##// END OF EJS Templates
merge with crew
Benoit Boissinot -
r2584:1f470311 merge default
parent child Browse files
Show More
@@ -65,7 +65,7 b' static inline uint32_t rol32(uint32_t wo'
65
65
66 int splitlines(const char *a, int len, struct line **lr)
66 int splitlines(const char *a, int len, struct line **lr)
67 {
67 {
68 int h, i;
68 int g, h, i;
69 const char *p, *b = a;
69 const char *p, *b = a;
70 struct line *l;
70 struct line *l;
71
71
@@ -82,7 +82,16 b' int splitlines(const char *a, int len, s'
82 /* build the line array and calculate hashes */
82 /* build the line array and calculate hashes */
83 h = 0;
83 h = 0;
84 for (p = a; p < a + len; p++) {
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 if (*p == '\n' || p == a + len - 1) {
95 if (*p == '\n' || p == a + len - 1) {
87 l->len = p - b + 1;
96 l->len = p - b + 1;
88 l->h = h * l->len;
97 l->h = h * l->len;
@@ -231,7 +231,7 b' def revrange(ui, repo, revs):'
231 """Yield revision as strings from a list of revision specifications."""
231 """Yield revision as strings from a list of revision specifications."""
232 seen = {}
232 seen = {}
233 for spec in revs:
233 for spec in revs:
234 if spec.find(revrangesep) >= 0:
234 if revrangesep in spec:
235 start, end = spec.split(revrangesep, 1)
235 start, end = spec.split(revrangesep, 1)
236 start = revfix(repo, start, 0)
236 start = revfix(repo, start, 0)
237 end = revfix(repo, end, repo.changelog.count() - 1)
237 end = revfix(repo, end, repo.changelog.count() - 1)
@@ -405,23 +405,33 b' def dodiff(fp, ui, repo, node1, node2, f'
405 diffopts = ui.diffopts()
405 diffopts = ui.diffopts()
406 showfunc = opts.get('show_function') or diffopts['showfunc']
406 showfunc = opts.get('show_function') or diffopts['showfunc']
407 ignorews = opts.get('ignore_all_space') or diffopts['ignorews']
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 for f in modified:
412 for f in modified:
409 to = None
413 to = None
410 if f in mmap:
414 if f in mmap:
411 to = repo.file(f).read(mmap[f])
415 to = repo.file(f).read(mmap[f])
412 tn = read(f)
416 tn = read(f)
413 fp.write(mdiff.unidiff(to, date1, tn, date2(f), f, r, text=text,
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 for f in added:
421 for f in added:
416 to = None
422 to = None
417 tn = read(f)
423 tn = read(f)
418 fp.write(mdiff.unidiff(to, date1, tn, date2(f), f, r, text=text,
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 for f in removed:
428 for f in removed:
421 to = repo.file(f).read(mmap[f])
429 to = repo.file(f).read(mmap[f])
422 tn = None
430 tn = None
423 fp.write(mdiff.unidiff(to, date1, tn, date2(f), f, r, text=text,
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 def trimuser(ui, name, rev, revcache):
436 def trimuser(ui, name, rev, revcache):
427 """trim the name of the user who committed a change"""
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 disallowed = (revrangesep, '\r', '\n')
2753 disallowed = (revrangesep, '\r', '\n')
2744 for c in disallowed:
2754 for c in disallowed:
2745 if name.find(c) >= 0:
2755 if c in name:
2746 raise util.Abort(_("%s cannot be used in a tag name") % repr(c))
2756 raise util.Abort(_("%s cannot be used in a tag name") % repr(c))
2747
2757
2748 repo.hook('pretag', throw=True, node=r, tag=name,
2758 repo.hook('pretag', throw=True, node=r, tag=name,
@@ -3018,6 +3028,10 b' table = {'
3018 _('show which function each change is in')),
3028 _('show which function each change is in')),
3019 ('w', 'ignore-all-space', None,
3029 ('w', 'ignore-all-space', None,
3020 _('ignore white space when comparing lines')),
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 ('I', 'include', [], _('include names matching the given patterns')),
3035 ('I', 'include', [], _('include names matching the given patterns')),
3022 ('X', 'exclude', [], _('exclude names matching the given patterns'))],
3036 ('X', 'exclude', [], _('exclude names matching the given patterns'))],
3023 _('hg diff [-a] [-I] [-X] [-r REV1 [-r REV2]] [FILE]...')),
3037 _('hg diff [-a] [-I] [-X] [-r REV1 [-r REV2]] [FILE]...')),
@@ -34,14 +34,14 b' class filelog(revlog):'
34 t = self.revision(node)
34 t = self.revision(node)
35 if not t.startswith('\1\n'):
35 if not t.startswith('\1\n'):
36 return t
36 return t
37 s = t.find('\1\n', 2)
37 s = t.index('\1\n', 2)
38 return t[s+2:]
38 return t[s+2:]
39
39
40 def readmeta(self, node):
40 def readmeta(self, node):
41 t = self.revision(node)
41 t = self.revision(node)
42 if not t.startswith('\1\n'):
42 if not t.startswith('\1\n'):
43 return {}
43 return {}
44 s = t.find('\1\n', 2)
44 s = t.index('\1\n', 2)
45 mt = t[2:s]
45 mt = t[2:s]
46 m = {}
46 m = {}
47 for l in mt.splitlines():
47 for l in mt.splitlines():
@@ -61,8 +61,7 b' def repository(ui, path=None, create=0):'
61 if not path: path = ''
61 if not path: path = ''
62 scheme = path
62 scheme = path
63 if scheme:
63 if scheme:
64 c = scheme.find(':')
64 scheme = scheme.split(":", 1)[0]
65 scheme = c >= 0 and scheme[:c]
66 ctor = schemes.get(scheme) or schemes['file']
65 ctor = schemes.get(scheme) or schemes['file']
67 if create:
66 if create:
68 try:
67 try:
@@ -133,21 +133,29 b' class hgweb(object):'
133 diffopts = self.repo.ui.diffopts()
133 diffopts = self.repo.ui.diffopts()
134 showfunc = diffopts['showfunc']
134 showfunc = diffopts['showfunc']
135 ignorews = diffopts['ignorews']
135 ignorews = diffopts['ignorews']
136 ignorewsamount = diffopts['ignorewsamount']
137 ignoreblanklines = diffopts['ignoreblanklines']
136 for f in modified:
138 for f in modified:
137 to = r.file(f).read(mmap1[f])
139 to = r.file(f).read(mmap1[f])
138 tn = r.file(f).read(mmap2[f])
140 tn = r.file(f).read(mmap2[f])
139 yield diffblock(mdiff.unidiff(to, date1, tn, date2, f,
141 yield diffblock(mdiff.unidiff(to, date1, tn, date2, f,
140 showfunc=showfunc, ignorews=ignorews), f, tn)
142 showfunc=showfunc, ignorews=ignorews,
143 ignorewsamount=ignorewsamount,
144 ignoreblanklines=ignoreblanklines), f, tn)
141 for f in added:
145 for f in added:
142 to = None
146 to = None
143 tn = r.file(f).read(mmap2[f])
147 tn = r.file(f).read(mmap2[f])
144 yield diffblock(mdiff.unidiff(to, date1, tn, date2, f,
148 yield diffblock(mdiff.unidiff(to, date1, tn, date2, f,
145 showfunc=showfunc, ignorews=ignorews), f, tn)
149 showfunc=showfunc, ignorews=ignorews,
150 ignorewsamount=ignorewsamount,
151 ignoreblanklines=ignoreblanklines), f, tn)
146 for f in removed:
152 for f in removed:
147 to = r.file(f).read(mmap1[f])
153 to = r.file(f).read(mmap1[f])
148 tn = None
154 tn = None
149 yield diffblock(mdiff.unidiff(to, date1, tn, date2, f,
155 yield diffblock(mdiff.unidiff(to, date1, tn, date2, f,
150 showfunc=showfunc, ignorews=ignorews), f, tn)
156 showfunc=showfunc, ignorews=ignorews,
157 ignorewsamount=ignorewsamount,
158 ignoreblanklines=ignoreblanklines), f, tn)
151
159
152 def changelog(self, pos):
160 def changelog(self, pos):
153 def changenav(**map):
161 def changenav(**map):
@@ -462,7 +470,7 b' class hgweb(object):'
462 continue
470 continue
463 remain = f[l:]
471 remain = f[l:]
464 if "/" in remain:
472 if "/" in remain:
465 short = remain[:remain.find("/") + 1] # bleah
473 short = remain[:remain.index("/") + 1] # bleah
466 files[short] = (f, None)
474 files[short] = (f, None)
467 else:
475 else:
468 short = os.path.basename(remain)
476 short = os.path.basename(remain)
@@ -127,6 +127,11 b' class _hgwebhandler(object, BaseHTTPServ'
127 if h[0].lower() == 'content-length':
127 if h[0].lower() == 'content-length':
128 should_close = False
128 should_close = False
129 self.length = int(h[1])
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 if should_close:
135 if should_close:
131 self.send_header('Connection', 'close')
136 self.send_header('Connection', 'close')
132 self.close_connection = should_close
137 self.close_connection = should_close
@@ -74,8 +74,8 b' class localrepository(object):'
74 self.transhandle = None
74 self.transhandle = None
75
75
76 if create:
76 if create:
77 if not os.path.exists(path):
77 if not os.path.exists(path):
78 os.mkdir(path)
78 os.mkdir(path)
79 os.mkdir(self.path)
79 os.mkdir(self.path)
80 os.mkdir(self.join("data"))
80 os.mkdir(self.join("data"))
81
81
@@ -101,9 +101,13 b' class localrepository(object):'
101 try:
101 try:
102 obj = __import__(modname)
102 obj = __import__(modname)
103 except ImportError:
103 except ImportError:
104 raise util.Abort(_('%s hook is invalid '
104 try:
105 '(import of "%s" failed)') %
105 # extensions are loaded with hgext_ prefix
106 (hname, modname))
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 try:
111 try:
108 for p in funcname.split('.')[1:]:
112 for p in funcname.split('.')[1:]:
109 obj = getattr(obj, p)
113 obj = getattr(obj, p)
@@ -85,14 +85,14 b' class lock(object):'
85 # see if locker is alive. if locker is on this machine but
85 # see if locker is alive. if locker is on this machine but
86 # not alive, we can safely break lock.
86 # not alive, we can safely break lock.
87 locker = util.readlock(self.f)
87 locker = util.readlock(self.f)
88 c = locker.find(':')
88 try:
89 if c == -1:
89 host, pid = locker.split(":", 1)
90 except ValueError:
90 return locker
91 return locker
91 host = locker[:c]
92 if host != self.host:
92 if host != self.host:
93 return locker
93 return locker
94 try:
94 try:
95 pid = int(locker[c+1:])
95 pid = int(pid)
96 except:
96 except:
97 return locker
97 return locker
98 if util.testpid(pid):
98 if util.testpid(pid):
@@ -20,7 +20,8 b' def splitnewlines(text):'
20 return lines
20 return lines
21
21
22 def unidiff(a, ad, b, bd, fn, r=None, text=False,
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 if not a and not b: return ""
26 if not a and not b: return ""
26 epoch = util.datestr((0, 0))
27 epoch = util.datestr((0, 0))
@@ -49,7 +50,9 b' def unidiff(a, ad, b, bd, fn, r=None, te'
49 al = splitnewlines(a)
50 al = splitnewlines(a)
50 bl = splitnewlines(b)
51 bl = splitnewlines(b)
51 l = list(bunidiff(a, b, al, bl, "a/" + fn, "b/" + fn,
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 if not l: return ""
56 if not l: return ""
54 # difflib uses a space, rather than a tab
57 # difflib uses a space, rather than a tab
55 l[0] = "%s\t%s\n" % (l[0][:-2], ad)
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 # context is the number of context lines
75 # context is the number of context lines
73 # showfunc enables diff -p output
76 # showfunc enables diff -p output
74 # ignorews ignores all whitespace changes in the diff
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 def bunidiff(t1, t2, l1, l2, header1, header2, context=3, showfunc=False,
80 def bunidiff(t1, t2, l1, l2, header1, header2, context=3, showfunc=False,
76 ignorews=False):
81 ignorews=False, ignorewsamount=False, ignoreblanklines=False):
77 def contextend(l, len):
82 def contextend(l, len):
78 ret = l + context
83 ret = l + context
79 if ret > len:
84 if ret > len:
@@ -116,6 +121,11 b' def bunidiff(t1, t2, l1, l2, header1, he'
116
121
117 if showfunc:
122 if showfunc:
118 funcre = re.compile('\w')
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 if ignorews:
129 if ignorews:
120 wsre = re.compile('[ \t]')
130 wsre = re.compile('[ \t]')
121
131
@@ -149,6 +159,20 b' def bunidiff(t1, t2, l1, l2, header1, he'
149 if not old and not new:
159 if not old and not new:
150 continue
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 if ignorews:
176 if ignorews:
153 wsold = wsre.sub('', "".join(old))
177 wsold = wsre.sub('', "".join(old))
154 wsnew = wsre.sub('', "".join(new))
178 wsnew = wsre.sub('', "".join(new))
@@ -76,7 +76,7 b' class ui(object):'
76 if root is None:
76 if root is None:
77 root = os.path.expanduser('~')
77 root = os.path.expanduser('~')
78 for name, path in self.configitems("paths"):
78 for name, path in self.configitems("paths"):
79 if path and path.find("://") == -1 and not os.path.isabs(path):
79 if path and "://" not in path and not os.path.isabs(path):
80 self.cdata.set("paths", name, os.path.join(root, path))
80 self.cdata.set("paths", name, os.path.join(root, path))
81
81
82 def setconfig(self, section, name, val):
82 def setconfig(self, section, name, val):
@@ -172,7 +172,8 b' class ui(object):'
172 def diffopts(self):
172 def diffopts(self):
173 if self.diffcache:
173 if self.diffcache:
174 return self.diffcache
174 return self.diffcache
175 result = {'showfunc': True, 'ignorews': False}
175 result = {'showfunc': True, 'ignorews': False,
176 'ignorewsamount': False, 'ignoreblanklines': False}
176 for key, value in self.configitems("diff"):
177 for key, value in self.configitems("diff"):
177 if value:
178 if value:
178 result[key.lower()] = (value.lower() == 'true')
179 result[key.lower()] = (value.lower() == 'true')
@@ -208,7 +209,7 b' class ui(object):'
208
209
209 def expandpath(self, loc, default=None):
210 def expandpath(self, loc, default=None):
210 """Return repository location relative to cwd or from [paths]"""
211 """Return repository location relative to cwd or from [paths]"""
211 if loc.find("://") != -1 or os.path.exists(loc):
212 if "://" in loc or os.path.exists(loc):
212 return loc
213 return loc
213
214
214 path = self.config("paths", loc)
215 path = self.config("paths", loc)
@@ -620,7 +620,7 b' else:'
620 def parse_patch_output(output_line):
620 def parse_patch_output(output_line):
621 """parses the output produced by patch and returns the file name"""
621 """parses the output produced by patch and returns the file name"""
622 pf = output_line[14:]
622 pf = output_line[14:]
623 if pf.startswith("'") and pf.endswith("'") and pf.find(" ") >= 0:
623 if pf.startswith("'") and pf.endswith("'") and " " in pf:
624 pf = pf[1:-1] # Remove the quotes
624 pf = pf[1:-1] # Remove the quotes
625 return pf
625 return pf
626
626
@@ -173,12 +173,14 b' diff repository (or selected files)'
173
173
174 options:
174 options:
175
175
176 -r --rev revision
176 -r --rev revision
177 -a --text treat all files as text
177 -a --text treat all files as text
178 -p --show-function show which function each change is in
178 -p --show-function show which function each change is in
179 -w --ignore-all-space ignore white space when comparing lines
179 -w --ignore-all-space ignore white space when comparing lines
180 -I --include include names matching the given patterns
180 -b --ignore-space-change ignore changes in the amount of white space
181 -X --exclude exclude names matching the given patterns
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 hg status [OPTION]... [FILE]...
184 hg status [OPTION]... [FILE]...
183
185
184 show changed files in the working directory
186 show changed files in the working directory
General Comments 0
You need to be logged in to leave comments. Login now