changeset 5224:20817af258d8

pull -u: if "url#rev" was given, update to rev
author Alexis S. L. Carvalho <alexis@cecm.usp.br>
date Mon, 27 Aug 2007 01:44:35 -0300
parents fe55e3d6dc0b
children 76c4cadb49fc
files mercurial/commands.py tests/test-url-rev tests/test-url-rev.out
diffstat 3 files changed, 87 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Mon Aug 27 01:44:35 2007 -0300
+++ b/mercurial/commands.py	Mon Aug 27 01:44:35 2007 -0300
@@ -2021,12 +2021,12 @@
         for name, path in ui.configitems("paths"):
             ui.write("%s = %s\n" % (name, path))
 
-def postincoming(ui, repo, modheads, optupdate):
+def postincoming(ui, repo, modheads, optupdate, checkout):
     if modheads == 0:
         return
     if optupdate:
-        if modheads <= 1:
-            return hg.update(repo, None)
+        if modheads <= 1 or checkout:
+            return hg.update(repo, checkout)
         else:
             ui.status(_("not updating, since new heads added\n"))
     if modheads > 1:
@@ -2089,7 +2089,7 @@
             raise util.Abort(error)
 
     modheads = repo.pull(other, heads=revs, force=opts['force'])
-    return postincoming(ui, repo, modheads, opts['update'])
+    return postincoming(ui, repo, modheads, opts['update'], checkout)
 
 def push(ui, repo, dest=None, **opts):
     """push changes to the specified destination
@@ -2661,7 +2661,7 @@
         gen = changegroup.readbundle(f, fname)
         modheads = repo.addchangegroup(gen, 'unbundle', 'bundle:' + fname)
 
-    return postincoming(ui, repo, modheads, opts['update'])
+    return postincoming(ui, repo, modheads, opts['update'], None)
 
 def update(ui, repo, node=None, rev=None, clean=False, date=None):
     """update working directory
--- a/tests/test-url-rev	Mon Aug 27 01:44:35 2007 -0300
+++ b/tests/test-url-rev	Mon Aug 27 01:44:35 2007 -0300
@@ -51,3 +51,33 @@
 hg heads
 echo
 
+echo '% pull should not have updated'
+hg parents -q
+echo '% going back to the default branch'
+hg up -C 0
+hg parents
+echo '% no new revs, no update'
+hg pull -qu
+hg parents -q
+echo '% rollback'
+hg rollback
+hg up -C 0
+hg parents -q
+echo '% pull -u takes us back to branch foo'
+hg pull -qu
+hg parents
+
+echo '% rollback'
+hg rollback
+hg up -C 0
+echo '% parents'
+hg parents -q
+echo '% heads'
+hg heads -q
+echo '% pull -u -r otherrev url#rev updates to rev'
+hg pull -qur default default
+echo '% parents'
+hg parents
+echo '% heads'
+hg heads
+
--- a/tests/test-url-rev.out	Mon Aug 27 01:44:35 2007 -0300
+++ b/tests/test-url-rev.out	Mon Aug 27 01:44:35 2007 -0300
@@ -76,3 +76,55 @@
 summary:     new head of branch foo
 
 
+% pull should not have updated
+1:cd2a86ecc814
+% going back to the default branch
+1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+changeset:   0:1f0dee641bb7
+user:        test
+date:        Thu Jan 01 00:00:00 1970 +0000
+summary:     add a
+
+% no new revs, no update
+0:1f0dee641bb7
+% rollback
+rolling back last transaction
+1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+0:1f0dee641bb7
+% pull -u takes us back to branch foo
+changeset:   2:faba9097cad4
+branch:      foo
+tag:         tip
+user:        test
+date:        Thu Jan 01 00:00:00 1970 +0000
+summary:     new head of branch foo
+
+% rollback
+rolling back last transaction
+1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+% parents
+0:1f0dee641bb7
+% heads
+1:cd2a86ecc814
+% pull -u -r otherrev url#rev updates to rev
+% parents
+changeset:   2:faba9097cad4
+branch:      foo
+user:        test
+date:        Thu Jan 01 00:00:00 1970 +0000
+summary:     new head of branch foo
+
+% heads
+changeset:   3:4cd725637392
+tag:         tip
+parent:      0:1f0dee641bb7
+user:        test
+date:        Thu Jan 01 00:00:00 1970 +0000
+summary:     add bar
+
+changeset:   2:faba9097cad4
+branch:      foo
+user:        test
+date:        Thu Jan 01 00:00:00 1970 +0000
+summary:     new head of branch foo
+