Show More
@@ -65,7 +65,7 b' static inline uint32_t rol32(uint32_t wo' | |||
|
65 | 65 | |
|
66 | 66 | int splitlines(const char *a, int len, struct line **lr) |
|
67 | 67 | { |
|
68 | int h, i; | |
|
68 | int g, h, i; | |
|
69 | 69 | const char *p, *b = a; |
|
70 | 70 | struct line *l; |
|
71 | 71 | |
@@ -82,7 +82,16 b' int splitlines(const char *a, int len, s' | |||
|
82 | 82 | /* build the line array and calculate hashes */ |
|
83 | 83 | h = 0; |
|
84 | 84 | for (p = a; p < a + len; p++) { |
|
85 | h = *p + rol32(h, 7); /* a simple hash from GNU diff */ | |
|
85 | /* | |
|
86 | * a simple hash from GNU diff, with better collision | |
|
87 | * resistance from hashpjw. this slows down common | |
|
88 | * case by 10%, but speeds up worst case by 100x. | |
|
89 | */ | |
|
90 | h = *p + rol32(h, 7); | |
|
91 | if ((g = h & 0xf0000000)) { | |
|
92 | h ^= g >> 24; | |
|
93 | h ^= g; | |
|
94 | } | |
|
86 | 95 | if (*p == '\n' || p == a + len - 1) { |
|
87 | 96 | l->len = p - b + 1; |
|
88 | 97 | l->h = h * l->len; |
@@ -231,7 +231,7 b' def revrange(ui, repo, revs):' | |||
|
231 | 231 | """Yield revision as strings from a list of revision specifications.""" |
|
232 | 232 | seen = {} |
|
233 | 233 | for spec in revs: |
|
234 |
if spec |
|
|
234 | if revrangesep in spec: | |
|
235 | 235 | start, end = spec.split(revrangesep, 1) |
|
236 | 236 | start = revfix(repo, start, 0) |
|
237 | 237 | end = revfix(repo, end, repo.changelog.count() - 1) |
@@ -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""" |
@@ -2742,7 +2752,7 b' def tag(ui, repo, name, rev_=None, **opt' | |||
|
2742 | 2752 | |
|
2743 | 2753 | disallowed = (revrangesep, '\r', '\n') |
|
2744 | 2754 | for c in disallowed: |
|
2745 |
if name |
|
|
2755 | if c in name: | |
|
2746 | 2756 | raise util.Abort(_("%s cannot be used in a tag name") % repr(c)) |
|
2747 | 2757 | |
|
2748 | 2758 | repo.hook('pretag', throw=True, node=r, tag=name, |
@@ -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]...')), |
@@ -34,14 +34,14 b' class filelog(revlog):' | |||
|
34 | 34 | t = self.revision(node) |
|
35 | 35 | if not t.startswith('\1\n'): |
|
36 | 36 | return t |
|
37 |
s = t. |
|
|
37 | s = t.index('\1\n', 2) | |
|
38 | 38 | return t[s+2:] |
|
39 | 39 | |
|
40 | 40 | def readmeta(self, node): |
|
41 | 41 | t = self.revision(node) |
|
42 | 42 | if not t.startswith('\1\n'): |
|
43 | 43 | return {} |
|
44 |
s = t. |
|
|
44 | s = t.index('\1\n', 2) | |
|
45 | 45 | mt = t[2:s] |
|
46 | 46 | m = {} |
|
47 | 47 | for l in mt.splitlines(): |
@@ -61,8 +61,7 b' def repository(ui, path=None, create=0):' | |||
|
61 | 61 | if not path: path = '' |
|
62 | 62 | scheme = path |
|
63 | 63 | if scheme: |
|
64 |
c = scheme. |
|
|
65 | scheme = c >= 0 and scheme[:c] | |
|
64 | scheme = scheme.split(":", 1)[0] | |
|
66 | 65 | ctor = schemes.get(scheme) or schemes['file'] |
|
67 | 66 | if create: |
|
68 | 67 | try: |
@@ -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): |
@@ -462,7 +470,7 b' class hgweb(object):' | |||
|
462 | 470 | continue |
|
463 | 471 | remain = f[l:] |
|
464 | 472 | if "/" in remain: |
|
465 |
short = remain[:remain. |
|
|
473 | short = remain[:remain.index("/") + 1] # bleah | |
|
466 | 474 | files[short] = (f, None) |
|
467 | 475 | else: |
|
468 | 476 | short = os.path.basename(remain) |
@@ -127,6 +127,11 b' class _hgwebhandler(object, BaseHTTPServ' | |||
|
127 | 127 | if h[0].lower() == 'content-length': |
|
128 | 128 | should_close = False |
|
129 | 129 | self.length = int(h[1]) |
|
130 | # The value of the Connection header is a list of case-insensitive | |
|
131 | # tokens separated by commas and optional whitespace. | |
|
132 | if 'close' in [token.strip().lower() for token in | |
|
133 | self.headers.get('connection', '').split(',')]: | |
|
134 | should_close = True | |
|
130 | 135 | if should_close: |
|
131 | 136 | self.send_header('Connection', 'close') |
|
132 | 137 | self.close_connection = should_close |
@@ -74,8 +74,8 b' class localrepository(object):' | |||
|
74 | 74 | self.transhandle = None |
|
75 | 75 | |
|
76 | 76 | if create: |
|
77 |
|
|
|
78 |
|
|
|
77 | if not os.path.exists(path): | |
|
78 | os.mkdir(path) | |
|
79 | 79 | os.mkdir(self.path) |
|
80 | 80 | os.mkdir(self.join("data")) |
|
81 | 81 | |
@@ -101,9 +101,13 b' class localrepository(object):' | |||
|
101 | 101 | try: |
|
102 | 102 | obj = __import__(modname) |
|
103 | 103 | except ImportError: |
|
104 | raise util.Abort(_('%s hook is invalid ' | |
|
105 | '(import of "%s" failed)') % | |
|
106 | (hname, modname)) | |
|
104 | try: | |
|
105 | # extensions are loaded with hgext_ prefix | |
|
106 | obj = __import__("hgext_%s" % modname) | |
|
107 | except ImportError: | |
|
108 | raise util.Abort(_('%s hook is invalid ' | |
|
109 | '(import of "%s" failed)') % | |
|
110 | (hname, modname)) | |
|
107 | 111 | try: |
|
108 | 112 | for p in funcname.split('.')[1:]: |
|
109 | 113 | obj = getattr(obj, p) |
@@ -85,14 +85,14 b' class lock(object):' | |||
|
85 | 85 | # see if locker is alive. if locker is on this machine but |
|
86 | 86 | # not alive, we can safely break lock. |
|
87 | 87 | locker = util.readlock(self.f) |
|
88 | c = locker.find(':') | |
|
89 | if c == -1: | |
|
88 | try: | |
|
89 | host, pid = locker.split(":", 1) | |
|
90 | except ValueError: | |
|
90 | 91 | return locker |
|
91 | host = locker[:c] | |
|
92 | 92 | if host != self.host: |
|
93 | 93 | return locker |
|
94 | 94 | try: |
|
95 |
pid = int( |
|
|
95 | pid = int(pid) | |
|
96 | 96 | except: |
|
97 | 97 | return locker |
|
98 | 98 | if util.testpid(pid): |
@@ -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)) |
@@ -76,7 +76,7 b' class ui(object):' | |||
|
76 | 76 | if root is None: |
|
77 | 77 | root = os.path.expanduser('~') |
|
78 | 78 | for name, path in self.configitems("paths"): |
|
79 |
if path and |
|
|
79 | if path and "://" not in path and not os.path.isabs(path): | |
|
80 | 80 | self.cdata.set("paths", name, os.path.join(root, path)) |
|
81 | 81 | |
|
82 | 82 | def setconfig(self, section, name, val): |
@@ -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') |
@@ -208,7 +209,7 b' class ui(object):' | |||
|
208 | 209 | |
|
209 | 210 | def expandpath(self, loc, default=None): |
|
210 | 211 | """Return repository location relative to cwd or from [paths]""" |
|
211 |
if |
|
|
212 | if "://" in loc or os.path.exists(loc): | |
|
212 | 213 | return loc |
|
213 | 214 | |
|
214 | 215 | path = self.config("paths", loc) |
@@ -620,7 +620,7 b' else:' | |||
|
620 | 620 | def parse_patch_output(output_line): |
|
621 | 621 | """parses the output produced by patch and returns the file name""" |
|
622 | 622 | pf = output_line[14:] |
|
623 |
if pf.startswith("'") and pf.endswith("'") and |
|
|
623 | if pf.startswith("'") and pf.endswith("'") and " " in pf: | |
|
624 | 624 | pf = pf[1:-1] # Remove the quotes |
|
625 | 625 | return pf |
|
626 | 626 |
@@ -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