diff --git a/hgext/keyword.py b/hgext/keyword.py --- a/hgext/keyword.py +++ b/hgext/keyword.py @@ -456,13 +456,14 @@ def reposetup(ui, repo): data = super(kwrepo, self).wread(filename) return kwt.wread(filename, data) - def commit(self, text='', user=None, date=None, match=None, - force=False, editor=None, extra={}): + def commit(self, *args, **opts): # use custom commitctx for user commands # other extensions can still wrap repo.commitctx directly - repo.commitctx = self.kwcommitctx - return super(kwrepo, self).commit(text, user, date, match, force, - editor, extra) + self.commitctx = self.kwcommitctx + try: + return super(kwrepo, self).commit(*args, **opts) + finally: + del self.commitctx def kwcommitctx(self, ctx, error=False): wlock = lock = None @@ -486,7 +487,7 @@ def reposetup(ui, repo): if commithooks: for name, cmd in commithooks.iteritems(): ui.setconfig('hooks', name, cmd) - repo.hook('commit', node=n, parent1=xp1, parent2=xp2) + self.hook('commit', node=n, parent1=xp1, parent2=xp2) return n finally: release(lock, wlock) diff --git a/hgext/win32mbcs.py b/hgext/win32mbcs.py --- a/hgext/win32mbcs.py +++ b/hgext/win32mbcs.py @@ -35,7 +35,7 @@ Path encoding conversion are done betwee is decided by Mercurial from current locale setting or HGENCODING. ''' -import os +import os, sys from mercurial.i18n import _ from mercurial import util, encoding @@ -76,10 +76,8 @@ def wrapper(func, args): " %s encoding\n") % (encoding.encoding)) def wrapname(name): - idx = name.rfind('.') - module = name[:idx] - name = name[idx+1:] - module = globals()[module] + module, name = name.rsplit('.', 1) + module = sys.modules[module] func = getattr(module, name) def f(*args): return wrapper(func, args) @@ -94,7 +92,8 @@ def wrapname(name): # they use result of os.path.split() funcs = '''os.path.join os.path.split os.path.splitext os.path.splitunc os.path.normpath os.path.normcase os.makedirs - util.endswithsep util.splitpath util.checkcase util.fspath''' + mercurial.util.endswithsep mercurial.util.splitpath mercurial.util.checkcase + mercurial.util.fspath mercurial.windows.pconvert''' # codec and alias names of sjis and big5 to be faked. problematic_encodings = '''big5 big5-tw csbig5 big5hkscs big5-hkscs diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -1183,18 +1183,7 @@ def grep(ui, repo, pattern, *pats, **opt if opts.get('print0'): sep = eol = '\0' - fcache = {} - forder = [] - def getfile(fn): - if fn not in fcache: - if len(fcache) > 20: - del fcache[forder.pop(0)] - fcache[fn] = repo.file(fn) - else: - forder.remove(fn) - - forder.append(fn) - return fcache[fn] + getfile = util.lrucachefunc(repo.file) def matchlines(body): begin = 0 diff --git a/mercurial/context.py b/mercurial/context.py --- a/mercurial/context.py +++ b/mercurial/context.py @@ -293,6 +293,7 @@ class filectx(object): def linkrev(self): return self._filelog.linkrev(self._filerev) def node(self): return self._changectx.node() + def hex(self): return hex(self.node()) def user(self): return self._changectx.user() def date(self): return self._changectx.date() def files(self): return self._changectx.files() @@ -381,11 +382,11 @@ class filectx(object): child[0][b1:b2] = parent[0][a1:a2] return child - getlog = util.cachefunc(lambda x: self._repo.file(x)) + getlog = util.lrucachefunc(lambda x: self._repo.file(x)) def getctx(path, fileid): log = path == self._path and self._filelog or getlog(path) return filectx(self._repo, path, fileid=fileid, filelog=log) - getctx = util.cachefunc(getctx) + getctx = util.lrucachefunc(getctx) def parents(f): # we want to reuse filectx objects as much as possible diff --git a/mercurial/copies.py b/mercurial/copies.py --- a/mercurial/copies.py +++ b/mercurial/copies.py @@ -120,8 +120,8 @@ def copies(repo, c1, c2, ca, checkdirs=F return c1.filectx(f) return c2.filectx(f) return repo.filectx(f, fileid=n) - ctx = util.cachefunc(makectx) + ctx = util.lrucachefunc(makectx) copy = {} fullcopy = {} diverge = {} diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -473,7 +473,9 @@ class localrepository(repo.repository): latest = newnodes.pop() if latest not in bheads: continue - reachable = self.changelog.reachable(latest, bheads[0]) + reachable = set() + for bh in bheads: + reachable |= self.changelog.reachable(latest, bh) bheads = [b for b in bheads if b not in reachable] newbheads.insert(0, latest) bheads.extend(newbheads) diff --git a/mercurial/transaction.py b/mercurial/transaction.py --- a/mercurial/transaction.py +++ b/mercurial/transaction.py @@ -35,7 +35,7 @@ def _playback(journal, report, opener, e try: fn = opener(f).name os.unlink(fn) - except OSError, inst: + except IOError, inst: if inst.errno != errno.ENOENT: raise os.unlink(journal) diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -115,6 +115,33 @@ def cachefunc(func): return f +def lrucachefunc(func): + '''cache most recent results of function calls''' + cache = {} + order = [] + if func.func_code.co_argcount == 1: + def f(arg): + if arg not in cache: + if len(cache) > 20: + del cache[order.pop(0)] + cache[arg] = func(arg) + else: + order.remove(arg) + order.append(arg) + return cache[arg] + else: + def f(*args): + if args not in cache: + if len(cache) > 20: + del cache[order.pop(0)] + cache[args] = func(*args) + else: + order.remove(args) + order.append(args) + return cache[args] + + return f + class propertycache(object): def __init__(self, func): self.func = func diff --git a/mercurial/windows.py b/mercurial/windows.py --- a/mercurial/windows.py +++ b/mercurial/windows.py @@ -209,11 +209,9 @@ def statfiles(files): dircache = {} # dirname -> filename -> status | None if file does not exist for nf in files: nf = ncase(nf) - pos = nf.rfind(sep) - if pos == -1: - dir, base = '.', nf - else: - dir, base = nf[:pos+1], nf[pos+1:] + dir, base = os.path.split(nf) + if not dir: + dir = '.' cache = dircache.get(dir, None) if cache is None: try: diff --git a/tests/test-fetch b/tests/test-fetch --- a/tests/test-fetch +++ b/tests/test-fetch @@ -185,6 +185,18 @@ echo % fetch should succeed hg --cwd ib2 fetch ../ib1 rm -fr ib1 ib2 +echo % test issue1726 +hg init i1726r1 +echo a > i1726r1/a +hg --cwd i1726r1 ci -Am base +hg clone i1726r1 i1726r2 +echo b > i1726r1/a +hg --cwd i1726r1 ci -m second +echo c > i1726r2/a +hg --cwd i1726r2 ci -m third +HGMERGE=true hg --cwd i1726r2 fetch ../i1726r1 | sed 's/new changeset 3:[0-9a-zA-Z]\+/new changeset 3/' +hg --cwd i1726r2 heads default --template '{rev}\n' + "$TESTDIR/killdaemons.py" true diff --git a/tests/test-fetch.out b/tests/test-fetch.out --- a/tests/test-fetch.out +++ b/tests/test-fetch.out @@ -190,3 +190,20 @@ 3 files updated, 0 files merged, 0 files pulling from ../ib1 searching for changes no changes found +% test issue1726 +adding a +updating working directory +1 files updated, 0 files merged, 0 files removed, 0 files unresolved +pulling from ../i1726r1 +searching for changes +adding changesets +adding manifests +adding file changes +added 1 changesets with 1 changes to 1 files (+1 heads) +updating to 2:7837755a2789 +1 files updated, 0 files merged, 0 files removed, 0 files unresolved +merging with 1:d1f0c6c48ebd +merging a +0 files updated, 1 files merged, 0 files removed, 0 files unresolved +new changeset 3 merges remote changes with local +3