Patchwork [2,of,2] update: change default destination to tipmost descendant (issue4673) (BC)

login
register
mail settings
Submitter Pierre-Yves David
Date Feb. 9, 2016, 7:16 p.m.
Message ID <913b57e4a14d5961dbd8.1455045366@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/13067/
State Accepted
Delegated to: Martin von Zweigbergk
Headers show

Comments

Pierre-Yves David - Feb. 9, 2016, 7:16 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1454426651 0
#      Tue Feb 02 15:24:11 2016 +0000
# Node ID 913b57e4a14d5961dbd845a45160b51a968c193a
# Parent  f865f8c9b492bea4514ba49c7c1cf2fa918f9a96
# EXP-Topic destination
# Available At http://hg.netv6.net/marmoute-wip/mercurial/
#              hg pull http://hg.netv6.net/marmoute-wip/mercurial/ -r 913b57e4a14d
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.
Sean Farley - Feb. 9, 2016, 7:28 p.m.
Pierre-Yves David <pierre-yves.david@ens-lyon.org> writes:

> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@fb.com>
> # Date 1454426651 0
> #      Tue Feb 02 15:24:11 2016 +0000
> # Node ID 913b57e4a14d5961dbd845a45160b51a968c193a
> # Parent  f865f8c9b492bea4514ba49c7c1cf2fa918f9a96
> # EXP-Topic destination
> # Available At http://hg.netv6.net/marmoute-wip/mercurial/
> #              hg pull http://hg.netv6.net/marmoute-wip/mercurial/ -r 913b57e4a14d
> 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.

I haven't digested the entire patch but I love the direction.
Yuya Nishihara - Feb. 11, 2016, 2:01 p.m.
On Tue, 09 Feb 2016 19:16:06 +0000, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@fb.com>
> # Date 1454426651 0
> #      Tue Feb 02 15:24:11 2016 +0000
> # Node ID 913b57e4a14d5961dbd845a45160b51a968c193a
> # Parent  f865f8c9b492bea4514ba49c7c1cf2fa918f9a96
> # EXP-Topic destination
> # Available At http://hg.netv6.net/marmoute-wip/mercurial/
> #              hg pull http://hg.netv6.net/marmoute-wip/mercurial/ -r 913b57e4a14d
> 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

New behavior makes sense to me.

> diff --git a/mercurial/destutil.py b/mercurial/destutil.py
> --- a/mercurial/destutil.py
> +++ b/mercurial/destutil.py
> @@ -90,11 +90,13 @@ def _destupdatebook(repo, clean, check):
>  def _destupdatebranch(repo, clean, check):
>      """decide on an update destination from current branch"""
>      wc = repo[None]
>      movemark = node = None
>      try:
> -        node = repo.branchtip(wc.branch())
> +        node = repo.revs('max(.::(head() and branch("%s")))'
> +                         % wc.branch()).first()

Typo of revs('.. branch(%s)', wc.branch()) ?
Pierre-Yves David - Feb. 11, 2016, 2:47 p.m.
On 02/11/2016 02:01 PM, Yuya Nishihara wrote:
> On Tue, 09 Feb 2016 19:16:06 +0000, Pierre-Yves David wrote:
>> # HG changeset patch
>> # User Pierre-Yves David <pierre-yves.david@fb.com>
>> # Date 1454426651 0
>> #      Tue Feb 02 15:24:11 2016 +0000
>> # Node ID 913b57e4a14d5961dbd845a45160b51a968c193a
>> # Parent  f865f8c9b492bea4514ba49c7c1cf2fa918f9a96
>> # EXP-Topic destination
>> # Available At http://hg.netv6.net/marmoute-wip/mercurial/
>> #              hg pull http://hg.netv6.net/marmoute-wip/mercurial/ -r 913b57e4a14d
>> 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
>
> New behavior makes sense to me.
>
>> diff --git a/mercurial/destutil.py b/mercurial/destutil.py
>> --- a/mercurial/destutil.py
>> +++ b/mercurial/destutil.py
>> @@ -90,11 +90,13 @@ def _destupdatebook(repo, clean, check):
>>   def _destupdatebranch(repo, clean, check):
>>       """decide on an update destination from current branch"""
>>       wc = repo[None]
>>       movemark = node = None
>>       try:
>> -        node = repo.branchtip(wc.branch())
>> +        node = repo.revs('max(.::(head() and branch("%s")))'
>> +                         % wc.branch()).first()
>
> Typo of revs('.. branch(%s)', wc.branch()) ?

