Show More
@@ -456,13 +456,14 b' def reposetup(ui, repo):' | |||||
456 | data = super(kwrepo, self).wread(filename) |
|
456 | data = super(kwrepo, self).wread(filename) | |
457 | return kwt.wread(filename, data) |
|
457 | return kwt.wread(filename, data) | |
458 |
|
458 | |||
459 | def commit(self, text='', user=None, date=None, match=None, |
|
459 | def commit(self, *args, **opts): | |
460 | force=False, editor=None, extra={}): |
|
|||
461 | # use custom commitctx for user commands |
|
460 | # use custom commitctx for user commands | |
462 | # other extensions can still wrap repo.commitctx directly |
|
461 | # other extensions can still wrap repo.commitctx directly | |
463 |
|
|
462 | self.commitctx = self.kwcommitctx | |
464 | return super(kwrepo, self).commit(text, user, date, match, force, |
|
463 | try: | |
465 | editor, extra) |
|
464 | return super(kwrepo, self).commit(*args, **opts) | |
|
465 | finally: | |||
|
466 | del self.commitctx | |||
466 |
|
467 | |||
467 | def kwcommitctx(self, ctx, error=False): |
|
468 | def kwcommitctx(self, ctx, error=False): | |
468 | wlock = lock = None |
|
469 | wlock = lock = None | |
@@ -486,7 +487,7 b' def reposetup(ui, repo):' | |||||
486 | if commithooks: |
|
487 | if commithooks: | |
487 | for name, cmd in commithooks.iteritems(): |
|
488 | for name, cmd in commithooks.iteritems(): | |
488 | ui.setconfig('hooks', name, cmd) |
|
489 | ui.setconfig('hooks', name, cmd) | |
489 |
|
|
490 | self.hook('commit', node=n, parent1=xp1, parent2=xp2) | |
490 | return n |
|
491 | return n | |
491 | finally: |
|
492 | finally: | |
492 | release(lock, wlock) |
|
493 | release(lock, wlock) |
@@ -35,7 +35,7 b' Path encoding conversion are done betwee' | |||||
35 | is decided by Mercurial from current locale setting or HGENCODING. |
|
35 | is decided by Mercurial from current locale setting or HGENCODING. | |
36 | ''' |
|
36 | ''' | |
37 |
|
37 | |||
38 | import os |
|
38 | import os, sys | |
39 | from mercurial.i18n import _ |
|
39 | from mercurial.i18n import _ | |
40 | from mercurial import util, encoding |
|
40 | from mercurial import util, encoding | |
41 |
|
41 | |||
@@ -76,10 +76,8 b' def wrapper(func, args):' | |||||
76 | " %s encoding\n") % (encoding.encoding)) |
|
76 | " %s encoding\n") % (encoding.encoding)) | |
77 |
|
77 | |||
78 | def wrapname(name): |
|
78 | def wrapname(name): | |
79 |
|
|
79 | module, name = name.rsplit('.', 1) | |
80 |
module = |
|
80 | module = sys.modules[module] | |
81 | name = name[idx+1:] |
|
|||
82 | module = globals()[module] |
|
|||
83 | func = getattr(module, name) |
|
81 | func = getattr(module, name) | |
84 | def f(*args): |
|
82 | def f(*args): | |
85 | return wrapper(func, args) |
|
83 | return wrapper(func, args) | |
@@ -94,7 +92,8 b' def wrapname(name):' | |||||
94 | # they use result of os.path.split() |
|
92 | # they use result of os.path.split() | |
95 | funcs = '''os.path.join os.path.split os.path.splitext |
|
93 | funcs = '''os.path.join os.path.split os.path.splitext | |
96 | os.path.splitunc os.path.normpath os.path.normcase os.makedirs |
|
94 | os.path.splitunc os.path.normpath os.path.normcase os.makedirs | |
97 |
util.endswithsep util.splitpath util.checkcase |
|
95 | mercurial.util.endswithsep mercurial.util.splitpath mercurial.util.checkcase | |
|
96 | mercurial.util.fspath mercurial.windows.pconvert''' | |||
98 |
|
97 | |||
99 | # codec and alias names of sjis and big5 to be faked. |
|
98 | # codec and alias names of sjis and big5 to be faked. | |
100 | problematic_encodings = '''big5 big5-tw csbig5 big5hkscs big5-hkscs |
|
99 | problematic_encodings = '''big5 big5-tw csbig5 big5hkscs big5-hkscs |
@@ -1183,18 +1183,7 b' def grep(ui, repo, pattern, *pats, **opt' | |||||
1183 | if opts.get('print0'): |
|
1183 | if opts.get('print0'): | |
1184 | sep = eol = '\0' |
|
1184 | sep = eol = '\0' | |
1185 |
|
1185 | |||
1186 | fcache = {} |
|
1186 | getfile = util.lrucachefunc(repo.file) | |
1187 | forder = [] |
|
|||
1188 | def getfile(fn): |
|
|||
1189 | if fn not in fcache: |
|
|||
1190 | if len(fcache) > 20: |
|
|||
1191 | del fcache[forder.pop(0)] |
|
|||
1192 | fcache[fn] = repo.file(fn) |
|
|||
1193 | else: |
|
|||
1194 | forder.remove(fn) |
|
|||
1195 |
|
||||
1196 | forder.append(fn) |
|
|||
1197 | return fcache[fn] |
|
|||
1198 |
|
1187 | |||
1199 | def matchlines(body): |
|
1188 | def matchlines(body): | |
1200 | begin = 0 |
|
1189 | begin = 0 |
@@ -293,6 +293,7 b' class filectx(object):' | |||||
293 |
|
293 | |||
294 | def linkrev(self): return self._filelog.linkrev(self._filerev) |
|
294 | def linkrev(self): return self._filelog.linkrev(self._filerev) | |
295 | def node(self): return self._changectx.node() |
|
295 | def node(self): return self._changectx.node() | |
|
296 | def hex(self): return hex(self.node()) | |||
296 | def user(self): return self._changectx.user() |
|
297 | def user(self): return self._changectx.user() | |
297 | def date(self): return self._changectx.date() |
|
298 | def date(self): return self._changectx.date() | |
298 | def files(self): return self._changectx.files() |
|
299 | def files(self): return self._changectx.files() | |
@@ -381,11 +382,11 b' class filectx(object):' | |||||
381 | child[0][b1:b2] = parent[0][a1:a2] |
|
382 | child[0][b1:b2] = parent[0][a1:a2] | |
382 | return child |
|
383 | return child | |
383 |
|
384 | |||
384 | getlog = util.cachefunc(lambda x: self._repo.file(x)) |
|
385 | getlog = util.lrucachefunc(lambda x: self._repo.file(x)) | |
385 | def getctx(path, fileid): |
|
386 | def getctx(path, fileid): | |
386 | log = path == self._path and self._filelog or getlog(path) |
|
387 | log = path == self._path and self._filelog or getlog(path) | |
387 | return filectx(self._repo, path, fileid=fileid, filelog=log) |
|
388 | return filectx(self._repo, path, fileid=fileid, filelog=log) | |
388 | getctx = util.cachefunc(getctx) |
|
389 | getctx = util.lrucachefunc(getctx) | |
389 |
|
390 | |||
390 | def parents(f): |
|
391 | def parents(f): | |
391 | # we want to reuse filectx objects as much as possible |
|
392 | # we want to reuse filectx objects as much as possible |
@@ -120,8 +120,8 b' def copies(repo, c1, c2, ca, checkdirs=F' | |||||
120 | return c1.filectx(f) |
|
120 | return c1.filectx(f) | |
121 | return c2.filectx(f) |
|
121 | return c2.filectx(f) | |
122 | return repo.filectx(f, fileid=n) |
|
122 | return repo.filectx(f, fileid=n) | |
123 | ctx = util.cachefunc(makectx) |
|
|||
124 |
|
123 | |||
|
124 | ctx = util.lrucachefunc(makectx) | |||
125 | copy = {} |
|
125 | copy = {} | |
126 | fullcopy = {} |
|
126 | fullcopy = {} | |
127 | diverge = {} |
|
127 | diverge = {} |
@@ -473,7 +473,9 b' class localrepository(repo.repository):' | |||||
473 | latest = newnodes.pop() |
|
473 | latest = newnodes.pop() | |
474 | if latest not in bheads: |
|
474 | if latest not in bheads: | |
475 | continue |
|
475 | continue | |
476 |
reachable = se |
|
476 | reachable = set() | |
|
477 | for bh in bheads: | |||
|
478 | reachable |= self.changelog.reachable(latest, bh) | |||
477 | bheads = [b for b in bheads if b not in reachable] |
|
479 | bheads = [b for b in bheads if b not in reachable] | |
478 | newbheads.insert(0, latest) |
|
480 | newbheads.insert(0, latest) | |
479 | bheads.extend(newbheads) |
|
481 | bheads.extend(newbheads) |
@@ -35,7 +35,7 b' def _playback(journal, report, opener, e' | |||||
35 | try: |
|
35 | try: | |
36 | fn = opener(f).name |
|
36 | fn = opener(f).name | |
37 | os.unlink(fn) |
|
37 | os.unlink(fn) | |
38 |
except O |
|
38 | except IOError, inst: | |
39 | if inst.errno != errno.ENOENT: |
|
39 | if inst.errno != errno.ENOENT: | |
40 | raise |
|
40 | raise | |
41 | os.unlink(journal) |
|
41 | os.unlink(journal) |
@@ -115,6 +115,33 b' def cachefunc(func):' | |||||
115 |
|
115 | |||
116 | return f |
|
116 | return f | |
117 |
|
117 | |||
|
118 | def lrucachefunc(func): | |||
|
119 | '''cache most recent results of function calls''' | |||
|
120 | cache = {} | |||
|
121 | order = [] | |||
|
122 | if func.func_code.co_argcount == 1: | |||
|
123 | def f(arg): | |||
|
124 | if arg not in cache: | |||
|
125 | if len(cache) > 20: | |||
|
126 | del cache[order.pop(0)] | |||
|
127 | cache[arg] = func(arg) | |||
|
128 | else: | |||
|
129 | order.remove(arg) | |||
|
130 | order.append(arg) | |||
|
131 | return cache[arg] | |||
|
132 | else: | |||
|
133 | def f(*args): | |||
|
134 | if args not in cache: | |||
|
135 | if len(cache) > 20: | |||
|
136 | del cache[order.pop(0)] | |||
|
137 | cache[args] = func(*args) | |||
|
138 | else: | |||
|
139 | order.remove(args) | |||
|
140 | order.append(args) | |||
|
141 | return cache[args] | |||
|
142 | ||||
|
143 | return f | |||
|
144 | ||||
118 | class propertycache(object): |
|
145 | class propertycache(object): | |
119 | def __init__(self, func): |
|
146 | def __init__(self, func): | |
120 | self.func = func |
|
147 | self.func = func |
@@ -209,11 +209,9 b' def statfiles(files):' | |||||
209 | dircache = {} # dirname -> filename -> status | None if file does not exist |
|
209 | dircache = {} # dirname -> filename -> status | None if file does not exist | |
210 | for nf in files: |
|
210 | for nf in files: | |
211 | nf = ncase(nf) |
|
211 | nf = ncase(nf) | |
212 | pos = nf.rfind(sep) |
|
212 | dir, base = os.path.split(nf) | |
213 |
if |
|
213 | if not dir: | |
214 |
dir |
|
214 | dir = '.' | |
215 | else: |
|
|||
216 | dir, base = nf[:pos+1], nf[pos+1:] |
|
|||
217 | cache = dircache.get(dir, None) |
|
215 | cache = dircache.get(dir, None) | |
218 | if cache is None: |
|
216 | if cache is None: | |
219 | try: |
|
217 | try: |
@@ -185,6 +185,18 b' echo % fetch should succeed' | |||||
185 | hg --cwd ib2 fetch ../ib1 |
|
185 | hg --cwd ib2 fetch ../ib1 | |
186 | rm -fr ib1 ib2 |
|
186 | rm -fr ib1 ib2 | |
187 |
|
187 | |||
|
188 | echo % test issue1726 | |||
|
189 | hg init i1726r1 | |||
|
190 | echo a > i1726r1/a | |||
|
191 | hg --cwd i1726r1 ci -Am base | |||
|
192 | hg clone i1726r1 i1726r2 | |||
|
193 | echo b > i1726r1/a | |||
|
194 | hg --cwd i1726r1 ci -m second | |||
|
195 | echo c > i1726r2/a | |||
|
196 | hg --cwd i1726r2 ci -m third | |||
|
197 | HGMERGE=true hg --cwd i1726r2 fetch ../i1726r1 | sed 's/new changeset 3:[0-9a-zA-Z]\+/new changeset 3/' | |||
|
198 | hg --cwd i1726r2 heads default --template '{rev}\n' | |||
|
199 | ||||
188 | "$TESTDIR/killdaemons.py" |
|
200 | "$TESTDIR/killdaemons.py" | |
189 |
|
201 | |||
190 | true |
|
202 | true |
@@ -190,3 +190,20 b' 3 files updated, 0 files merged, 0 files' | |||||
190 | pulling from ../ib1 |
|
190 | pulling from ../ib1 | |
191 | searching for changes |
|
191 | searching for changes | |
192 | no changes found |
|
192 | no changes found | |
|
193 | % test issue1726 | |||
|
194 | adding a | |||
|
195 | updating working directory | |||
|
196 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |||
|
197 | pulling from ../i1726r1 | |||
|
198 | searching for changes | |||
|
199 | adding changesets | |||
|
200 | adding manifests | |||
|
201 | adding file changes | |||
|
202 | added 1 changesets with 1 changes to 1 files (+1 heads) | |||
|
203 | updating to 2:7837755a2789 | |||
|
204 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |||
|
205 | merging with 1:d1f0c6c48ebd | |||
|
206 | merging a | |||
|
207 | 0 files updated, 1 files merged, 0 files removed, 0 files unresolved | |||
|
208 | new changeset 3 merges remote changes with local | |||
|
209 | 3 |
General Comments 0
You need to be logged in to leave comments.
Login now