Patchwork [3,of,3,V2] pull: deactivate a bookmark not matching with the destination of the update

login
register
mail settings
Submitter Katsunori FUJIWARA
Date Feb. 26, 2016, 11:25 a.m.
Message ID <351794f863dbd56fa787.1456485928@feefifofum>
Download mbox | patch
Permalink /patch/13403/
State Accepted
Delegated to: Pierre-Yves David
Headers show

Comments

Katsunori FUJIWARA - Feb. 26, 2016, 11:25 a.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1456485725 -32400
#      Fri Feb 26 20:22:05 2016 +0900
# Node ID 351794f863dbd56fa787714bb1986da2b506ace4
# Parent  8bc889107331ed73969ec1e5364bdd380f736299
pull: deactivate a bookmark not matching with the destination of the update

Before this patch, "hg pull -u" doesn't deactivate a current active
bookmark, which doesn't match with the explicit destination of the
update, even though bare "hg update" does so.
Pierre-Yves David - Feb. 27, 2016, 1:38 p.m.
On 02/26/2016 12:25 PM, FUJIWARA Katsunori wrote:
> # HG changeset patch
> # User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
> # Date 1456485725 -32400
> #      Fri Feb 26 20:22:05 2016 +0900
> # Node ID 351794f863dbd56fa787714bb1986da2b506ace4
> # Parent  8bc889107331ed73969ec1e5364bdd380f736299
> pull: deactivate a bookmark not matching with the destination of the update
>
> Before this patch, "hg pull -u" doesn't deactivate a current active
> bookmark, which doesn't match with the explicit destination of the
> update, even though bare "hg update" does so.

Same as with previous patch:

In practice, it looks like your are talking about:

'hg pull -u --rev bmname'

am I right? if so, we should probably update the commit message to have 
the '--rev bmname' bits

This seems to also apply to `hg pull -u URL#bmname too.

If so, I think the change make sense (probably requires a BC) flagging.

If you agree with the aboves, we can probably update the message in flight.
Katsunori FUJIWARA - Feb. 27, 2016, 3:46 p.m.
At Sat, 27 Feb 2016 14:38:25 +0100,
Pierre-Yves David wrote:
> 
> On 02/26/2016 12:25 PM, FUJIWARA Katsunori wrote:
> > # HG changeset patch
> > # User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
> > # Date 1456485725 -32400
> > #      Fri Feb 26 20:22:05 2016 +0900
> > # Node ID 351794f863dbd56fa787714bb1986da2b506ace4
> > # Parent  8bc889107331ed73969ec1e5364bdd380f736299
> > pull: deactivate a bookmark not matching with the destination of the update
> >
> > Before this patch, "hg pull -u" doesn't deactivate a current active
> > bookmark, which doesn't match with the explicit destination of the
> > update, even though bare "hg update" does so.
> 
> Same as with previous patch:
> 
> In practice, it looks like your are talking about:
> 
> 'hg pull -u --rev bmname'
> 
> am I right? if so, we should probably update the commit message to have 
> the '--rev bmname' bits
> 
> This seems to also apply to `hg pull -u URL#bmname too.

Yes, this patch focuses on "hg pull -u" with argument below (ANOTHER
should be different from current active bookmark name):

  - option --rev ANOTHER
  - option --branch ANOTHER
  - source URL#ANOTHER


> If so, I think the change make sense (probably requires a BC) flagging.
> 
> If you agree with the aboves, we can probably update the message in flight.

Please do so.
 
> -- 
> Pierre-Yves David
> 