Good catch, do you want to fix in flight or do you want a V2?
Martin von Zweigbergk - Feb. 11, 2016, 10:49 p.m.
On Tue, Feb 9, 2016 at 11:16 AM, Pierre-Yves David
<pierre-yves.david@ens-lyon.org> wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@fb.com>
> # Date 1454426651 0
> #      Tue Feb 02 15:24:11 2016 +0000
> # Node ID 913b57e4a14d5961dbd845a45160b51a968c193a
> # Parent  f865f8c9b492bea4514ba49c7c1cf2fa918f9a96
> # EXP-Topic destination
> # Available At http://hg.netv6.net/marmoute-wip/mercurial/
> #              hg pull http://hg.netv6.net/marmoute-wip/mercurial/ -r 913b57e4a14d
> 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.
>
> diff --git a/mercurial/destutil.py b/mercurial/destutil.py
> --- a/mercurial/destutil.py
> +++ b/mercurial/destutil.py
> @@ -90,11 +90,13 @@ def _destupdatebook(repo, clean, check):
>  def _destupdatebranch(repo, clean, check):
>      """decide on an update destination from current branch"""
>      wc = repo[None]
>      movemark = node = None
>      try:
> -        node = repo.branchtip(wc.branch())
> +        node = repo.revs('max(.::(head() and branch("%s")))'
> +                         % wc.branch()).first()
> +        # node = repo.branchtip(wc.branch())

I dropped this commented-out line, made the change Yuya suggested, and
pushed to the clowncopter. Thanks!

Patch

diff --git a/mercurial/destutil.py b/mercurial/destutil.py
--- a/mercurial/destutil.py
+++ b/mercurial/destutil.py
@@ -90,11 +90,13 @@  def _destupdatebook(repo, clean, check):
 def _destupdatebranch(repo, clean, check):
     """decide on an update destination from current branch"""
     wc = repo[None]
     movemark = node = None
     try:
-        node = repo.branchtip(wc.branch())
+        node = repo.revs('max(.::(head() and branch("%s")))'
+                         % wc.branch()).first()
+        # node = repo.branchtip(wc.branch())
         if bookmarks.isactivewdirparent(repo):
             movemark = repo['.'].node()
     except error.RepoLookupError:
         if wc.branch() == 'default': # no default branch!
             node = repo.lookup('tip') # update to tip
diff --git a/tests/test-bookmarks.t b/tests/test-bookmarks.t
--- a/tests/test-bookmarks.t
+++ b/tests/test-bookmarks.t
@@ -733,39 +733,16 @@  tipmost surviving ancestor of the stripp
   o  changeset:   0:f7b1eb17ad24
      user:        test
      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
   parent: 3:9ba5f110a0b3 tip
    y
diff --git a/tests/test-largefiles-cache.t b/tests/test-largefiles-cache.t
--- a/tests/test-largefiles-cache.t
+++ b/tests/test-largefiles-cache.t
@@ -187,11 +187,11 @@  conditional above.
   src/.hg/largefiles/e2fb5f2139d086ded2cb600d5a91a196e76bf020
 
 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
   $ cat .hglf/large
   e2fb5f2139d086ded2cb600d5a91a196e76bf020
diff --git a/tests/test-merge-criss-cross.t b/tests/test-merge-criss-cross.t
--- a/tests/test-merge-criss-cross.t
+++ b/tests/test-merge-criss-cross.t
@@ -210,11 +210,11 @@  Verify how the output looks and and how 
   $ hg up -qC
   $ hg merge
   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
   
   calculating bids for ancestor 0f6b37dbe527
   resolving manifests
diff --git a/tests/test-merge5.t b/tests/test-merge5.t
--- a/tests/test-merge5.t
+++ b/tests/test-merge5.t
@@ -11,22 +11,17 @@ 
   $ hg commit -A -m "comment #2"
   removing b
   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:
 
   $ hg update 1
diff --git a/tests/test-pull-update.t b/tests/test-pull-update.t
--- a/tests/test-pull-update.t
+++ b/tests/test-pull-update.t
@@ -14,37 +14,35 @@ 
 
   $ cd ../t
   $ 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
   searching for changes
   adding changesets
   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
   searching for changes
   adding changesets
   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
   0 files updated, 1 files merged, 0 files removed, 0 files unresolved
   (branch merge, don't forget to commit)
diff --git a/tests/test-up-local-change.t b/tests/test-up-local-change.t
--- a/tests/test-up-local-change.t
+++ b/tests/test-up-local-change.t
@@ -170,13 +170,12 @@  create a second head
   user:        test
   date:        Thu Jan 01 00:00:00 1970 +0000
   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
 
   $ hg up -qC 0
   $ echo untracked > b
diff --git a/tests/test-update-branches.t b/tests/test-update-branches.t
--- a/tests/test-update-branches.t
+++ b/tests/test-update-branches.t
@@ -91,12 +91,12 @@  Cases are run as shown in that table, ro
   $ norevtest 'none clean linear' clean 4
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   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
 
 
   $ revtest 'none clean linear' clean 1 2
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
@@ -138,12 +138,12 @@  Cases are run as shown in that table, ro
   (commit or update --clean to discard changes)
   parent=3
   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
 
   $ revtest 'none dirtysub cross'  dirtysub 3 4
   abort: uncommitted changes
@@ -164,13 +164,13 @@  Cases are run as shown in that table, ro
   abort: uncommitted changes in subrepository 'sub'
   parent=1
   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
   parent=1
   M foo