Show More
@@ -0,0 +1,18 b'' | |||
|
1 | diff --git a/gravatar.png b/gravatar.png | |
|
2 | old mode 100644 | |
|
3 | new mode 100755 | |
|
4 | index 54d2d129e3372c45a4c68a742e269864222e99ae..0c1d65410bd51fdff935443e01931c9fc3ad7def | |
|
5 | GIT binary patch | |
|
6 | literal 740 | |
|
7 | zc%17D@N?(olHy`uVBq!ia0vp^dx3Z#2NRHduQ>B0kYX$ja(7}_cTVOdki%Kv5n0T@ | |
|
8 | zz%2~Ij105pNB{-dOFVsD*>AH+2@7*F&3eGWz`&H|>EaktaqI0JMZd!V5(hqpU(%ki | |
|
9 | zz<{N_Dc~^g1GeA{8S#b#jBU<`Ij0FINT{SO2`=WI*Kku%Kte?~QvUtk`~FuatbIH` | |
|
10 | zU*0#<bY2fr$(Coz4(2b|?k<qNz`M&4#A?WcvPzmkEJg29#pjiUe<s|iw%c!Ml>foD | |
|
11 | zHLr#RtfPb(q61ZL^D3dLy27sS9LG1ks-ApS8e$A1NIi%J(b=2_we?fTsn6Zh<#UVP | |
|
12 | z|9tiF%$|eaMRt7@#I6)<9go)1-`(@)=Q(p!@3vNKDKmRt(o@-7dHLx1lNY~Ad}g~_ | |
|
13 | za{b)1``zCC$!DbBm~WE-irmOC$k!;|zwzb_^B2daEtWo!yMN=;86Y!nbQtDu5Wn34 | |
|
14 | zbmZh?b(0@$%sb%=43(hD^~>9*yZ+6yNtdtp|J$sq{^jrc-CO$Jn%~HOWByJ0bK9TY | |
|
15 | zg@4_kydS*R^JDe{4Z08FKRNbQ`g%Ud?r+k+d3UblwmiT6sL83<_jKRAJ-Pr-V6<tp | |
|
16 | z?epIfY2R5iFZ#Ccl<T?EX78;p`&F5H??E-!-5(q%k>Y5MY!uto=R2=&d?)y?yZLYL | |
|
17 | zJ^SCEe$Bh{bKS3dDW9<fAX0p_*<5X%lMalj*{B8|p0JPMtzFP9%Uvy?WXj;_>gTe~ | |
|
18 | RDWNH`I3+QqIFSoR0|1y<SJMCh No newline at end of file |
@@ -0,0 +1,10 b'' | |||
|
1 | diff --git a/README b/README.rst | |
|
2 | rename from README | |
|
3 | rename to README.rst | |
|
4 | --- a/README | |
|
5 | +++ b/README.rst | |
|
6 | @@ -1,1 +1,4 @@ | |
|
7 | readme2 | |
|
8 | +line 1 | |
|
9 | + line2 | |
|
10 | + No newline at end of file |
@@ -0,0 +1,15 b'' | |||
|
1 | diff --git a/README.rst b/README | |
|
2 | old mode 100755 | |
|
3 | new mode 100644 | |
|
4 | rename from README.rst | |
|
5 | rename to README | |
|
6 | --- a/README.rst | |
|
7 | +++ b/README | |
|
8 | @@ -1,4 +1,7 @@ | |
|
9 | readme2 | |
|
10 | line 1 | |
|
11 | line2 | |
|
12 | ||
|
13 | +line 1 | |
|
14 | + line2 | |
|
15 | + No newline at end of file |
@@ -0,0 +1,5 b'' | |||
|
1 | diff --git a/README.rst b/README | |
|
2 | old mode 100644 | |
|
3 | new mode 100755 | |
|
4 | rename from README.rst | |
|
5 | rename to README No newline at end of file |
@@ -265,9 +265,8 b' class ChangesetController(BaseRepoContro' | |||
|
265 | 265 | c.limited_diff = True |
|
266 | 266 | for f in _parsed: |
|
267 | 267 | st = f['stats'] |
|
268 |
|
|
|
269 |
|
|
|
270 | c.lines_deleted += st[1] | |
|
268 | c.lines_added += st['added'] | |
|
269 | c.lines_deleted += st['deleted'] | |
|
271 | 270 | fid = h.FID(changeset.raw_id, f['filename']) |
|
272 | 271 | diff = diff_processor.as_html(enable_comments=enable_comments, |
|
273 | 272 | parsed_lines=[f]) |
@@ -258,9 +258,9 b' class CompareController(BaseRepoControll' | |||
|
258 | 258 | c.lines_deleted = 0 |
|
259 | 259 | for f in _parsed: |
|
260 | 260 | st = f['stats'] |
|
261 |
if st[ |
|
|
262 |
c.lines_added += st[ |
|
|
263 |
c.lines_deleted += st[ |
|
|
261 | if not st['binary']: | |
|
262 | c.lines_added += st['added'] | |
|
263 | c.lines_deleted += st['deleted'] | |
|
264 | 264 | fid = h.FID('', f['filename']) |
|
265 | 265 | c.files.append([fid, f['operation'], f['filename'], f['stats']]) |
|
266 | 266 | htmldiff = diff_processor.as_html(enable_comments=False, parsed_lines=[f]) |
@@ -76,8 +76,8 b' class FeedController(BaseRepoController)' | |||
|
76 | 76 | limited_diff = True |
|
77 | 77 | |
|
78 | 78 | for st in _parsed: |
|
79 |
st.update({'added': st['stats'][ |
|
|
80 |
'removed': st['stats'][ |
|
|
79 | st.update({'added': st['stats']['added'], | |
|
80 | 'removed': st['stats']['deleted']}) | |
|
81 | 81 | changes.append('\n %(operation)s %(filename)s ' |
|
82 | 82 | '(%(added)s lines added, %(removed)s lines removed)' |
|
83 | 83 | % st) |
@@ -213,13 +213,10 b' class PullrequestsController(BaseRepoCon' | |||
|
213 | 213 | |
|
214 | 214 | c.files = [] |
|
215 | 215 | c.changes = {} |
|
216 | c.lines_added = 0 | |
|
217 | c.lines_deleted = 0 | |
|
218 | 216 | for f in _parsed: |
|
219 | 217 | st = f['stats'] |
|
220 | if st[0] != 'b': | |
|
221 |
|
|
|
222 | c.lines_deleted += st[1] | |
|
218 | c.lines_added += st['added'] | |
|
219 | c.lines_deleted += st['deleted'] | |
|
223 | 220 | fid = h.FID('', f['filename']) |
|
224 | 221 | c.files.append([fid, f['operation'], f['filename'], f['stats']]) |
|
225 | 222 | htmldiff = diff_processor.as_html(enable_comments=enable_comments, |
@@ -128,6 +128,7 b' DEL_FILENODE = 2' | |||
|
128 | 128 | MOD_FILENODE = 3 |
|
129 | 129 | RENAMED_FILENODE = 4 |
|
130 | 130 | CHMOD_FILENODE = 5 |
|
131 | BIN_FILENODE = 6 | |
|
131 | 132 | |
|
132 | 133 | |
|
133 | 134 | class DiffLimitExceeded(Exception): |
@@ -166,6 +167,7 b' class DiffProcessor(object):' | |||
|
166 | 167 | (?:^deleted[ ]file[ ]mode[ ](?P<deleted_file_mode>.+)(?:\n|$))? |
|
167 | 168 | (?:^index[ ](?P<a_blob_id>[0-9A-Fa-f]+) |
|
168 | 169 | \.\.(?P<b_blob_id>[0-9A-Fa-f]+)[ ]?(?P<b_mode>.+)?(?:\n|$))? |
|
170 | (?:^(?P<bin_patch>GIT[ ]binary[ ]patch)(?:\n|$))? | |
|
169 | 171 | (?:^---[ ](a/(?P<a_file>.+)|/dev/null)(?:\n|$))? |
|
170 | 172 | (?:^\+\+\+[ ](b/(?P<b_file>.+)|/dev/null)(?:\n|$))? |
|
171 | 173 | """, re.VERBOSE | re.MULTILINE) |
@@ -181,6 +183,7 b' class DiffProcessor(object):' | |||
|
181 | 183 | (?:^deleted[ ]file[ ]mode[ ](?P<deleted_file_mode>.+)(?:\n|$))? |
|
182 | 184 | (?:^index[ ](?P<a_blob_id>[0-9A-Fa-f]+) |
|
183 | 185 | \.\.(?P<b_blob_id>[0-9A-Fa-f]+)[ ]?(?P<b_mode>.+)?(?:\n|$))? |
|
186 | (?:^(?P<bin_patch>GIT[ ]binary[ ]patch)(?:\n|$))? | |
|
184 | 187 | (?:^---[ ](a/(?P<a_file>.+)|/dev/null)(?:\n|$))? |
|
185 | 188 | (?:^\+\+\+[ ](b/(?P<b_file>.+)|/dev/null)(?:\n|$))? |
|
186 | 189 | """, re.VERBOSE | re.MULTILINE) |
@@ -357,62 +360,84 b' class DiffProcessor(object):' | |||
|
357 | 360 | head, diff = self._get_header(raw_diff) |
|
358 | 361 | |
|
359 | 362 | op = None |
|
360 |
stats = |
|
|
361 | msgs = [] | |
|
363 | stats = { | |
|
364 | 'added': 0, | |
|
365 | 'deleted': 0, | |
|
366 | 'binary': False, | |
|
367 | 'ops': {}, | |
|
368 | } | |
|
362 | 369 | |
|
363 | 370 | if head['deleted_file_mode']: |
|
364 | 371 | op = 'D' |
|
365 | stats = ['b', DEL_FILENODE] | |
|
366 |
|
|
|
372 | stats['binary'] = True | |
|
373 | stats['ops'][DEL_FILENODE] = 'deleted file' | |
|
374 | ||
|
367 | 375 | elif head['new_file_mode']: |
|
368 | 376 | op = 'A' |
|
369 | stats = ['b', NEW_FILENODE] | |
|
370 |
|
|
|
371 | else: | |
|
377 | stats['binary'] = True | |
|
378 | stats['ops'][NEW_FILENODE] = 'new file %s' % head['new_file_mode'] | |
|
379 | else: # modify operation, can be cp, rename, chmod | |
|
380 | # CHMOD | |
|
372 | 381 | if head['new_mode'] and head['old_mode']: |
|
373 | 382 | op = 'M' |
|
374 |
stats = |
|
|
375 |
|
|
|
383 | stats['binary'] = True | |
|
384 | stats['ops'][CHMOD_FILENODE] = ('modified file chmod %s => %s' | |
|
376 | 385 | % (head['old_mode'], head['new_mode'])) |
|
386 | # RENAME | |
|
377 | 387 | if (head['rename_from'] and head['rename_to'] |
|
378 | 388 | and head['rename_from'] != head['rename_to']): |
|
379 | 389 | op = 'M' |
|
380 | stats = ['b', RENAMED_FILENODE] # might overwrite CHMOD_FILENODE | |
|
381 |
|
|
|
390 | stats['binary'] = True | |
|
391 | stats['ops'][RENAMED_FILENODE] = ('file renamed from %s to %s' | |
|
382 | 392 | % (head['rename_from'], head['rename_to'])) |
|
383 | if op is None: # fall back: detect missed old style add or remove | |
|
393 | ||
|
394 | # FALL BACK: detect missed old style add or remove | |
|
395 | if op is None: | |
|
384 | 396 | if not head['a_file'] and head['b_file']: |
|
385 | 397 | op = 'A' |
|
386 |
stats = |
|
|
387 |
|
|
|
398 | stats['binary'] = True | |
|
399 | stats['ops'][NEW_FILENODE] = 'new file' | |
|
400 | ||
|
388 | 401 | elif head['a_file'] and not head['b_file']: |
|
389 | 402 | op = 'D' |
|
390 |
stats = |
|
|
391 |
|
|
|
403 | stats['binary'] = True | |
|
404 | stats['ops'][DEL_FILENODE] = 'deleted file' | |
|
405 | ||
|
406 | # it's not ADD not DELETE | |
|
392 | 407 | if op is None: |
|
393 | 408 | op = 'M' |
|
394 |
stats = |
|
|
409 | stats['binary'] = True | |
|
410 | stats['ops'][MOD_FILENODE] = 'modified file' | |
|
395 | 411 | |
|
396 | if head['a_file'] or head['b_file']: # a real diff | |
|
412 | # a real non-binary diff | |
|
413 | if head['a_file'] or head['b_file']: | |
|
397 | 414 | try: |
|
398 | chunks, stats = self._parse_lines(diff) | |
|
415 | chunks, _stats = self._parse_lines(diff) | |
|
416 | stats['binary'] = False | |
|
417 | stats['added'] = _stats[0] | |
|
418 | stats['deleted'] = _stats[1] | |
|
419 | # explicit mark that it's a modified file | |
|
420 | if op == 'M': | |
|
421 | stats['ops'][MOD_FILENODE] = 'modified file' | |
|
422 | ||
|
399 | 423 | except DiffLimitExceeded: |
|
400 |
diff_container = lambda _diff: |
|
|
401 |
|
|
|
402 |
|
|
|
403 | _diff) | |
|
424 | diff_container = lambda _diff: \ | |
|
425 | LimitedDiffContainer(self.diff_limit, | |
|
426 | self.cur_diff_size, _diff) | |
|
404 | 427 | break |
|
405 | 428 | else: # GIT binary patch (or empty diff) |
|
429 | # GIT Binary patch | |
|
430 | if head['bin_patch']: | |
|
431 | stats['ops'][BIN_FILENODE] = 'binary diff not shown' | |
|
406 | 432 | chunks = [] |
|
407 | msgs.append('binary diff not shown') # or no diff because it was a rename or chmod or add/remove of empty file | |
|
408 | 433 | |
|
409 | if msgs: | |
|
410 | 434 |
|
|
411 | 435 |
|
|
412 | 436 |
|
|
413 |
|
|
|
437 | 'action': 'context', | |
|
414 | 438 |
|
|
415 |
|
|
|
439 | } for _op, msg in stats['ops'].iteritems() | |
|
440 | if _op not in [MOD_FILENODE]]) | |
|
416 | 441 | |
|
417 | 442 | _files.append({ |
|
418 | 443 | 'filename': head['b_path'], |
@@ -1078,6 +1078,9 b' def fancy_file_stats(stats):' | |||
|
1078 | 1078 | |
|
1079 | 1079 | :param stats: two element list of added/deleted lines of code |
|
1080 | 1080 | """ |
|
1081 | from rhodecode.lib.diffs import NEW_FILENODE, DEL_FILENODE, \ | |
|
1082 | MOD_FILENODE, RENAMED_FILENODE, CHMOD_FILENODE, BIN_FILENODE | |
|
1083 | ||
|
1081 | 1084 | def cgen(l_type, a_v, d_v): |
|
1082 | 1085 | mapping = {'tr': 'top-right-rounded-corner-mid', |
|
1083 | 1086 | 'tl': 'top-left-rounded-corner-mid', |
@@ -1098,16 +1101,41 b' def fancy_file_stats(stats):' | |||
|
1098 | 1101 | if l_type == 'd' and not a_v: |
|
1099 | 1102 | return ' '.join(map(map_getter, ['tr', 'br', 'tl', 'bl'])) |
|
1100 | 1103 | |
|
1101 |
a, d = stats[ |
|
|
1104 | a, d = stats['added'], stats['deleted'] | |
|
1102 | 1105 | width = 100 |
|
1103 | 1106 | |
|
1104 |
if |
|
|
1107 | if stats['binary']: | |
|
1105 | 1108 | #binary mode |
|
1106 | b_d = '<div class="bin%s %s" style="width:100%%">%s</div>' % (d, cgen('a', a_v='', d_v=0), 'bin') | |
|
1107 | b_a = '<div class="bin1" style="width:0%%">%s</div>' % ('bin') | |
|
1109 | lbl = '' | |
|
1110 | bin_op = 1 | |
|
1111 | ||
|
1112 | if BIN_FILENODE in stats['ops']: | |
|
1113 | lbl = 'bin+' | |
|
1114 | ||
|
1115 | if NEW_FILENODE in stats['ops']: | |
|
1116 | lbl += _('new file') | |
|
1117 | bin_op = NEW_FILENODE | |
|
1118 | elif MOD_FILENODE in stats['ops']: | |
|
1119 | lbl += _('mod') | |
|
1120 | bin_op = MOD_FILENODE | |
|
1121 | elif DEL_FILENODE in stats['ops']: | |
|
1122 | lbl += _('del') | |
|
1123 | bin_op = DEL_FILENODE | |
|
1124 | elif RENAMED_FILENODE in stats['ops']: | |
|
1125 | lbl += _('rename') | |
|
1126 | bin_op = RENAMED_FILENODE | |
|
1127 | ||
|
1128 | #chmod can go with other operations | |
|
1129 | if CHMOD_FILENODE in stats['ops']: | |
|
1130 | _org_lbl = _('chmod') | |
|
1131 | lbl += _org_lbl if lbl.endswith('+') else '+%s' % _org_lbl | |
|
1132 | ||
|
1133 | #import ipdb;ipdb.set_trace() | |
|
1134 | b_d = '<div class="bin bin%s %s" style="width:100%%">%s</div>' % (bin_op, cgen('a', a_v='', d_v=0), lbl) | |
|
1135 | b_a = '<div class="bin bin1" style="width:0%%"></div>' | |
|
1108 | 1136 | return literal('<div style="width:%spx">%s%s</div>' % (width, b_a, b_d)) |
|
1109 | 1137 | |
|
1110 |
t = stats[ |
|
|
1138 | t = stats['added'] + stats['deleted'] | |
|
1111 | 1139 | unit = float(width) / (t or 1) |
|
1112 | 1140 | |
|
1113 | 1141 | # needs > 9% of width to be visible or 0 to be hidden |
@@ -2404,42 +2404,49 b' h3.files_location {' | |||
|
2404 | 2404 | font-size: 9px; |
|
2405 | 2405 | padding: 2px 0px 2px 0px; |
|
2406 | 2406 | } |
|
2407 |
/*new binary |
|
|
2408 | .cs_files .changes .bin1 { | |
|
2407 | /*new binary | |
|
2408 | NEW_FILENODE = 1 | |
|
2409 | DEL_FILENODE = 2 | |
|
2410 | MOD_FILENODE = 3 | |
|
2411 | RENAMED_FILENODE = 4 | |
|
2412 | CHMOD_FILENODE = 5 | |
|
2413 | BIN_FILENODE = 6 | |
|
2414 | */ | |
|
2415 | .cs_files .changes .bin { | |
|
2409 | 2416 | background-color: #BBFFBB; |
|
2410 | 2417 | float: left; |
|
2411 | 2418 | text-align: center; |
|
2412 | 2419 | font-size: 9px; |
|
2413 | 2420 | padding: 2px 0px 2px 0px; |
|
2414 | 2421 | } |
|
2422 | .cs_files .changes .bin.bin1 { | |
|
2423 | background-color: #BBFFBB; | |
|
2424 | } | |
|
2415 | 2425 | |
|
2416 | 2426 | /*deleted binary*/ |
|
2417 | .cs_files .changes .bin2 { | |
|
2427 | .cs_files .changes .bin.bin2 { | |
|
2418 | 2428 | background-color: #FF8888; |
|
2419 | float: left; | |
|
2420 | text-align: center; | |
|
2421 | font-size: 9px; | |
|
2422 | padding: 2px 0px 2px 0px; | |
|
2423 | 2429 | } |
|
2424 | 2430 | |
|
2425 | 2431 | /*mod binary*/ |
|
2426 | .cs_files .changes .bin3 { | |
|
2432 | .cs_files .changes .bin.bin3 { | |
|
2427 | 2433 | background-color: #DDDDDD; |
|
2428 | float: left; | |
|
2429 | text-align: center; | |
|
2430 | font-size: 9px; | |
|
2431 | padding: 2px 0px 2px 0px; | |
|
2432 | 2434 | } |
|
2433 | 2435 | |
|
2434 | 2436 | /*rename file*/ |
|
2435 | .cs_files .changes .bin4 { | |
|
2437 | .cs_files .changes .bin.bin4 { | |
|
2438 | background-color: #6D99FF; | |
|
2439 | } | |
|
2440 | ||
|
2441 | /*rename file*/ | |
|
2442 | .cs_files .changes .bin.bin4 { | |
|
2436 | 2443 | background-color: #6D99FF; |
|
2437 | float: left; | |
|
2438 | text-align: center; | |
|
2439 | font-size: 9px; | |
|
2440 | padding: 2px 0px 2px 0px; | |
|
2441 | } | |
|
2442 | ||
|
2444 | } | |
|
2445 | ||
|
2446 | /*chmod file*/ | |
|
2447 | .cs_files .changes .bin.bin5 { | |
|
2448 | background-color: #6D99FF; | |
|
2449 | } | |
|
2443 | 2450 | |
|
2444 | 2451 | .cs_files .cs_added, .cs_files .cs_A { |
|
2445 | 2452 | background: url("../images/icons/page_white_add.png") no-repeat scroll |
@@ -9,7 +9,6 b'' | |||
|
9 | 9 | </div> |
|
10 | 10 | <div class="diff-container" id="${'diff-container-%s' % (id(change))}"> |
|
11 | 11 | %for FID,(cs1, cs2, change, path, diff, stats) in change.iteritems(): |
|
12 | ##%if op !='removed': | |
|
13 | 12 | <div id="${FID}_target" style="clear:both;margin-top:25px"></div> |
|
14 | 13 | <div id="${FID}" class="diffblock margined comm"> |
|
15 | 14 | <div class="code-header"> |
@@ -38,7 +37,6 b'' | |||
|
38 | 37 | ${diff|n} |
|
39 | 38 | </div> |
|
40 | 39 | </div> |
|
41 | ##%endif | |
|
42 | 40 | %endfor |
|
43 | 41 | </div> |
|
44 | 42 | </%def> |
@@ -9,7 +9,11 b' y)y@U((_~Lrb!=|_@`K?vV_&A58+!u-Gs6x+MGjB' | |||
|
9 | 9 | |
|
10 | 10 | diff --git a/img/baseline-20px.png b/img/baseline-20px.png |
|
11 | 11 | deleted file mode 100644 |
|
12 | Binary file img/baseline-20px.png has changed | |
|
12 | index f76dd238ade08917e6712764a16a22005a50573d..0000000000000000000000000000000000000000 | |
|
13 | GIT binary patch | |
|
14 | literal 0 | |
|
15 | Hc$@<O00001 | |
|
16 | ||
|
13 | 17 | diff --git a/index.html b/index.html |
|
14 | 18 | --- a/index.html |
|
15 | 19 | +++ b/index.html |
@@ -1,3 +1,6 b'' | |||
|
1 | 1 | diff --git a/US Warszawa.jpg b/US Warszawa.jpg |
|
2 | 2 | deleted file mode 100755 |
|
3 | Binary file US Warszawa.jpg has changed | |
|
3 | index f76dd238ade08917e6712764a16a22005a50573d..0000000000000000000000000000000000000000 | |
|
4 | GIT binary patch | |
|
5 | literal 0 | |
|
6 | Hc$@<O00001 |
@@ -3,84 +3,249 b' import os' | |||
|
3 | 3 | import unittest |
|
4 | 4 | from rhodecode.tests import * |
|
5 | 5 | from rhodecode.lib.diffs import DiffProcessor, NEW_FILENODE, DEL_FILENODE, \ |
|
6 | MOD_FILENODE, RENAMED_FILENODE, CHMOD_FILENODE | |
|
6 | MOD_FILENODE, RENAMED_FILENODE, CHMOD_FILENODE, BIN_FILENODE | |
|
7 | 7 | |
|
8 | 8 | dn = os.path.dirname |
|
9 | 9 | FIXTURES = os.path.join(dn(dn(os.path.abspath(__file__))), 'fixtures') |
|
10 | 10 | |
|
11 | 11 | DIFF_FIXTURES = { |
|
12 | 12 | 'hg_diff_add_single_binary_file.diff': [ |
|
13 |
( |
|
|
13 | ('US Warszawa.jpg', 'A', | |
|
14 | {'added': 0, | |
|
15 | 'deleted': 0, | |
|
16 | 'binary': True, | |
|
17 | 'ops': {NEW_FILENODE: 'new file 100755', | |
|
18 | BIN_FILENODE: 'binary diff not shown'}}), | |
|
14 | 19 | ], |
|
15 | 20 | 'hg_diff_mod_single_binary_file.diff': [ |
|
16 |
( |
|
|
21 | ('US Warszawa.jpg', 'M', | |
|
22 | {'added': 0, | |
|
23 | 'deleted': 0, | |
|
24 | 'binary': True, | |
|
25 | 'ops': {MOD_FILENODE: 'modified file', | |
|
26 | BIN_FILENODE: 'binary diff not shown'}}), | |
|
27 | ], | |
|
28 | ||
|
29 | 'hg_diff_mod_single_file_and_rename_and_chmod.diff': [ | |
|
30 | ('README', 'M', | |
|
31 | {'added': 3, | |
|
32 | 'deleted': 0, | |
|
33 | 'binary': False, | |
|
34 | 'ops': {MOD_FILENODE: 'modified file', | |
|
35 | RENAMED_FILENODE: 'file renamed from README.rst to README', | |
|
36 | CHMOD_FILENODE: 'modified file chmod 100755 => 100644'}}), | |
|
37 | ], | |
|
38 | 'hg_diff_rename_and_chmod_file.diff': [ | |
|
39 | ('README', 'M', | |
|
40 | {'added': 3, | |
|
41 | 'deleted': 0, | |
|
42 | 'binary': False, | |
|
43 | 'ops': {MOD_FILENODE: 'modified file', | |
|
44 | BIN_FILENODE: 'binary diff not shown'}}), | |
|
17 | 45 | ], |
|
18 | 46 | 'hg_diff_del_single_binary_file.diff': [ |
|
19 |
( |
|
|
47 | ('US Warszawa.jpg', 'D', | |
|
48 | {'added': 0, | |
|
49 | 'deleted': 0, | |
|
50 | 'binary': True, | |
|
51 | 'ops': {DEL_FILENODE: 'deleted file', | |
|
52 | BIN_FILENODE: 'binary diff not shown'}}), | |
|
53 | ], | |
|
54 | 'hg_diff_chmod_and_mod_single_binary_file.diff': [ | |
|
55 | ('gravatar.png', 'M', | |
|
56 | {'added': 0, | |
|
57 | 'deleted': 0, | |
|
58 | 'binary': True, | |
|
59 | 'ops': {CHMOD_FILENODE: 'modified file chmod 100644 => 100755', | |
|
60 | BIN_FILENODE: 'binary diff not shown'}}), | |
|
61 | ], | |
|
62 | 'hg_diff_chmod.diff': [ | |
|
63 | ('file', 'M', | |
|
64 | {'added': 0, | |
|
65 | 'deleted': 0, | |
|
66 | 'binary': True, | |
|
67 | 'ops': {CHMOD_FILENODE: 'modified file chmod 100755 => 100644'}}), | |
|
68 | ], | |
|
69 | 'hg_diff_rename_file.diff': [ | |
|
70 | ('file_renamed', 'M', | |
|
71 | {'added': 0, | |
|
72 | 'deleted': 0, | |
|
73 | 'binary': True, | |
|
74 | 'ops': {RENAMED_FILENODE: 'file renamed from file to file_renamed'}}), | |
|
75 | ], | |
|
76 | 'hg_diff_rename_and_chmod_file.diff': [ | |
|
77 | ('README', 'M', | |
|
78 | {'added': 0, | |
|
79 | 'deleted': 0, | |
|
80 | 'binary': True, | |
|
81 | 'ops': {CHMOD_FILENODE: 'modified file chmod 100644 => 100755', | |
|
82 | RENAMED_FILENODE: 'file renamed from README.rst to README'}}), | |
|
20 | 83 | ], |
|
21 | 84 | 'hg_diff_binary_and_normal.diff': [ |
|
22 |
( |
|
|
23 | (u'js/jquery/hashgrid.js', 'A', [340, 0]), | |
|
24 | (u'index.html', 'M', [3, 2]), | |
|
25 | (u'less/docs.less', 'M', [34, 0]), | |
|
26 | (u'less/scaffolding.less', 'M', [1, 3]), | |
|
27 | (u'readme.markdown', 'M', [1, 10]), | |
|
28 | (u'img/baseline-20px.png', 'D', ['b', DEL_FILENODE]), | |
|
29 | (u'js/global.js', 'D', [0, 75]) | |
|
30 | ], | |
|
31 | 'hg_diff_chmod.diff': [ | |
|
32 | (u'file', 'M', ['b', CHMOD_FILENODE]), | |
|
33 | ], | |
|
34 | 'hg_diff_rename_file.diff': [ | |
|
35 | (u'file_renamed', 'M', ['b', RENAMED_FILENODE]), | |
|
85 | ('img/baseline-10px.png', 'A', | |
|
86 | {'added': 0, | |
|
87 | 'deleted': 0, | |
|
88 | 'binary': True, | |
|
89 | 'ops': {NEW_FILENODE: 'new file 100644', | |
|
90 | BIN_FILENODE: 'binary diff not shown'}}), | |
|
91 | ('js/jquery/hashgrid.js', 'A', | |
|
92 | {'added': 340, | |
|
93 | 'deleted': 0, | |
|
94 | 'binary': False, | |
|
95 | 'ops': {NEW_FILENODE: 'new file 100755'}}), | |
|
96 | ('index.html', 'M', | |
|
97 | {'added': 3, | |
|
98 | 'deleted': 2, | |
|
99 | 'binary': False, | |
|
100 | 'ops': {MOD_FILENODE: 'modified file'}}), | |
|
101 | ('less/docs.less', 'M', | |
|
102 | {'added': 34, | |
|
103 | 'deleted': 0, | |
|
104 | 'binary': False, | |
|
105 | 'ops': {MOD_FILENODE: 'modified file'}}), | |
|
106 | ('less/scaffolding.less', 'M', | |
|
107 | {'added': 1, | |
|
108 | 'deleted': 3, | |
|
109 | 'binary': False, | |
|
110 | 'ops': {MOD_FILENODE: 'modified file'}}), | |
|
111 | ('readme.markdown', 'M', | |
|
112 | {'added': 1, | |
|
113 | 'deleted': 10, | |
|
114 | 'binary': False, | |
|
115 | 'ops': {MOD_FILENODE: 'modified file'}}), | |
|
116 | ('img/baseline-20px.png', 'D', | |
|
117 | {'added': 0, | |
|
118 | 'deleted': 0, | |
|
119 | 'binary': True, | |
|
120 | 'ops': {DEL_FILENODE: 'deleted file', | |
|
121 | BIN_FILENODE: 'binary diff not shown'}}), | |
|
122 | ('js/global.js', 'D', | |
|
123 | {'added': 0, | |
|
124 | 'deleted': 75, | |
|
125 | 'binary': False, | |
|
126 | 'ops': {DEL_FILENODE: 'deleted file'}}) | |
|
36 | 127 | ], |
|
37 | 128 | 'git_diff_chmod.diff': [ |
|
38 |
( |
|
|
129 | ('work-horus.xls', 'M', | |
|
130 | {'added': 0, | |
|
131 | 'deleted': 0, | |
|
132 | 'binary': True, | |
|
133 | 'ops': {CHMOD_FILENODE: 'modified file chmod 100644 => 100755'}}) | |
|
39 | 134 | ], |
|
40 | 135 | 'git_diff_rename_file.diff': [ |
|
41 |
( |
|
|
136 | ('file.xls', 'M', | |
|
137 | {'added': 0, | |
|
138 | 'deleted': 0, | |
|
139 | 'binary': True, | |
|
140 | 'ops': {RENAMED_FILENODE: 'file renamed from work-horus.xls to file.xls'}}) | |
|
42 | 141 | ], |
|
43 | 142 | 'git_diff_mod_single_binary_file.diff': [ |
|
44 |
('US Warszawa.jpg', 'M', |
|
|
45 | ||
|
143 | ('US Warszawa.jpg', 'M', | |
|
144 | {'added': 0, | |
|
145 | 'deleted': 0, | |
|
146 | 'binary': True, | |
|
147 | 'ops': {MOD_FILENODE: 'modified file', | |
|
148 | BIN_FILENODE: 'binary diff not shown'}}) | |
|
46 | 149 | ], |
|
47 | 150 | 'git_diff_binary_and_normal.diff': [ |
|
48 |
( |
|
|
49 | (u'js/jquery/hashgrid.js', 'A', [340, 0]), | |
|
50 | (u'index.html', 'M', [3, 2]), | |
|
51 | (u'less/docs.less', 'M', [34, 0]), | |
|
52 | (u'less/scaffolding.less', 'M', [1, 3]), | |
|
53 | (u'readme.markdown', 'M', [1, 10]), | |
|
54 | (u'img/baseline-20px.png', 'D', ['b', DEL_FILENODE]), | |
|
55 | (u'js/global.js', 'D', [0, 75]) | |
|
151 | ('img/baseline-10px.png', 'A', | |
|
152 | {'added': 0, | |
|
153 | 'deleted': 0, | |
|
154 | 'binary': True, | |
|
155 | 'ops': {NEW_FILENODE: 'new file 100644', | |
|
156 | BIN_FILENODE: 'binary diff not shown'}}), | |
|
157 | ('js/jquery/hashgrid.js', 'A', | |
|
158 | {'added': 340, | |
|
159 | 'deleted': 0, | |
|
160 | 'binary': False, | |
|
161 | 'ops': {NEW_FILENODE: 'new file 100755'}}), | |
|
162 | ('index.html', 'M', | |
|
163 | {'added': 3, | |
|
164 | 'deleted': 2, | |
|
165 | 'binary': False, | |
|
166 | 'ops': {MOD_FILENODE: 'modified file'}}), | |
|
167 | ('less/docs.less', 'M', | |
|
168 | {'added': 34, | |
|
169 | 'deleted': 0, | |
|
170 | 'binary': False, | |
|
171 | 'ops': {MOD_FILENODE: 'modified file'}}), | |
|
172 | ('less/scaffolding.less', 'M', | |
|
173 | {'added': 1, | |
|
174 | 'deleted': 3, | |
|
175 | 'binary': False, | |
|
176 | 'ops': {MOD_FILENODE: 'modified file'}}), | |
|
177 | ('readme.markdown', 'M', | |
|
178 | {'added': 1, | |
|
179 | 'deleted': 10, | |
|
180 | 'binary': False, | |
|
181 | 'ops': {MOD_FILENODE: 'modified file'}}), | |
|
182 | ('img/baseline-20px.png', 'D', | |
|
183 | {'added': 0, | |
|
184 | 'deleted': 0, | |
|
185 | 'binary': True, | |
|
186 | 'ops': {DEL_FILENODE: 'deleted file', | |
|
187 | BIN_FILENODE: 'binary diff not shown'}}), | |
|
188 | ('js/global.js', 'D', | |
|
189 | {'added': 0, | |
|
190 | 'deleted': 75, | |
|
191 | 'binary': False, | |
|
192 | 'ops': {DEL_FILENODE: 'deleted file'}}), | |
|
56 | 193 | ], |
|
57 | 194 | 'diff_with_diff_data.diff': [ |
|
58 |
( |
|
|
59 | (u'vcs/backends/git/repository.py', 'M', [46, 15]), | |
|
60 | (u'vcs/backends/hg.py', 'M', [22, 3]), | |
|
61 | (u'vcs/tests/test_git.py', 'M', [5, 5]), | |
|
62 | (u'vcs/tests/test_repository.py', 'M', [174, 2]) | |
|
195 | ('vcs/backends/base.py', 'M', | |
|
196 | {'added': 18, | |
|
197 | 'deleted': 2, | |
|
198 | 'binary': False, | |
|
199 | 'ops': {MOD_FILENODE: 'modified file'}}), | |
|
200 | ('vcs/backends/git/repository.py', 'M', | |
|
201 | {'added': 46, | |
|
202 | 'deleted': 15, | |
|
203 | 'binary': False, | |
|
204 | 'ops': {MOD_FILENODE: 'modified file'}}), | |
|
205 | ('vcs/backends/hg.py', 'M', | |
|
206 | {'added': 22, | |
|
207 | 'deleted': 3, | |
|
208 | 'binary': False, | |
|
209 | 'ops': {MOD_FILENODE: 'modified file'}}), | |
|
210 | ('vcs/tests/test_git.py', 'M', | |
|
211 | {'added': 5, | |
|
212 | 'deleted': 5, | |
|
213 | 'binary': False, | |
|
214 | 'ops': {MOD_FILENODE: 'modified file'}}), | |
|
215 | ('vcs/tests/test_repository.py', 'M', | |
|
216 | {'added': 174, | |
|
217 | 'deleted': 2, | |
|
218 | 'binary': False, | |
|
219 | 'ops': {MOD_FILENODE: 'modified file'}}), | |
|
63 | 220 | ], |
|
64 | 221 | # 'large_diff.diff': [ |
|
65 | # | |
|
222 | # ('.hgignore', 'A', {'deleted': 0, 'binary': False, 'added': 3, 'ops': {1: 'new file 100644'}}), | |
|
223 | # ('MANIFEST.in', 'A', {'deleted': 0, 'binary': False, 'added': 3, 'ops': {1: 'new file 100644'}}), | |
|
224 | # ('README.txt', 'A', {'deleted': 0, 'binary': False, 'added': 19, 'ops': {1: 'new file 100644'}}), | |
|
225 | # ('development.ini', 'A', {'deleted': 0, 'binary': False, 'added': 116, 'ops': {1: 'new file 100644'}}), | |
|
226 | # ('docs/index.txt', 'A', {'deleted': 0, 'binary': False, 'added': 19, 'ops': {1: 'new file 100644'}}), | |
|
227 | # ('ez_setup.py', 'A', {'deleted': 0, 'binary': False, 'added': 276, 'ops': {1: 'new file 100644'}}), | |
|
228 | # ('hgapp.py', 'A', {'deleted': 0, 'binary': False, 'added': 26, 'ops': {1: 'new file 100644'}}), | |
|
229 | # ('hgwebdir.config', 'A', {'deleted': 0, 'binary': False, 'added': 21, 'ops': {1: 'new file 100644'}}), | |
|
230 | # ('pylons_app.egg-info/PKG-INFO', 'A', {'deleted': 0, 'binary': False, 'added': 10, 'ops': {1: 'new file 100644'}}), | |
|
231 | # ('pylons_app.egg-info/SOURCES.txt', 'A', {'deleted': 0, 'binary': False, 'added': 33, 'ops': {1: 'new file 100644'}}), | |
|
232 | # ('pylons_app.egg-info/dependency_links.txt', 'A', {'deleted': 0, 'binary': False, 'added': 1, 'ops': {1: 'new file 100644'}}), | |
|
233 | # #TODO: | |
|
66 | 234 | # ], |
|
67 | 235 | |
|
68 | ||
|
69 | 236 | } |
|
70 | 237 | |
|
71 | 238 | |
|
72 | def _diff_checker(fixture): | |
|
73 | with open(os.path.join(FIXTURES, fixture)) as f: | |
|
239 | class DiffLibTest(unittest.TestCase): | |
|
240 | ||
|
241 | @parameterized.expand([(x,) for x in DIFF_FIXTURES]) | |
|
242 | def test_diff(self, diff_fixture): | |
|
243 | ||
|
244 | with open(os.path.join(FIXTURES, diff_fixture)) as f: | |
|
74 | 245 | diff = f.read() |
|
75 | 246 | |
|
76 | 247 | diff_proc = DiffProcessor(diff) |
|
77 | 248 | diff_proc_d = diff_proc.prepare() |
|
78 | 249 | data = [(x['filename'], x['operation'], x['stats']) for x in diff_proc_d] |
|
79 | expected_data = DIFF_FIXTURES[fixture] | |
|
80 | ||
|
81 | assert expected_data == data | |
|
82 | ||
|
83 | ||
|
84 | def test_parse_diff(): | |
|
85 | for fixture in DIFF_FIXTURES: | |
|
86 | yield _diff_checker, fixture | |
|
250 | expected_data = DIFF_FIXTURES[diff_fixture] | |
|
251 | self.assertListEqual(expected_data, data) |
General Comments 0
You need to be logged in to leave comments.
Login now