[PATCH] pull: lookup checkout on remote before updating (fixes issue1465)

John Mulligan phlogistonjohn at asynchrono.us
Mon Feb 16 09:36:50 CST 2009


# HG changeset patch
# User John Mulligan <phlogistonjohn at asynchrono.us>
# Date 1234798555 18000
# Node ID 50c118d149f6b1a5c6c359da69d741201b7d2832
# Parent  14a42208d8aff6fad1ab5e73bc807eed3f753034
pull: lookup checkout on remote before updating (fixes issue1465)

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -2166,15 +2166,20 @@
 
     other = hg.repository(ui, source)
     ui.status(_('pulling from %s\n') % url.hidepassword(source))
+    pullrevs = None
     if revs:
+        pullrevs = []
         try:
-            revs = [other.lookup(rev) for rev in revs]
+            for rev in revs:
+                pullrevs.append(other.lookup(rev))
+                if checkout == rev:
+                    checkout = pullrevs[-1]
         except error.CapabilityError:
             err = _("Other repository doesn't support revision lookup, "
                     "so a rev cannot be specified.")
             raise util.Abort(err)
 
-    modheads = repo.pull(other, heads=revs, force=opts.get('force'))
+    modheads = repo.pull(other, heads=pullrevs, force=opts.get('force'))
     return postincoming(ui, repo, modheads, opts.get('update'), checkout)
 
 def push(ui, repo, dest=None, **opts):
diff --git a/tests/test-pull b/tests/test-pull
--- a/tests/test-pull
+++ b/tests/test-pull
@@ -24,3 +24,29 @@
 hg init empty
 cd empty
 hg pull -u ../test
+
+echo % issue 1465
+hg init test1465
+cd test1465
+echo 0 > zero
+hg add zero
+hg commit -u test -d '0 0' -m zero
+echo a > a
+echo b > b
+hg add a
+hg commit -u test -d '0 0' -m 1a
+hg add b
+hg commit -u test -d '0 0' -m 1b
+hg up -C 0
+echo c > c
+echo d > d
+hg add c
+hg commit -u test -d '0 0' -m 2c
+hg add d
+hg commit -u test -d '0 0' -m 2d
+cd ..
+hg init to1465
+cd to1465
+hg pull -u -r 4 ../test1465
+
+
diff --git a/tests/test-pull.out b/tests/test-pull.out
--- a/tests/test-pull.out
+++ b/tests/test-pull.out
@@ -30,3 +30,13 @@
 adding file changes
 added 1 changesets with 1 changes to 1 files
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+% issue 1465
+0 files updated, 0 files merged, 2 files removed, 0 files unresolved
+created new head
+pulling from ../test1465
+requesting all changes
+adding changesets
+adding manifests
+adding file changes
+added 3 changesets with 3 changes to 3 files
+3 files updated, 0 files merged, 0 files removed, 0 files unresolved


More information about the Mercurial-devel mailing list