Merge with stable
authorMatt Mackall <mpm@selenic.com>
Thu, 09 Jul 2009 19:49:02 -0500
changeset 9102 bbc78cb1bf15
parent 9092 9aebeea7ac00 (current diff)
parent 9101 71d26ae62fbb (diff)
child 9103 9c7a5d70e72f
Merge with stable
hgext/convert/cvs.py
hgext/keyword.py
hgext/win32mbcs.py
mercurial/commands.py
mercurial/context.py
mercurial/copies.py
mercurial/localrepo.py
mercurial/util.py
--- a/hgext/keyword.py	Sat Jul 04 14:18:15 2009 +0100
+++ b/hgext/keyword.py	Thu Jul 09 19:49:02 2009 -0500
@@ -456,13 +456,14 @@
             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 @@
                 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)
--- a/hgext/win32mbcs.py	Sat Jul 04 14:18:15 2009 +0100
+++ b/hgext/win32mbcs.py	Thu Jul 09 19:49:02 2009 -0500
@@ -35,7 +35,7 @@
 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 @@
                          " %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 @@
 #       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
--- a/mercurial/commands.py	Sat Jul 04 14:18:15 2009 +0100
+++ b/mercurial/commands.py	Thu Jul 09 19:49:02 2009 -0500
@@ -1183,18 +1183,7 @@
     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
--- a/mercurial/context.py	Sat Jul 04 14:18:15 2009 +0100
+++ b/mercurial/context.py	Thu Jul 09 19:49:02 2009 -0500
@@ -293,6 +293,7 @@
 
     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 @@
                 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
--- a/mercurial/copies.py	Sat Jul 04 14:18:15 2009 +0100
+++ b/mercurial/copies.py	Thu Jul 09 19:49:02 2009 -0500
@@ -120,8 +120,8 @@
                 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 = {}
--- a/mercurial/localrepo.py	Sat Jul 04 14:18:15 2009 +0100
+++ b/mercurial/localrepo.py	Thu Jul 09 19:49:02 2009 -0500
@@ -473,7 +473,9 @@
                 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)
--- a/mercurial/transaction.py	Sat Jul 04 14:18:15 2009 +0100
+++ b/mercurial/transaction.py	Thu Jul 09 19:49:02 2009 -0500
@@ -35,7 +35,7 @@
             try:
                 fn = opener(f).name
                 os.unlink(fn)
-            except OSError, inst:
+            except IOError, inst:
                 if inst.errno != errno.ENOENT:
                     raise
     os.unlink(journal)
--- a/mercurial/util.py	Sat Jul 04 14:18:15 2009 +0100
+++ b/mercurial/util.py	Thu Jul 09 19:49:02 2009 -0500
@@ -115,6 +115,33 @@
 
     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
--- a/mercurial/windows.py	Sat Jul 04 14:18:15 2009 +0100
+++ b/mercurial/windows.py	Thu Jul 09 19:49:02 2009 -0500
@@ -209,11 +209,9 @@
     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:
--- a/tests/test-fetch	Sat Jul 04 14:18:15 2009 +0100
+++ b/tests/test-fetch	Thu Jul 09 19:49:02 2009 -0500
@@ -185,6 +185,18 @@
 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
--- a/tests/test-fetch.out	Sat Jul 04 14:18:15 2009 +0100
+++ b/tests/test-fetch.out	Thu Jul 09 19:49:02 2009 -0500
@@ -190,3 +190,20 @@
 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