Commits

Martin Geisler committed daae7f9

A patch we need to talk about some more

We'll have the same problem with clone -- what revision should we
update to when there are several branches/revisions given on the
command line.

  • Participants
  • Parent commits 9c9211a

Comments (0)

Files changed (2)

+# HG changeset patch
+# Parent cd31a1cc15217a120cf58a5cd6ebb25c6ca270bf
+RFC... postincoming: run 'hg update' with no checkout argument
+
+The current behavior was added to make 'hg pull -r X -r Y -u'
+consistent with 'hg clone -r X -r Y', which both update to revision X.
+
+With abandoned changesets, you can be in a situation where
+
+  hg pull -r X -u
+
+does not update to X, but to a non-abandoned ancestor of X. The pull
+command would then have to figure out what ancestor that is.
+
+diff --git a/mercurial/commands.py b/mercurial/commands.py
+--- a/mercurial/commands.py
++++ b/mercurial/commands.py
+@@ -3658,12 +3658,12 @@
+             else:
+                 ui.write("%s = %s\n" % (name, util.hidepassword(path)))
+ 
+-def postincoming(ui, repo, modheads, optupdate, checkout):
++def postincoming(ui, repo, modheads, optupdate):
+     if modheads == 0:
+         return
+     if optupdate:
+         try:
+-            return hg.update(repo, checkout)
++            return hg.update(repo, None)
+         except util.Abort, inst:
+             ui.warn(_("not updating: %s\n" % str(inst)))
+             return 0
+@@ -3736,7 +3736,7 @@
+         checkout = str(repo.changelog.rev(other.lookup(checkout)))
+     repo._subtoppath = source
+     try:
+-        ret = postincoming(ui, repo, modheads, opts.get('update'), checkout)
++        ret = postincoming(ui, repo, modheads, opts.get('update'))
+ 
+     finally:
+         del repo._subtoppath
+@@ -4970,7 +4970,7 @@
+         bookmarks.updatecurrentbookmark(repo, wc.node(), wc.branch())
+     finally:
+         lock.release()
+-    return postincoming(ui, repo, modheads, opts.get('update'), None)
++    return postincoming(ui, repo, modheads, opts.get('update'))
+ 
+ @command('^update|up|checkout|co',
+     [('C', 'clean', None, _('discard uncommitted changes (no backup)')),
+diff --git a/tests/test-pull-r.t b/tests/test-pull-r.t
+--- a/tests/test-pull-r.t
++++ b/tests/test-pull-r.t
+@@ -70,7 +70,7 @@
+ 
+   $ hg pull -qu -r 0 -r 1 ../repo
+   $ hg -q parents
+-  0:bbd179dfa0a7
++  1:ed1b79f46b9a
+   $ hg rollback
+   repository tip rolled back to revision -1 (undo pull)
+   working directory now based on revision -1
+diff --git a/tests/test-url-rev.t b/tests/test-url-rev.t
+--- a/tests/test-url-rev.t
++++ b/tests/test-url-rev.t
+@@ -155,24 +155,22 @@
+   $ hg parents -q
+   0:1f0dee641bb7
+ 
+-Pull -u takes us back to branch foo:
++Pull -u doesn't take us back to branch foo:
+ 
+   $ hg pull -qu
+ 
+   $ hg parents
+-  changeset:   2:faba9097cad4
+-  branch:      foo
+-  tag:         tip
++  changeset:   0:1f0dee641bb7
+   user:        test
+   date:        Thu Jan 01 00:00:00 1970 +0000
+-  summary:     new head of branch foo
++  summary:     add a
+   
+   $ hg rollback
+   repository tip rolled back to revision 1 (undo pull)
+   working directory now based on revision 0
+ 
+   $ hg up -C 0
+-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
++  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+ 
+   $ hg parents -q
+   0:1f0dee641bb7
 copy-of-81e6d42b3228 #+old
 copy-of-08fde203a600 #+old
 old-abandon #+old
+no-checkout
 hidden
 abandon-command
 abandoned-revset