aboutsummaryrefslogtreecommitdiff
path: root/rhodecode/tests/models
diff options
context:
space:
mode:
authorMarcin Kuzminski <marcin@python-works.com>2012-11-05 19:57:29 +0100
committerMarcin Kuzminski <marcin@python-works.com>2012-11-05 19:57:29 +0100
commit2ef9943a71f1b8abab06df77ab638ff7596b0005 (patch)
tree03036b446dddf221ce0f74d4dcb75c87ceae4528 /rhodecode/tests/models
parent0797edac787a4c723eb1b01cb9fcda28f3fec3bf (diff)
Implemented generation of changesets based
on whole diff instead of per file diff. That can give a big speed improvement for large changesets in repositories with large history. - improved handling of binary files - show renames of binary files - implemented new diff limit functionality - unify diff generation between hg and git - Added binary indicators for changed files, - added diff lib tests --HG-- branch : beta extra : amend_source : 0648fbfbaf56e25c177ab5c34ba75a9edd227561
Diffstat (limited to 'rhodecode/tests/models')
-rw-r--r--rhodecode/tests/models/test_diff_parsers.py78
1 files changed, 78 insertions, 0 deletions
diff --git a/rhodecode/tests/models/test_diff_parsers.py b/rhodecode/tests/models/test_diff_parsers.py
new file mode 100644
index 00000000..e5e35a04
--- /dev/null
+++ b/rhodecode/tests/models/test_diff_parsers.py
@@ -0,0 +1,78 @@
+import os
+import unittest
+from rhodecode.tests import *
+from rhodecode.lib.diffs import DiffProcessor, NEW_FILENODE, DEL_FILENODE, \
+ MOD_FILENODE, RENAMED_FILENODE, CHMOD_FILENODE
+
+dn = os.path.dirname
+FIXTURES = os.path.join(dn(dn(os.path.abspath(__file__))), 'fixtures')
+
+DIFF_FIXTURES = {
+ 'hg_diff_add_single_binary_file.diff': [
+ (u'US Warszawa.jpg', 'A', ['b', NEW_FILENODE]),
+ ],
+ 'hg_diff_mod_single_binary_file.diff': [
+ (u'US Warszawa.jpg', 'M', ['b', MOD_FILENODE]),
+ ],
+ 'hg_diff_del_single_binary_file.diff': [
+ (u'US Warszawa.jpg', 'D', ['b', DEL_FILENODE]),
+ ],
+ 'hg_diff_binary_and_normal.diff': [
+ (u'img/baseline-10px.png', 'A', ['b', NEW_FILENODE]),
+ (u'js/jquery/hashgrid.js', 'A', [340, 0]),
+ (u'index.html', 'M', [3, 2]),
+ (u'less/docs.less', 'M', [34, 0]),
+ (u'less/scaffolding.less', 'M', [1, 3]),
+ (u'readme.markdown', 'M', [1, 10]),
+ (u'img/baseline-20px.png', 'D', ['b', DEL_FILENODE]),
+ (u'js/global.js', 'D', [0, 75])
+ ],
+ 'hg_diff_chmod.diff': [
+ (u'file', 'M', ['b', CHMOD_FILENODE]),
+ ],
+ 'hg_diff_rename_file.diff': [
+ (u'file_renamed', 'M', ['b', RENAMED_FILENODE]),
+ ],
+ 'git_diff_chmod.diff': [
+ (u'work-horus.xls', 'M', ['b', CHMOD_FILENODE]),
+ ],
+ 'git_diff_rename_file.diff': [
+ (u'file.xls', 'M', ['b', RENAMED_FILENODE]),
+ ],
+ 'git_diff_mod_single_binary_file.diff': [
+ ('US Warszawa.jpg', 'M', ['b', MOD_FILENODE])
+
+ ],
+ 'git_diff_binary_and_normal.diff': [
+ (u'img/baseline-10px.png', 'A', ['b', NEW_FILENODE]),
+ (u'js/jquery/hashgrid.js', 'A', [340, 0]),
+ (u'index.html', 'M', [3, 2]),
+ (u'less/docs.less', 'M', [34, 0]),
+ (u'less/scaffolding.less', 'M', [1, 3]),
+ (u'readme.markdown', 'M', [1, 10]),
+ (u'img/baseline-20px.png', 'D', ['b', DEL_FILENODE]),
+ (u'js/global.js', 'D', [0, 75])
+ ],
+# 'large_diff.diff': [
+#
+# ],
+
+
+}
+
+
+def _diff_checker(fixture):
+ with open(os.path.join(FIXTURES, fixture)) as f:
+ diff = f.read()
+
+ diff_proc = DiffProcessor(diff)
+ diff_proc_d = diff_proc.prepare()
+ data = [(x['filename'], x['operation'], x['stats']) for x in diff_proc_d]
+ expected_data = DIFF_FIXTURES[fixture]
+
+ assert expected_data == data
+
+
+def test_parse_diff():
+ for fixture in DIFF_FIXTURES:
+ yield _diff_checker, fixture