Show More
@@ -8,7 +8,7 b'' | |||||
8 | import os, mimetypes, re, cgi, copy |
|
8 | import os, mimetypes, re, cgi, copy | |
9 | import webutil |
|
9 | import webutil | |
10 | from mercurial import error, encoding, archival, templater, templatefilters |
|
10 | from mercurial import error, encoding, archival, templater, templatefilters | |
11 | from mercurial.node import short, hex |
|
11 | from mercurial.node import short, hex, nullid | |
12 | from mercurial.util import binary |
|
12 | from mercurial.util import binary | |
13 | from common import paritygen, staticfile, get_contact, ErrorResponse |
|
13 | from common import paritygen, staticfile, get_contact, ErrorResponse | |
14 | from common import HTTP_OK, HTTP_FORBIDDEN, HTTP_NOT_FOUND |
|
14 | from common import HTTP_OK, HTTP_FORBIDDEN, HTTP_NOT_FOUND | |
@@ -597,7 +597,39 b' def comparison(web, req, tmpl):' | |||||
597 | else: |
|
597 | else: | |
598 | context = parsecontext(web.config('web', 'comparisoncontext', '5')) |
|
598 | context = parsecontext(web.config('web', 'comparisoncontext', '5')) | |
599 |
|
599 | |||
600 | comparison = webutil.compare(tmpl, ctx, path, context) |
|
600 | def filelines(f): | |
|
601 | if binary(f.data()): | |||
|
602 | mt = mimetypes.guess_type(f.path())[0] | |||
|
603 | if not mt: | |||
|
604 | mt = 'application/octet-stream' | |||
|
605 | return [_('(binary file %s, hash: %s)') % (mt, hex(f.filenode()))] | |||
|
606 | return f.data().splitlines() | |||
|
607 | ||||
|
608 | if path in ctx: | |||
|
609 | fctx = ctx[path] | |||
|
610 | rightrev = fctx.filerev() | |||
|
611 | rightnode = fctx.filenode() | |||
|
612 | rightlines = filelines(fctx) | |||
|
613 | parents = fctx.parents() | |||
|
614 | if not parents: | |||
|
615 | leftrev = -1 | |||
|
616 | leftnode = nullid | |||
|
617 | leftlines = () | |||
|
618 | else: | |||
|
619 | pfctx = parents[0] | |||
|
620 | leftrev = pfctx.filerev() | |||
|
621 | leftnode = pfctx.filenode() | |||
|
622 | leftlines = filelines(pfctx) | |||
|
623 | else: | |||
|
624 | rightrev = -1 | |||
|
625 | rightnode = nullid | |||
|
626 | rightlines = () | |||
|
627 | fctx = ctx.parents()[0][path] | |||
|
628 | leftrev = fctx.filerev() | |||
|
629 | leftnode = fctx.filenode() | |||
|
630 | leftlines = filelines(fctx) | |||
|
631 | ||||
|
632 | comparison = webutil.compare(tmpl, context, leftlines, rightlines) | |||
601 | return tmpl('filecomparison', |
|
633 | return tmpl('filecomparison', | |
602 | file=path, |
|
634 | file=path, | |
603 | node=hex(ctx.node()), |
|
635 | node=hex(ctx.node()), | |
@@ -609,6 +641,10 b' def comparison(web, req, tmpl):' | |||||
609 | branch=webutil.nodebranchnodefault(ctx), |
|
641 | branch=webutil.nodebranchnodefault(ctx), | |
610 | parent=webutil.parents(ctx), |
|
642 | parent=webutil.parents(ctx), | |
611 | child=webutil.children(ctx), |
|
643 | child=webutil.children(ctx), | |
|
644 | leftrev=leftrev, | |||
|
645 | leftnode=hex(leftnode), | |||
|
646 | rightrev=rightrev, | |||
|
647 | rightnode=hex(rightnode), | |||
612 | comparison=comparison) |
|
648 | comparison=comparison) | |
613 |
|
649 | |||
614 | def annotate(web, req, tmpl): |
|
650 | def annotate(web, req, tmpl): |
@@ -6,7 +6,7 b'' | |||||
6 | # This software may be used and distributed according to the terms of the |
|
6 | # This software may be used and distributed according to the terms of the | |
7 | # GNU General Public License version 2 or any later version. |
|
7 | # GNU General Public License version 2 or any later version. | |
8 |
|
8 | |||
9 |
import os, |
|
9 | import os, copy | |
10 | from mercurial import match, patch, scmutil, error, ui, util |
|
10 | from mercurial import match, patch, scmutil, error, ui, util | |
11 | from mercurial.i18n import _ |
|
11 | from mercurial.i18n import _ | |
12 | from mercurial.node import hex, nullid |
|
12 | from mercurial.node import hex, nullid | |
@@ -227,17 +227,9 b' def diffs(repo, tmpl, ctx, files, parity' | |||||
227 | yield tmpl('diffblock', parity=parity.next(), blockno=blockno, |
|
227 | yield tmpl('diffblock', parity=parity.next(), blockno=blockno, | |
228 | lines=prettyprintlines(''.join(block), blockno)) |
|
228 | lines=prettyprintlines(''.join(block), blockno)) | |
229 |
|
229 | |||
230 |
def compare(tmpl, ctx, |
|
230 | def compare(tmpl, context, leftlines, rightlines): | |
231 | '''Generator function that provides side-by-side comparison data.''' |
|
231 | '''Generator function that provides side-by-side comparison data.''' | |
232 |
|
232 | |||
233 | def filelines(f): |
|
|||
234 | if util.binary(f.data()): |
|
|||
235 | mt = mimetypes.guess_type(f.path())[0] |
|
|||
236 | if not mt: |
|
|||
237 | mt = 'application/octet-stream' |
|
|||
238 | return [_('(binary file %s, hash: %s)') % (mt, hex(f.filenode()))] |
|
|||
239 | return f.data().splitlines() |
|
|||
240 |
|
||||
241 | def compline(type, leftlineno, leftline, rightlineno, rightline): |
|
233 | def compline(type, leftlineno, leftline, rightlineno, rightline): | |
242 | lineid = leftlineno and ("l%s" % leftlineno) or '' |
|
234 | lineid = leftlineno and ("l%s" % leftlineno) or '' | |
243 | lineid += rightlineno and ("r%s" % rightlineno) or '' |
|
235 | lineid += rightlineno and ("r%s" % rightlineno) or '' | |
@@ -275,43 +267,12 b' def compare(tmpl, ctx, path, context):' | |||||
275 | rightlineno=i + 1, |
|
267 | rightlineno=i + 1, | |
276 | rightline=rightlines[i]) |
|
268 | rightline=rightlines[i]) | |
277 |
|
269 | |||
278 | if path in ctx: |
|
|||
279 | fctx = ctx[path] |
|
|||
280 | rightrev = fctx.filerev() |
|
|||
281 | rightnode = fctx.filenode() |
|
|||
282 | rightlines = filelines(fctx) |
|
|||
283 | parents = fctx.parents() |
|
|||
284 | if not parents: |
|
|||
285 | leftrev = -1 |
|
|||
286 | leftnode = nullid |
|
|||
287 | leftlines = () |
|
|||
288 | else: |
|
|||
289 | pfctx = parents[0] |
|
|||
290 | leftrev = pfctx.filerev() |
|
|||
291 | leftnode = pfctx.filenode() |
|
|||
292 | leftlines = filelines(pfctx) |
|
|||
293 | else: |
|
|||
294 | rightrev = -1 |
|
|||
295 | rightnode = nullid |
|
|||
296 | rightlines = () |
|
|||
297 | fctx = ctx.parents()[0][path] |
|
|||
298 | leftrev = fctx.filerev() |
|
|||
299 | leftnode = fctx.filenode() |
|
|||
300 | leftlines = filelines(fctx) |
|
|||
301 |
|
||||
302 | s = difflib.SequenceMatcher(None, leftlines, rightlines) |
|
270 | s = difflib.SequenceMatcher(None, leftlines, rightlines) | |
303 | if context < 0: |
|
271 | if context < 0: | |
304 |
|
|
272 | yield tmpl('comparisonblock', lines=getblock(s.get_opcodes())) | |
305 | else: |
|
273 | else: | |
306 | blocks = (tmpl('comparisonblock', lines=getblock(oc)) |
|
274 | for oc in s.get_grouped_opcodes(n=context): | |
307 | for oc in s.get_grouped_opcodes(n=context)) |
|
275 | yield tmpl('comparisonblock', lines=getblock(oc)) | |
308 |
|
||||
309 | yield tmpl('comparison', |
|
|||
310 | leftrev=leftrev, |
|
|||
311 | leftnode=hex(leftnode), |
|
|||
312 | rightrev=rightrev, |
|
|||
313 | rightnode=hex(rightnode), |
|
|||
314 | blocks=blocks) |
|
|||
315 |
|
276 | |||
316 | def diffstatgen(ctx): |
|
277 | def diffstatgen(ctx): | |
317 | '''Generator function that provides the diffstat data.''' |
|
278 | '''Generator function that provides the diffstat data.''' |
@@ -84,16 +84,6 b' difflineminus = \'<a href="#{lineid}" id=' | |||||
84 | difflineat = '<a href="#{lineid}" id="{lineid}">{linenumber}</a> <span class="atline">{line|escape}</span>' |
|
84 | difflineat = '<a href="#{lineid}" id="{lineid}">{linenumber}</a> <span class="atline">{line|escape}</span>' | |
85 | diffline = '<a href="#{lineid}" id="{lineid}">{linenumber}</a> {line|escape}' |
|
85 | diffline = '<a href="#{lineid}" id="{lineid}">{linenumber}</a> {line|escape}' | |
86 |
|
86 | |||
87 | comparison = ' |
|
|||
88 | <table class="bigtable"> |
|
|||
89 | <thead class="header"> |
|
|||
90 | <tr> |
|
|||
91 | <th>{leftrev}:{leftnode|short}</th> |
|
|||
92 | <th>{rightrev}:{rightnode|short}</th> |
|
|||
93 | </tr> |
|
|||
94 | </thead> |
|
|||
95 | {blocks} |
|
|||
96 | </table>' |
|
|||
97 | comparisonblock =' |
|
87 | comparisonblock =' | |
98 | <tbody class="block"> |
|
88 | <tbody class="block"> | |
99 | {lines} |
|
89 | {lines} |
@@ -55,7 +55,15 b' comparison |' | |||||
55 | </div> |
|
55 | </div> | |
56 |
|
56 | |||
57 | <div class="comparison"> |
|
57 | <div class="comparison"> | |
58 | {comparison} |
|
58 | <table style="border-collapse:collapse;"> | |
|
59 | <thead class="header"> | |||
|
60 | <tr> | |||
|
61 | <th>{leftrev}:{leftnode|short}</th> | |||
|
62 | <th>{rightrev}:{rightnode|short}</th> | |||
|
63 | </tr> | |||
|
64 | </thead> | |||
|
65 | {comparison} | |||
|
66 | </table> | |||
59 | </div> |
|
67 | </div> | |
60 |
|
68 | |||
61 | </div> |
|
69 | </div> |
@@ -103,16 +103,6 b' difflineminus = \'<span style="color:#cc0' | |||||
103 | difflineat = '<span style="color:#990099;"><a class="linenr" href="#{lineid}" id="{lineid}">{linenumber}</a> {line|escape}</span>' |
|
103 | difflineat = '<span style="color:#990099;"><a class="linenr" href="#{lineid}" id="{lineid}">{linenumber}</a> {line|escape}</span>' | |
104 | diffline = '<span><a class="linenr" href="#{lineid}" id="{lineid}">{linenumber}</a> {line|escape}</span>' |
|
104 | diffline = '<span><a class="linenr" href="#{lineid}" id="{lineid}">{linenumber}</a> {line|escape}</span>' | |
105 |
|
105 | |||
106 | comparison = ' |
|
|||
107 | <table style="border-collapse:collapse;"> |
|
|||
108 | <thead class="header"> |
|
|||
109 | <tr> |
|
|||
110 | <th>{leftrev}:{leftnode|short}</th> |
|
|||
111 | <th>{rightrev}:{rightnode|short}</th> |
|
|||
112 | </tr> |
|
|||
113 | </thead> |
|
|||
114 | {blocks} |
|
|||
115 | </table>' |
|
|||
116 | comparisonblock =' |
|
106 | comparisonblock =' | |
117 | <tbody class="block"> |
|
107 | <tbody class="block"> | |
118 | {lines} |
|
108 | {lines} |
@@ -58,7 +58,15 b'' | |||||
58 | </div> |
|
58 | </div> | |
59 |
|
59 | |||
60 | <div class="comparison"> |
|
60 | <div class="comparison"> | |
61 | {comparison} |
|
61 | <table class="bigtable"> | |
|
62 | <thead class="header"> | |||
|
63 | <tr> | |||
|
64 | <th>{leftrev}:{leftnode|short}</th> | |||
|
65 | <th>{rightrev}:{rightnode|short}</th> | |||
|
66 | </tr> | |||
|
67 | </thead> | |||
|
68 | {comparison} | |||
|
69 | </table> | |||
62 | </div> |
|
70 | </div> | |
63 |
|
71 | |||
64 | {footer} |
|
72 | {footer} |
@@ -98,16 +98,6 b' difflineminus = \'<span style="color:#cc0' | |||||
98 | difflineat = '<span style="color:#990099;"><a class="linenr" href="#{lineid}" id="{lineid}">{linenumber}</a> {line|escape}</span>' |
|
98 | difflineat = '<span style="color:#990099;"><a class="linenr" href="#{lineid}" id="{lineid}">{linenumber}</a> {line|escape}</span>' | |
99 | diffline = '<span><a class="linenr" href="#{lineid}" id="{lineid}">{linenumber}</a> {line|escape}</span>' |
|
99 | diffline = '<span><a class="linenr" href="#{lineid}" id="{lineid}">{linenumber}</a> {line|escape}</span>' | |
100 |
|
100 | |||
101 | comparison = ' |
|
|||
102 | <table class="bigtable"> |
|
|||
103 | <thead class="header"> |
|
|||
104 | <tr> |
|
|||
105 | <th>{leftrev}:{leftnode|short}</th> |
|
|||
106 | <th>{rightrev}:{rightnode|short}</th> |
|
|||
107 | </tr> |
|
|||
108 | </thead> |
|
|||
109 | {blocks} |
|
|||
110 | </table>' |
|
|||
111 | comparisonblock =' |
|
101 | comparisonblock =' | |
112 | <tbody class="block"> |
|
102 | <tbody class="block"> | |
113 | {lines} |
|
103 | {lines} |
@@ -76,7 +76,15 b' files, or words in the commit message</d' | |||||
76 | <span class="legendinfo replace">replaced</span> |
|
76 | <span class="legendinfo replace">replaced</span> | |
77 | </div> |
|
77 | </div> | |
78 |
|
78 | |||
79 | {comparison} |
|
79 | <table class="bigtable"> | |
|
80 | <thead class="header"> | |||
|
81 | <tr> | |||
|
82 | <th>{leftrev}:{leftnode|short}</th> | |||
|
83 | <th>{rightrev}:{rightnode|short}</th> | |||
|
84 | </tr> | |||
|
85 | </thead> | |||
|
86 | {comparison} | |||
|
87 | </table> | |||
80 |
|
88 | |||
81 | </div> |
|
89 | </div> | |
82 | </div> |
|
90 | </div> |
@@ -83,16 +83,6 b' difflineminus = \'<a href="#{lineid}" id=' | |||||
83 | difflineat = '<a href="#{lineid}" id="{lineid}">{linenumber}</a> <span class="atline">{line|escape}</span>' |
|
83 | difflineat = '<a href="#{lineid}" id="{lineid}">{linenumber}</a> <span class="atline">{line|escape}</span>' | |
84 | diffline = '<a href="#{lineid}" id="{lineid}">{linenumber}</a> {line|escape}' |
|
84 | diffline = '<a href="#{lineid}" id="{lineid}">{linenumber}</a> {line|escape}' | |
85 |
|
85 | |||
86 | comparison = ' |
|
|||
87 | <table class="bigtable"> |
|
|||
88 | <thead class="header"> |
|
|||
89 | <tr> |
|
|||
90 | <th>{leftrev}:{leftnode|short}</th> |
|
|||
91 | <th>{rightrev}:{rightnode|short}</th> |
|
|||
92 | </tr> |
|
|||
93 | </thead> |
|
|||
94 | {blocks} |
|
|||
95 | </table>' |
|
|||
96 | comparisonblock =' |
|
86 | comparisonblock =' | |
97 | <tbody class="block"> |
|
87 | <tbody class="block"> | |
98 | {lines} |
|
88 | {lines} |
@@ -642,15 +642,14 b' comparison new file' | |||||
642 | <span class="legendinfo replace">replaced</span> |
|
642 | <span class="legendinfo replace">replaced</span> | |
643 | </div> |
|
643 | </div> | |
644 |
|
644 | |||
645 |
|
||||
646 | <table class="bigtable"> |
|
645 | <table class="bigtable"> | |
647 | <thead class="header"> |
|
646 | <thead class="header"> | |
648 | <tr> |
|
647 | <tr> | |
649 | <th>-1:000000000000</th> |
|
648 | <th>-1:000000000000</th> | |
650 | <th>0:b789fdd96dc2</th> |
|
649 | <th>0:b789fdd96dc2</th> | |
651 | </tr> |
|
650 | </tr> | |
652 | </thead> |
|
651 | </thead> | |
653 |
|
652 | |||
654 | <tbody class="block"> |
|
653 | <tbody class="block"> | |
655 |
|
654 | |||
656 | <tr> |
|
655 | <tr> | |
@@ -765,15 +764,14 b' comparison existing file' | |||||
765 | <span class="legendinfo replace">replaced</span> |
|
764 | <span class="legendinfo replace">replaced</span> | |
766 | </div> |
|
765 | </div> | |
767 |
|
766 | |||
768 |
|
||||
769 | <table class="bigtable"> |
|
767 | <table class="bigtable"> | |
770 | <thead class="header"> |
|
768 | <thead class="header"> | |
771 | <tr> |
|
769 | <tr> | |
772 | <th>0:b789fdd96dc2</th> |
|
770 | <th>0:b789fdd96dc2</th> | |
773 | <th>1:a80d06849b33</th> |
|
771 | <th>1:a80d06849b33</th> | |
774 | </tr> |
|
772 | </tr> | |
775 | </thead> |
|
773 | </thead> | |
776 |
|
774 | |||
777 | <tbody class="block"> |
|
775 | <tbody class="block"> | |
778 |
|
776 | |||
779 | <tr> |
|
777 | <tr> | |
@@ -890,15 +888,14 b' comparison removed file' | |||||
890 | <span class="legendinfo replace">replaced</span> |
|
888 | <span class="legendinfo replace">replaced</span> | |
891 | </div> |
|
889 | </div> | |
892 |
|
890 | |||
893 |
|
||||
894 | <table class="bigtable"> |
|
891 | <table class="bigtable"> | |
895 | <thead class="header"> |
|
892 | <thead class="header"> | |
896 | <tr> |
|
893 | <tr> | |
897 | <th>1:a80d06849b33</th> |
|
894 | <th>1:a80d06849b33</th> | |
898 | <th>-1:000000000000</th> |
|
895 | <th>-1:000000000000</th> | |
899 | </tr> |
|
896 | </tr> | |
900 | </thead> |
|
897 | </thead> | |
901 |
|
898 | |||
902 | <tbody class="block"> |
|
899 | <tbody class="block"> | |
903 |
|
900 | |||
904 | <tr> |
|
901 | <tr> |
General Comments 0
You need to be logged in to leave comments.
Login now