changeset 10785:071da7caac22

Merge with i18n
author Matt Mackall <mpm@selenic.com>
date Mon, 29 Mar 2010 15:16:38 -0500
parents 0065e6b42a25 (diff) 3dada86eb1e7 (current diff)
children 2f2ae64a2948
files
diffstat 5 files changed, 60 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/mq.py	Fri Mar 26 21:35:06 2010 -0300
+++ b/hgext/mq.py	Mon Mar 29 15:16:38 2010 -0500
@@ -2577,7 +2577,8 @@
             start = lrev + 1
             if start < qbase:
                 # update the cache (excluding the patches) and save it
-                self._updatebranchcache(partial, lrev + 1, qbase)
+                ctxgen = (self[r] for r in xrange(lrev + 1, qbase))
+                self._updatebranchcache(partial, ctxgen)
                 self._writebranchcache(partial, cl.node(qbase - 1), qbase - 1)
                 start = qbase
             # if start = qbase, the cache is as updated as it should be.
@@ -2585,7 +2586,8 @@
             # we might as well use it, but we won't save it.
 
             # update the cache up to the tip
-            self._updatebranchcache(partial, start, len(cl))
+            ctxgen = (self[r] for r in xrange(start, len(cl)))
+            self._updatebranchcache(partial, ctxgen)
 
             return partial
 
--- a/mercurial/localrepo.py	Fri Mar 26 21:35:06 2010 -0300
+++ b/mercurial/localrepo.py	Mon Mar 29 15:16:38 2010 -0500
@@ -320,7 +320,8 @@
         # TODO: rename this function?
         tiprev = len(self) - 1
         if lrev != tiprev:
-            self._updatebranchcache(partial, lrev + 1, tiprev + 1)
+            ctxgen = (self[r] for r in xrange(lrev + 1, tiprev + 1))
+            self._updatebranchcache(partial, ctxgen)
             self._writebranchcache(partial, self.changelog.tip(), tiprev)
 
         return partial
@@ -398,11 +399,10 @@
         except (IOError, OSError):
             pass
 
-    def _updatebranchcache(self, partial, start, end):
+    def _updatebranchcache(self, partial, ctxgen):
         # collect new branch entries
         newbranches = {}
-        for r in xrange(start, end):
-            c = self[r]
+        for c in ctxgen:
             newbranches.setdefault(c.branch(), []).append(c.node())
         # if older branchheads are reachable from new ones, they aren't
         # really branchheads. Note checking parents is insufficient:
@@ -1503,30 +1503,22 @@
         update, updated_heads = self.findoutgoing(remote, common, remote_heads)
         msng_cl, bases, heads = self.changelog.nodesbetween(update, revs)
 
-        def checkbranch(lheads, rheads, updatelb, branchname=None):
+        def checkbranch(lheads, rheads, branchname=None):
             '''
             check whether there are more local heads than remote heads on
             a specific branch.
 
             lheads: local branch heads
             rheads: remote branch heads
-            updatelb: outgoing local branch bases
             '''
 
             warn = 0
 
-            if not revs and len(lheads) > len(rheads):
+            if len(lheads) > len(rheads):
                 warn = 1
             else:
-                # add local heads involved in the push
-                updatelheads = [self.changelog.heads(x, lheads)
-                                for x in updatelb]
-                newheads = set(sum(updatelheads, [])) & set(lheads)
-
-                if not newheads:
-                    return True
-
                 # add heads we don't have or that are not involved in the push
+                newheads = set(lheads)
                 for r in rheads:
                     if r in self.changelog.nodemap:
                         desc = self.changelog.heads(r, heads)
@@ -1575,9 +1567,8 @@
                         localbrheads = self.branchmap()
                     else:
                         localbrheads = {}
-                        for n in heads:
-                            branch = self[n].branch()
-                            localbrheads.setdefault(branch, []).append(n)
+                        ctxgen = (self[n] for n in msng_cl)
+                        self._updatebranchcache(localbrheads, ctxgen)
 
                     newbranches = list(set(localbrheads) - set(remotebrheads))
                     if newbranches: # new branch requires --force
@@ -1591,10 +1582,10 @@
                     for branch, lheads in localbrheads.iteritems():
                         if branch in remotebrheads:
                             rheads = remotebrheads[branch]
-                            if not checkbranch(lheads, rheads, update, branch):
+                            if not checkbranch(lheads, rheads, branch):
                                 return None, 0
                 else:
-                    if not checkbranch(heads, remote_heads, update):
+                    if not checkbranch(heads, remote_heads):
                         return None, 0
 
             if inc:
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/helpers.sh	Mon Mar 29 15:16:38 2010 -0500
@@ -0,0 +1,9 @@
+#/bin/sh
+
+hideport() { sed "s/localhost:$HGPORT/localhost:\$HGPORT/"; }
+
+repr() { python -c "import sys; print repr(sys.stdin.read()).replace('\\n', '\n')" }
+
+hidehex() { python -c 'import sys, re; print re.replace("\b[0-9A-Fa-f]{12,40}", "X" * 12)' }
+
+hidetmp() { sed "s/$HGTMP/\$HGTMP/"; }
\ No newline at end of file
--- a/tests/test-push-warn	Fri Mar 26 21:35:06 2010 -0300
+++ b/tests/test-push-warn	Mon Mar 29 15:16:38 2010 -0500
@@ -166,4 +166,32 @@
 hg -R k push -r a j
 echo
 
+echo % prepush -r should not allow you to sneak in new heads
+hg init l
+cd l
+echo a >> foo
+hg -q add foo
+hg -q branch a
+hg -q ci -d '0 0' -ma
+hg -q up null
+echo a >> foo
+hg -q add foo
+hg -q branch b
+hg -q ci -d '0 0' -mb
+cd ..
+hg -q clone l m -u a
+cd m
+hg -q merge b
+hg -q ci -d '0 0' -mmb
+hg -q up 0
+echo a >> foo
+hg -q ci -ma2
+hg -q up 2
+echo a >> foo
+hg -q branch -f b
+hg -q ci -d '0 0' -mb2
+hg -q merge 3
+hg -q ci -d '0 0' -mma
+hg push ../l -b b
+
 exit 0
--- a/tests/test-push-warn.out	Fri Mar 26 21:35:06 2010 -0300
+++ b/tests/test-push-warn.out	Mon Mar 29 15:16:38 2010 -0500
@@ -100,7 +100,7 @@
 1
 pushing to ../f
 searching for changes
-abort: push creates new remote branches: d!
+abort: push creates new remote branches: c, d!
 (use 'hg push -f' to force)
 1
 % fail on multiple head push
@@ -167,6 +167,11 @@
 (branch merge, don't forget to commit)
 pushing to j
 searching for changes
+abort: push creates new remote branches: b!
+(use 'hg push -f' to force)
+
+% prepush -r should not allow you to sneak in new heads
+pushing to ../l
+searching for changes
 abort: push creates new remote heads on branch 'a'!
-(you should pull and merge or use push -f to force)
-
+(did you forget to merge? use push -f to force)