changeset 28065:6b1fc09c699a

update: change default destination to tipmost descendant (issue4673) (BC) Bare 'hg update' now brings you to the tipmost descendant (on the same branch). Leaving the user on the same topological branch. The previous behavior, updating to the tipmost changeset on the same branch could lead to jump from a topological branch to another. This was confusing and impractical. As the only conceivable reason for the old behavior have been address by the recently introduce message about other heads, we can "safely" change this behavior All test changes have been reviewed and seen a valid consequences.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Tue, 02 Feb 2016 15:24:11 +0000
parents 9e0535da20a5
children d1cc07123243
files mercurial/destutil.py tests/test-bookmarks.t tests/test-largefiles-cache.t tests/test-merge-criss-cross.t tests/test-merge5.t tests/test-pull-update.t tests/test-up-local-change.t tests/test-update-branches.t
diffstat 8 files changed, 23 insertions(+), 53 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/destutil.py	Wed Feb 03 15:21:11 2016 +0000
+++ b/mercurial/destutil.py	Tue Feb 02 15:24:11 2016 +0000
@@ -92,7 +92,8 @@
     wc = repo[None]
     movemark = node = None
     try:
-        node = repo.branchtip(wc.branch())
+        node = repo.revs('max(.::(head() and branch(%s)))'
+                         , wc.branch()).first()
         if bookmarks.isactivewdirparent(repo):
             movemark = repo['.'].node()
     except error.RepoLookupError:
--- a/tests/test-bookmarks.t	Wed Feb 03 15:21:11 2016 +0000
+++ b/tests/test-bookmarks.t	Tue Feb 02 15:24:11 2016 +0000
@@ -735,35 +735,12 @@
      date:        Thu Jan 01 00:00:00 1970 +0000
      summary:     0
   
-test non-linear update not clearing active bookmark
-
-  $ hg up 1
-  1 files updated, 0 files merged, 2 files removed, 0 files unresolved
-  (leaving bookmark four)
-  $ hg book drop
-  $ hg up -C
-  1 files updated, 0 files merged, 1 files removed, 0 files unresolved
-  (leaving bookmark drop)
-  1 other heads for branch "default"
-  $ hg sum
-  parent: 2:db815d6d32e6 
-   2
-  branch: default
-  bookmarks: should-end-on-two
-  commit: 2 unknown (clean)
-  update: 1 new changesets, 2 branch heads (merge)
-  phases: 4 draft
-  $ hg book
-     drop                      1:925d80f479bb
-     four                      3:9ba5f110a0b3
-     should-end-on-two         2:db815d6d32e6
-  $ hg book -d drop
-  $ hg up four
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  (activating bookmark four)
 
 no-op update doesn't deactive bookmarks
 
+  $ hg up four
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  (activating bookmark four)
   $ hg up
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ hg sum
--- a/tests/test-largefiles-cache.t	Wed Feb 03 15:21:11 2016 +0000
+++ b/tests/test-largefiles-cache.t	Tue Feb 02 15:24:11 2016 +0000
@@ -189,7 +189,7 @@
 Inject corruption into the largefiles store and see how update handles that:
 
   $ cd src
-  $ hg up -qC
+  $ hg up -qC tip
   $ cat large
   modified
   $ rm large
--- a/tests/test-merge-criss-cross.t	Wed Feb 03 15:21:11 2016 +0000
+++ b/tests/test-merge-criss-cross.t	Tue Feb 02 15:24:11 2016 +0000
@@ -212,7 +212,7 @@
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   (branch merge, don't forget to commit)
 
-  $ hg up -qC
+  $ hg up -qC tip
   $ hg merge -v
   note: merging 3b08d01b0ab5+ and adfe50279922 using bids from ancestors 0f6b37dbe527 and 40663881a6dd
   
--- a/tests/test-merge5.t	Wed Feb 03 15:21:11 2016 +0000
+++ b/tests/test-merge5.t	Tue Feb 02 15:24:11 2016 +0000
@@ -13,18 +13,13 @@
   created new head
   $ hg update 1
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  $ hg update
-  abort: not a linear update
-  (merge or update --check to force update)
-  [255]
   $ rm b
-  $ hg update -c
+  $ hg update -c 2
   abort: uncommitted changes
   [255]
   $ hg revert b
-  $ hg update -c
+  $ hg update -c 2
   0 files updated, 0 files merged, 1 files removed, 0 files unresolved
-  1 other heads for branch "default"
   $ mv a c
 
 Should abort:
--- a/tests/test-pull-update.t	Wed Feb 03 15:21:11 2016 +0000
+++ b/tests/test-pull-update.t	Tue Feb 02 15:24:11 2016 +0000
@@ -16,7 +16,7 @@
   $ echo 1.2 > foo
   $ hg ci -Am m
 
-Should not update:
+Should not update to the other topological branch:
 
   $ hg pull -u ../tt
   pulling from ../tt
@@ -25,13 +25,12 @@
   adding manifests
   adding file changes
   added 1 changesets with 1 changes to 1 files (+1 heads)
-  abort: not updating: not a linear update
-  (merge or update --check to force update)
-  [255]
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  1 other heads for branch "default"
 
   $ cd ../tt
 
-Should not update:
+Should not update to the other branch:
 
   $ hg pull -u ../t
   pulling from ../t
@@ -40,9 +39,8 @@
   adding manifests
   adding file changes
   added 1 changesets with 1 changes to 1 files (+1 heads)
-  abort: not updating: not a linear update
-  (merge or update --check to force update)
-  [255]
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  1 other heads for branch "default"
 
   $ HGMERGE=true hg merge
   merging foo
--- a/tests/test-up-local-change.t	Wed Feb 03 15:21:11 2016 +0000
+++ b/tests/test-up-local-change.t	Tue Feb 02 15:24:11 2016 +0000
@@ -172,9 +172,8 @@
   summary:     2
   
   $ hg --debug up
-  abort: uncommitted changes
-  (commit and merge, or update --clean to discard changes)
-  [255]
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  1 other heads for branch "default"
 
 test conflicting untracked files
 
--- a/tests/test-update-branches.t	Wed Feb 03 15:21:11 2016 +0000
+++ b/tests/test-update-branches.t	Tue Feb 02 15:24:11 2016 +0000
@@ -93,8 +93,8 @@
   parent=5
 
   $ norevtest 'none clean same'   clean 2
-  abort: not a linear update
-  (merge or update --check to force update)
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  1 other heads for branch "default"
   parent=2
 
 
@@ -140,8 +140,8 @@
   M foo
 
   $ norevtest 'none dirty cross'  dirty 2
-  abort: uncommitted changes
-  (commit and merge, or update --clean to discard changes)
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  1 other heads for branch "default"
   parent=2
   M foo
 
@@ -166,9 +166,9 @@
   M sub/suba
 
   $ norevtest '-c clean same'   clean 2 -c
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
   1 other heads for branch "default"
-  parent=3
+  parent=2
 
   $ revtest '-cC dirty linear'  dirty 1 2 -cC
   abort: cannot specify both -c/--check and -C/--clean