Show More
@@ -405,23 +405,33 b' def dodiff(fp, ui, repo, node1, node2, f' | |||
|
405 | 405 | diffopts = ui.diffopts() |
|
406 | 406 | showfunc = opts.get('show_function') or diffopts['showfunc'] |
|
407 | 407 | ignorews = opts.get('ignore_all_space') or diffopts['ignorews'] |
|
408 | ignorewsamount = opts.get('ignore_space_change') or \ | |
|
409 | diffopts['ignorewsamount'] | |
|
410 | ignoreblanklines = opts.get('ignore_blank_lines') or \ | |
|
411 | diffopts['ignoreblanklines'] | |
|
408 | 412 | for f in modified: |
|
409 | 413 | to = None |
|
410 | 414 | if f in mmap: |
|
411 | 415 | to = repo.file(f).read(mmap[f]) |
|
412 | 416 | tn = read(f) |
|
413 | 417 | fp.write(mdiff.unidiff(to, date1, tn, date2(f), f, r, text=text, |
|
414 |
showfunc=showfunc, ignorews=ignorews |
|
|
418 | showfunc=showfunc, ignorews=ignorews, | |
|
419 | ignorewsamount=ignorewsamount, | |
|
420 | ignoreblanklines=ignoreblanklines)) | |
|
415 | 421 | for f in added: |
|
416 | 422 | to = None |
|
417 | 423 | tn = read(f) |
|
418 | 424 | fp.write(mdiff.unidiff(to, date1, tn, date2(f), f, r, text=text, |
|
419 |
showfunc=showfunc, ignorews=ignorews |
|
|
425 | showfunc=showfunc, ignorews=ignorews, | |
|
426 | ignorewsamount=ignorewsamount, | |
|
427 | ignoreblanklines=ignoreblanklines)) | |
|
420 | 428 | for f in removed: |
|
421 | 429 | to = repo.file(f).read(mmap[f]) |
|
422 | 430 | tn = None |
|
423 | 431 | fp.write(mdiff.unidiff(to, date1, tn, date2(f), f, r, text=text, |
|
424 |
showfunc=showfunc, ignorews=ignorews |
|
|
432 | showfunc=showfunc, ignorews=ignorews, | |
|
433 | ignorewsamount=ignorewsamount, | |
|
434 | ignoreblanklines=ignoreblanklines)) | |
|
425 | 435 | |
|
426 | 436 | def trimuser(ui, name, rev, revcache): |
|
427 | 437 | """trim the name of the user who committed a change""" |
@@ -3018,6 +3028,10 b' table = {' | |||
|
3018 | 3028 | _('show which function each change is in')), |
|
3019 | 3029 | ('w', 'ignore-all-space', None, |
|
3020 | 3030 | _('ignore white space when comparing lines')), |
|
3031 | ('b', 'ignore-space-change', None, | |
|
3032 | _('ignore changes in the amount of white space')), | |
|
3033 | ('B', 'ignore-blank-lines', None, | |
|
3034 | _('ignore changes whose lines are all blank')), | |
|
3021 | 3035 | ('I', 'include', [], _('include names matching the given patterns')), |
|
3022 | 3036 | ('X', 'exclude', [], _('exclude names matching the given patterns'))], |
|
3023 | 3037 | _('hg diff [-a] [-I] [-X] [-r REV1 [-r REV2]] [FILE]...')), |
@@ -133,21 +133,29 b' class hgweb(object):' | |||
|
133 | 133 | diffopts = self.repo.ui.diffopts() |
|
134 | 134 | showfunc = diffopts['showfunc'] |
|
135 | 135 | ignorews = diffopts['ignorews'] |
|
136 | ignorewsamount = diffopts['ignorewsamount'] | |
|
137 | ignoreblanklines = diffopts['ignoreblanklines'] | |
|
136 | 138 | for f in modified: |
|
137 | 139 | to = r.file(f).read(mmap1[f]) |
|
138 | 140 | tn = r.file(f).read(mmap2[f]) |
|
139 | 141 | yield diffblock(mdiff.unidiff(to, date1, tn, date2, f, |
|
140 |
showfunc=showfunc, ignorews=ignorews |
|
|
142 | showfunc=showfunc, ignorews=ignorews, | |
|
143 | ignorewsamount=ignorewsamount, | |
|
144 | ignoreblanklines=ignoreblanklines), f, tn) | |
|
141 | 145 | for f in added: |
|
142 | 146 | to = None |
|
143 | 147 | tn = r.file(f).read(mmap2[f]) |
|
144 | 148 | yield diffblock(mdiff.unidiff(to, date1, tn, date2, f, |
|
145 |
showfunc=showfunc, ignorews=ignorews |
|
|
149 | showfunc=showfunc, ignorews=ignorews, | |
|
150 | ignorewsamount=ignorewsamount, | |
|
151 | ignoreblanklines=ignoreblanklines), f, tn) | |
|
146 | 152 | for f in removed: |
|
147 | 153 | to = r.file(f).read(mmap1[f]) |
|
148 | 154 | tn = None |
|
149 | 155 | yield diffblock(mdiff.unidiff(to, date1, tn, date2, f, |
|
150 |
showfunc=showfunc, ignorews=ignorews |
|
|
156 | showfunc=showfunc, ignorews=ignorews, | |
|
157 | ignorewsamount=ignorewsamount, | |
|
158 | ignoreblanklines=ignoreblanklines), f, tn) | |
|
151 | 159 | |
|
152 | 160 | def changelog(self, pos): |
|
153 | 161 | def changenav(**map): |
@@ -20,7 +20,8 b' def splitnewlines(text):' | |||
|
20 | 20 | return lines |
|
21 | 21 | |
|
22 | 22 | def unidiff(a, ad, b, bd, fn, r=None, text=False, |
|
23 |
showfunc=False, ignorews=False |
|
|
23 | showfunc=False, ignorews=False, ignorewsamount=False, | |
|
24 | ignoreblanklines=False): | |
|
24 | 25 | |
|
25 | 26 | if not a and not b: return "" |
|
26 | 27 | epoch = util.datestr((0, 0)) |
@@ -49,7 +50,9 b' def unidiff(a, ad, b, bd, fn, r=None, te' | |||
|
49 | 50 | al = splitnewlines(a) |
|
50 | 51 | bl = splitnewlines(b) |
|
51 | 52 | l = list(bunidiff(a, b, al, bl, "a/" + fn, "b/" + fn, |
|
52 |
showfunc=showfunc, ignorews=ignorews |
|
|
53 | showfunc=showfunc, ignorews=ignorews, | |
|
54 | ignorewsamount=ignorewsamount, | |
|
55 | ignoreblanklines=ignoreblanklines)) | |
|
53 | 56 | if not l: return "" |
|
54 | 57 | # difflib uses a space, rather than a tab |
|
55 | 58 | l[0] = "%s\t%s\n" % (l[0][:-2], ad) |
@@ -72,8 +75,10 b' def unidiff(a, ad, b, bd, fn, r=None, te' | |||
|
72 | 75 | # context is the number of context lines |
|
73 | 76 | # showfunc enables diff -p output |
|
74 | 77 | # ignorews ignores all whitespace changes in the diff |
|
78 | # ignorewsamount ignores changes in the amount of whitespace | |
|
79 | # ignoreblanklines ignores changes whose lines are all blank | |
|
75 | 80 | def bunidiff(t1, t2, l1, l2, header1, header2, context=3, showfunc=False, |
|
76 | ignorews=False): | |
|
81 | ignorews=False, ignorewsamount=False, ignoreblanklines=False): | |
|
77 | 82 | def contextend(l, len): |
|
78 | 83 | ret = l + context |
|
79 | 84 | if ret > len: |
@@ -116,6 +121,11 b' def bunidiff(t1, t2, l1, l2, header1, he' | |||
|
116 | 121 | |
|
117 | 122 | if showfunc: |
|
118 | 123 | funcre = re.compile('\w') |
|
124 | if ignorewsamount: | |
|
125 | wsamountre = re.compile('[ \t]+') | |
|
126 | wsappendedre = re.compile(' \n') | |
|
127 | if ignoreblanklines: | |
|
128 | wsblanklinesre = re.compile('\n') | |
|
119 | 129 | if ignorews: |
|
120 | 130 | wsre = re.compile('[ \t]') |
|
121 | 131 | |
@@ -149,6 +159,20 b' def bunidiff(t1, t2, l1, l2, header1, he' | |||
|
149 | 159 | if not old and not new: |
|
150 | 160 | continue |
|
151 | 161 | |
|
162 | if ignoreblanklines: | |
|
163 | wsold = wsblanklinesre.sub('', "".join(old)) | |
|
164 | wsnew = wsblanklinesre.sub('', "".join(new)) | |
|
165 | if wsold == wsnew: | |
|
166 | continue | |
|
167 | ||
|
168 | if ignorewsamount: | |
|
169 | wsold = wsamountre.sub(' ', "".join(old)) | |
|
170 | wsold = wsappendedre.sub('\n', wsold) | |
|
171 | wsnew = wsamountre.sub(' ', "".join(new)) | |
|
172 | wsnew = wsappendedre.sub('\n', wsnew) | |
|
173 | if wsold == wsnew: | |
|
174 | continue | |
|
175 | ||
|
152 | 176 | if ignorews: |
|
153 | 177 | wsold = wsre.sub('', "".join(old)) |
|
154 | 178 | wsnew = wsre.sub('', "".join(new)) |
@@ -172,7 +172,8 b' class ui(object):' | |||
|
172 | 172 | def diffopts(self): |
|
173 | 173 | if self.diffcache: |
|
174 | 174 | return self.diffcache |
|
175 |
result = {'showfunc': True, 'ignorews': False |
|
|
175 | result = {'showfunc': True, 'ignorews': False, | |
|
176 | 'ignorewsamount': False, 'ignoreblanklines': False} | |
|
176 | 177 | for key, value in self.configitems("diff"): |
|
177 | 178 | if value: |
|
178 | 179 | result[key.lower()] = (value.lower() == 'true') |
@@ -173,12 +173,14 b' diff repository (or selected files)' | |||
|
173 | 173 | |
|
174 | 174 | options: |
|
175 | 175 | |
|
176 | -r --rev revision | |
|
177 | -a --text treat all files as text | |
|
178 | -p --show-function show which function each change is in | |
|
179 | -w --ignore-all-space ignore white space when comparing lines | |
|
180 | -I --include include names matching the given patterns | |
|
181 | -X --exclude exclude names matching the given patterns | |
|
176 | -r --rev revision | |
|
177 | -a --text treat all files as text | |
|
178 | -p --show-function show which function each change is in | |
|
179 | -w --ignore-all-space ignore white space when comparing lines | |
|
180 | -b --ignore-space-change ignore changes in the amount of white space | |
|
181 | -B --ignore-blank-lines ignore changes whose lines are all blank | |
|
182 | -I --include include names matching the given patterns | |
|
183 | -X --exclude exclude names matching the given patterns | |
|
182 | 184 | hg status [OPTION]... [FILE]... |
|
183 | 185 | |
|
184 | 186 | show changed files in the working directory |
General Comments 0
You need to be logged in to leave comments.
Login now