Patchwork [evolve-ext] evolve: current bookmark wrongly moving during prune (issue4559)

login
register
mail settings
Submitter Laurent Charignon
Date May 13, 2015, 5:04 p.m.
Message ID <3dd9da52dd375267fc10.1431536699@lcharignon-mbp.local>
Download mbox | patch
Permalink /patch/9056/
State Accepted
Headers show

Comments

Laurent Charignon - May 13, 2015, 5:04 p.m.
# HG changeset patch
# User Laurent Charignon <lcharignon@fb.com>
# Date 1431532047 25200
#      Wed May 13 08:47:27 2015 -0700
# Node ID 3dd9da52dd375267fc109cedbe908b46dabe6960
# Parent  5e82d78f5872c9503d7b6691c594a13794a9b4a4
evolve: current bookmark wrongly moving during prune (issue4559)

Before this patch: prune -r <otherbookmark> also moved the current bookmark
eventhough it was not related to the pruned changes.
This patch fixes it and adds two tests to catch regressions.
Pierre-Yves David - May 13, 2015, 11:59 p.m.
On 05/13/2015 10:04 AM, Laurent Charignon wrote:
> # HG changeset patch
> # User Laurent Charignon <lcharignon@fb.com>
> # Date 1431532047 25200
> #      Wed May 13 08:47:27 2015 -0700
> # Node ID 3dd9da52dd375267fc109cedbe908b46dabe6960
> # Parent  5e82d78f5872c9503d7b6691c594a13794a9b4a4
> evolve: current bookmark wrongly moving during prune (issue4559)

pushed to main after a couple of changes

>
> Before this patch: prune -r <otherbookmark> also moved the current bookmark
> eventhough it was not related to the pruned changes.
> This patch fixes it and adds two tests to catch regressions.
>
> diff --git a/hgext/evolve.py b/hgext/evolve.py
> --- a/hgext/evolve.py
> +++ b/hgext/evolve.py
> @@ -913,12 +913,8 @@
>       """Return a callable update(newid) updating the current bookmark
>       and bookmarks bound to oldid to newid.
>       """
> -    bm = bmactive(repo)
>       def updatebookmarks(newid):
>           dirty = False
> -        if bm:
> -            repo._bookmarks[bm] = newid
> -            dirty = True
>           oldbookmarks = repo.nodebookmarks(oldid)
>           if oldbookmarks:
>               for b in oldbookmarks:
> diff --git a/tests/test-prune.t b/tests/test-prune.t
> --- a/tests/test-prune.t
> +++ b/tests/test-prune.t
> @@ -317,3 +317,69 @@
>             longer length:              1
>             median length:              1
>             mean length:                1
> +
> +  $ mkcommit rg
> +  created new head
> +  $ hg bookmark rg
> +  $ hg up 10
> +  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
> +  (leaving bookmark rg)
> +  $ hg bookmark r10
> +  $ hg log -G
> +  o  11:cd0038e05e1b[rg] (stable/draft) add rg
> +  |
> +  | @  10:ff43616e5d0f[B r10] (stable/draft) r10
> +  |/
> +  o  8:d62d843c9a01[] (stable/draft) r8
> +  |
> +  o  7:e7d9710d9fc6[] (stable/draft) r7
> +  |
> +  o    3:2b6d669947cd[] (stable/draft) r3
> +  |\
> +  | o  2:fa942426a6fd[] (stable/draft) r2
> +  | |
> +  o |  1:66f7d451a68b[] (stable/draft) r1
> +  |/
> +  o  0:1ea73414a91b[] (stable/draft) r0
> +
> +  $ hg prune 11
> +  1 changesets pruned
> +  $ hg log -G
> +  @  10:ff43616e5d0f[B r10] (stable/draft) r10
> +  |
> +  o  8:d62d843c9a01[rg] (stable/draft) r8
> +  |
> +  o  7:e7d9710d9fc6[] (stable/draft) r7
> +  |
> +  o    3:2b6d669947cd[] (stable/draft) r3
> +  |\
> +  | o  2:fa942426a6fd[] (stable/draft) r2
> +  | |
> +  o |  1:66f7d451a68b[] (stable/draft) r1
> +  |/
> +  o  0:1ea73414a91b[] (stable/draft) r0
> +

> +Pruning r10 should move the active bookmarks below

I've dropped that second tests, it is redundant with pre-existing test 
and its result is very confusing because the prune changeset is kep 
visible by a local-tag.

> +
> +  $ hg prune 10
> +  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
> +  (leaving bookmark r10)

However, you just uncovered another bug. Prune deactivate the active 
bookmark.

Patch

diff --git a/hgext/evolve.py b/hgext/evolve.py
--- a/hgext/evolve.py
+++ b/hgext/evolve.py
@@ -913,12 +913,8 @@ 
     """Return a callable update(newid) updating the current bookmark
     and bookmarks bound to oldid to newid.
     """
-    bm = bmactive(repo)
     def updatebookmarks(newid):
         dirty = False
-        if bm:
-            repo._bookmarks[bm] = newid
-            dirty = True
         oldbookmarks = repo.nodebookmarks(oldid)
         if oldbookmarks:
             for b in oldbookmarks:
diff --git a/tests/test-prune.t b/tests/test-prune.t
--- a/tests/test-prune.t
+++ b/tests/test-prune.t
@@ -317,3 +317,69 @@ 
           longer length:              1
           median length:              1
           mean length:                1
+
+  $ mkcommit rg
+  created new head
+  $ hg bookmark rg
+  $ hg up 10
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  (leaving bookmark rg)
+  $ hg bookmark r10
+  $ hg log -G
+  o  11:cd0038e05e1b[rg] (stable/draft) add rg
+  |
+  | @  10:ff43616e5d0f[B r10] (stable/draft) r10
+  |/
+  o  8:d62d843c9a01[] (stable/draft) r8
+  |
+  o  7:e7d9710d9fc6[] (stable/draft) r7
+  |
+  o    3:2b6d669947cd[] (stable/draft) r3
+  |\
+  | o  2:fa942426a6fd[] (stable/draft) r2
+  | |
+  o |  1:66f7d451a68b[] (stable/draft) r1
+  |/
+  o  0:1ea73414a91b[] (stable/draft) r0
+  
+  $ hg prune 11
+  1 changesets pruned
+  $ hg log -G
+  @  10:ff43616e5d0f[B r10] (stable/draft) r10
+  |
+  o  8:d62d843c9a01[rg] (stable/draft) r8
+  |
+  o  7:e7d9710d9fc6[] (stable/draft) r7
+  |
+  o    3:2b6d669947cd[] (stable/draft) r3
+  |\
+  | o  2:fa942426a6fd[] (stable/draft) r2
+  | |
+  o |  1:66f7d451a68b[] (stable/draft) r1
+  |/
+  o  0:1ea73414a91b[] (stable/draft) r0
+  
+Pruning r10 should move the active bookmarks below
+ 
+  $ hg prune 10
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  (leaving bookmark r10)
+  working directory now at d62d843c9a01
+  1 changesets pruned
+  $ hg log -G
+  x  10:ff43616e5d0f[] (extinct/draft) r10
+  |
+  @  8:d62d843c9a01[B r10 rg] (stable/draft) r8
+  |
+  o  7:e7d9710d9fc6[] (stable/draft) r7
+  |
+  o    3:2b6d669947cd[] (stable/draft) r3
+  |\
+  | o  2:fa942426a6fd[] (stable/draft) r2
+  | |
+  o |  1:66f7d451a68b[] (stable/draft) r1
+  |/
+  o  0:1ea73414a91b[] (stable/draft) r0
+  
+
+