----------------------------------------------------------------------
[FUJIWARA Katsunori]                             foozy@lares.dti.ne.jp
Pierre-Yves David - Feb. 27, 2016, 3:55 p.m.
On 02/27/2016 04:46 PM, FUJIWARA Katsunori wrote:
> At Sat, 27 Feb 2016 14:38:25 +0100,
> Pierre-Yves David wrote:
>>
>> On 02/26/2016 12:25 PM, FUJIWARA Katsunori wrote:
>>> # HG changeset patch
>>> # User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
>>> # Date 1456485725 -32400
>>> #      Fri Feb 26 20:22:05 2016 +0900
>>> # Node ID 351794f863dbd56fa787714bb1986da2b506ace4
>>> # Parent  8bc889107331ed73969ec1e5364bdd380f736299
>>> pull: deactivate a bookmark not matching with the destination of the update
>>>
>>> Before this patch, "hg pull -u" doesn't deactivate a current active
>>> bookmark, which doesn't match with the explicit destination of the
>>> update, even though bare "hg update" does so.
>>
>> Same as with previous patch:
>>
>> In practice, it looks like your are talking about:
>>
>> 'hg pull -u --rev bmname'
>>
>> am I right? if so, we should probably update the commit message to have
>> the '--rev bmname' bits
>>
>> This seems to also apply to `hg pull -u URL#bmname too.
>
> Yes, this patch focuses on "hg pull -u" with argument below (ANOTHER
> should be different from current active bookmark name):
>
>    - option --rev ANOTHER
>    - option --branch ANOTHER
>    - source URL#ANOTHER
>
>
>> If so, I think the change make sense (probably requires a BC) flagging.
>>
>> If you agree with the aboves, we can probably update the message in flight.
>
> Please do so.

I did just pushed them.

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -5570,6 +5570,11 @@  def postincoming(ui, repo, modheads, opt
             if brev != repo._activebookmark:
                 ui.status(_("(activating bookmark %s)\n") % brev)
             bookmarks.activate(repo, brev)
+        elif brev:
+            if repo._activebookmark:
+                ui.status(_("(leaving bookmark %s)\n") %
+                          repo._activebookmark)
+            bookmarks.deactivate(repo)
         return ret
     if modheads > 1:
         currentbranchheads = len(repo.branchheads())
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
@@ -123,4 +123,92 @@  explicit destination of the update.
    * active-after-pull         4:f815b3da6163
      active-before-pull        3:483b76ad4309
 
+(discard pulled changes)
+
+  $ hg update -q 483b76ad4309
+  $ hg rollback -q
+
+Test that updating deactivates current active bookmark, if the
+destination of the update is explicitly specified, and it doesn't
+match with the name of any exsiting bookmarks.
+
+  $ cd ../t
+  $ hg bookmark -d active-after-pull
+  $ hg branch bar -q
+  $ hg commit -m "#5 (bar #1)"
+  $ cd ../tt
+
+(1) deactivating by --rev REV
+
+  $ hg bookmark -f active-before-pull
+  $ hg bookmarks
+   * active-before-pull        3:483b76ad4309
+
+  $ hg pull -u -r b5e4babfaaa7
+  pulling from $TESTTMP/t (glob)
+  searching for changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 2 changesets with 1 changes to 1 files
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  (leaving bookmark active-before-pull)
+
+  $ hg parents -q
+  5:b5e4babfaaa7
+  $ hg bookmarks
+     active-before-pull        3:483b76ad4309
+
+(discard pulled changes)
+
+  $ hg update -q 483b76ad4309
+  $ hg rollback -q
+
+(2) deactivating by --branch BRANCH
+
+  $ hg bookmark -f active-before-pull
+  $ hg bookmarks
+   * active-before-pull        3:483b76ad4309
+
+  $ hg pull -u -b bar
+  pulling from $TESTTMP/t (glob)
+  searching for changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 2 changesets with 1 changes to 1 files
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  (leaving bookmark active-before-pull)
+
+  $ hg parents -q
+  5:b5e4babfaaa7
+  $ hg bookmarks
+     active-before-pull        3:483b76ad4309
+
+(discard pulled changes)
+
+  $ hg update -q 483b76ad4309
+  $ hg rollback -q
+
+(3) deactivating by URL#ANOTHER-BRANCH
+
+  $ hg bookmark -f active-before-pull
+  $ hg bookmarks
+   * active-before-pull        3:483b76ad4309
+
+  $ hg pull -u $TESTTMP/t#bar
+  pulling from $TESTTMP/t (glob)
+  searching for changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 2 changesets with 1 changes to 1 files
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  (leaving bookmark active-before-pull)
+
+  $ hg parents -q
+  5:b5e4babfaaa7
+  $ hg bookmarks
+     active-before-pull        3:483b76ad4309
+
   $ cd ..