Patchwork [2,of,2,fix] rebase: properly handle chain of marker with missing node

login
register
mail settings
Submitter Pierre-Yves David
Date Oct. 14, 2015, 11:57 p.m.
Message ID <a53d0a524cf14db2ce63.1444867056@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/11087/
State Accepted
Headers show

Comments

Pierre-Yves David - Oct. 14, 2015, 11:57 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1444865540 -3600
#      Thu Oct 15 00:32:20 2015 +0100
# Node ID a53d0a524cf14db2ce63b8376020e22dd4f2e636
# Parent  d2dd179568f5aa46ffc597a393f2df663a4893af
# EXP-Topic reb.skip
# Available At http://hg.netv6.net/marmoute-wip/mercurial/
#              hg pull http://hg.netv6.net/marmoute-wip/mercurial/ -r a53d0a524cf1
rebase: properly handle chain of marker with missing node

As obsolescence markers can contains unknown nodes and 'allsuccessors' returns
them, we have to protect again that when looking for successors of the rebase
set in the destination.

Test have been expanded to catch that.
Sean Farley - Oct. 15, 2015, 12:20 a.m.
Pierre-Yves David <pierre-yves.david@ens-lyon.org> writes:

> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@fb.com>
> # Date 1444865540 -3600
> #      Thu Oct 15 00:32:20 2015 +0100
> # Node ID a53d0a524cf14db2ce63b8376020e22dd4f2e636
> # Parent  d2dd179568f5aa46ffc597a393f2df663a4893af
> # EXP-Topic reb.skip
> # Available At http://hg.netv6.net/marmoute-wip/mercurial/
> #              hg pull http://hg.netv6.net/marmoute-wip/mercurial/ -r a53d0a524cf1
> rebase: properly handle chain of marker with missing node
>
> As obsolescence markers can contains unknown nodes and 'allsuccessors' returns
> them, we have to protect again that when looking for successors of the rebase
> set in the destination.
>
> Test have been expanded to catch that.
>
> diff --git a/hgext/rebase.py b/hgext/rebase.py
> --- a/hgext/rebase.py
> +++ b/hgext/rebase.py
> @@ -1162,11 +1162,14 @@ def _computeobsoletenotrebased(repo, reb
>      for r in rebasesetrevs:
>          n = repo[r]
>          if n.obsolete():
>              node = cl.node(r)
>              for s in obsolete.allsuccessors(repo.obsstore, [node]):
> -                allsuccessors[cl.rev(s)] = cl.rev(node)
> +                try:
> +                    allsuccessors[cl.rev(s)] = cl.rev(node)
> +                except LookupError:
> +                    pass
>  
>      if allsuccessors:
>          # Look for successors of obsolete nodes to be rebased among
>          # the ancestors of dest
>          ancs = cl.ancestors([repo[dest].rev()],
> diff --git a/tests/test-rebase-obsolete.t b/tests/test-rebase-obsolete.t
> --- a/tests/test-rebase-obsolete.t
> +++ b/tests/test-rebase-obsolete.t
> @@ -588,5 +588,53 @@ Test hidden changesets in the rebase set
>    
>    $ hg rebase -s 14 -d 18 --config experimental.rebaseskipobsolete=True
>    note: not rebasing 14:9ad579b4a5de "I", already in destination as 17:fc37a630c901 "K"
>    rebasing 15:5ae8a643467b "J"
>  
> +  $ cd ..
> +
> +Skip obsolete changeset even with multiple hope

multiple hop(s)?
Pierre-Yves David - Oct. 15, 2015, 12:24 a.m.
On 10/15/2015 01:20 AM, Sean Farley wrote:
>
> Pierre-Yves David <pierre-yves.david@ens-lyon.org> writes:
>
>> # HG changeset patch
>> # User Pierre-Yves David <pierre-yves.david@fb.com>
>> # Date 1444865540 -3600
>> #      Thu Oct 15 00:32:20 2015 +0100
>> # Node ID a53d0a524cf14db2ce63b8376020e22dd4f2e636
>> # Parent  d2dd179568f5aa46ffc597a393f2df663a4893af
>> # EXP-Topic reb.skip
>> # Available At http://hg.netv6.net/marmoute-wip/mercurial/
>> #              hg pull http://hg.netv6.net/marmoute-wip/mercurial/ -r a53d0a524cf1
>> rebase: properly handle chain of marker with missing node
>>
>> As obsolescence markers can contains unknown nodes and 'allsuccessors' returns
>> them, we have to protect again that when looking for successors of the rebase
>> set in the destination.
>>
>> Test have been expanded to catch that.
>>
>> diff --git a/hgext/rebase.py b/hgext/rebase.py
>> --- a/hgext/rebase.py
>> +++ b/hgext/rebase.py
>> @@ -1162,11 +1162,14 @@ def _computeobsoletenotrebased(repo, reb
>>       for r in rebasesetrevs:
>>           n = repo[r]
>>           if n.obsolete():
>>               node = cl.node(r)
>>               for s in obsolete.allsuccessors(repo.obsstore, [node]):
>> -                allsuccessors[cl.rev(s)] = cl.rev(node)
>> +                try:
>> +                    allsuccessors[cl.rev(s)] = cl.rev(node)
>> +                except LookupError:
>> +                    pass
>>
>>       if allsuccessors:
>>           # Look for successors of obsolete nodes to be rebased among
>>           # the ancestors of dest
>>           ancs = cl.ancestors([repo[dest].rev()],
>> diff --git a/tests/test-rebase-obsolete.t b/tests/test-rebase-obsolete.t
>> --- a/tests/test-rebase-obsolete.t
>> +++ b/tests/test-rebase-obsolete.t
>> @@ -588,5 +588,53 @@ Test hidden changesets in the rebase set
>>
>>     $ hg rebase -s 14 -d 18 --config experimental.rebaseskipobsolete=True
>>     note: not rebasing 14:9ad579b4a5de "I", already in destination as 17:fc37a630c901 "K"
>>     rebasing 15:5ae8a643467b "J"
>>
>> +  $ cd ..
>> +
>> +Skip obsolete changeset even with multiple hope
>
> multiple hop(s)?

groomphs, yes. multiple hops.
Augie Fackler - Oct. 15, 2015, 1:06 p.m.
On Thu, Oct 15, 2015 at 12:57:36AM +0100, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@fb.com>
> # Date 1444865540 -3600
> #      Thu Oct 15 00:32:20 2015 +0100
> # Node ID a53d0a524cf14db2ce63b8376020e22dd4f2e636
> # Parent  d2dd179568f5aa46ffc597a393f2df663a4893af
> # EXP-Topic reb.skip
> # Available At http://hg.netv6.net/marmoute-wip/mercurial/
> #              hg pull http://hg.netv6.net/marmoute-wip/mercurial/ -r a53d0a524cf1
> rebase: properly handle chain of marker with missing node

queued, thanks

>
> As obsolescence markers can contains unknown nodes and 'allsuccessors' returns
> them, we have to protect again that when looking for successors of the rebase
> set in the destination.
>
> Test have been expanded to catch that.
>
> diff --git a/hgext/rebase.py b/hgext/rebase.py
> --- a/hgext/rebase.py
> +++ b/hgext/rebase.py
> @@ -1162,11 +1162,14 @@ def _computeobsoletenotrebased(repo, reb
>      for r in rebasesetrevs:
>          n = repo[r]
>          if n.obsolete():
>              node = cl.node(r)
>              for s in obsolete.allsuccessors(repo.obsstore, [node]):
> -                allsuccessors[cl.rev(s)] = cl.rev(node)
> +                try:
> +                    allsuccessors[cl.rev(s)] = cl.rev(node)
> +                except LookupError:
> +                    pass
>
>      if allsuccessors:
>          # Look for successors of obsolete nodes to be rebased among
>          # the ancestors of dest
>          ancs = cl.ancestors([repo[dest].rev()],
> diff --git a/tests/test-rebase-obsolete.t b/tests/test-rebase-obsolete.t
> --- a/tests/test-rebase-obsolete.t
> +++ b/tests/test-rebase-obsolete.t
> @@ -588,5 +588,53 @@ Test hidden changesets in the rebase set
>
>    $ hg rebase -s 14 -d 18 --config experimental.rebaseskipobsolete=True
>    note: not rebasing 14:9ad579b4a5de "I", already in destination as 17:fc37a630c901 "K"
>    rebasing 15:5ae8a643467b "J"
>
> +  $ cd ..
> +
> +Skip obsolete changeset even with multiple hope
> +-----------------------------------------------
> +
> +setup
> +
> +  $ hg init obsskip
> +  $ cd obsskip
> +  $ cat << EOF >> .hg/hgrc
> +  > [experimental]
> +  > rebaseskipobsolete = True
> +  > [extensions]
> +  > strip =
> +  > EOF
> +  $ echo A > A
> +  $ hg add A
> +  $ hg commit -m A
> +  $ echo B > B
> +  $ hg add B
> +  $ hg commit -m B0
> +  $ hg commit --amend -m B1
> +  $ hg commit --amend -m B2
> +  $ hg up --hidden 'desc(B0)'
> +  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
> +  $ echo C > C
> +  $ hg add C
> +  $ hg commit -m C
> +
> +Rebase finds its way in a chain of marker
> +
> +  $ hg rebase -d 'desc(B2)'
> +  note: not rebasing 1:a8b11f55fb19 "B0", already in destination as 3:261e70097290 "B2"
> +  rebasing 4:212cb178bcbb "C" (tip)
> +
> +Even when the chain include missing node
> +
> +  $ hg up --hidden 'desc(B0)'
> +  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
> +  $ echo D > D
> +  $ hg add D
> +  $ hg commit -m D
> +  $ hg --hidden strip -r 'desc(B1)'
> +  saved backup bundle to $TESTTMP/obsskip/.hg/strip-backup/86f6414ccda7-b1c452ee-backup.hg (glob)
> +
> +  $ hg rebase -d 'desc(B2)'
> +  note: not rebasing 1:a8b11f55fb19 "B0", already in destination as 2:261e70097290 "B2"
> +  rebasing 5:1a79b7535141 "D" (tip)
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> https://selenic.com/mailman/listinfo/mercurial-devel

Patch

diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -1162,11 +1162,14 @@  def _computeobsoletenotrebased(repo, reb
     for r in rebasesetrevs:
         n = repo[r]
         if n.obsolete():
             node = cl.node(r)
             for s in obsolete.allsuccessors(repo.obsstore, [node]):
-                allsuccessors[cl.rev(s)] = cl.rev(node)
+                try:
+                    allsuccessors[cl.rev(s)] = cl.rev(node)
+                except LookupError:
+                    pass
 
     if allsuccessors:
         # Look for successors of obsolete nodes to be rebased among
         # the ancestors of dest
         ancs = cl.ancestors([repo[dest].rev()],
diff --git a/tests/test-rebase-obsolete.t b/tests/test-rebase-obsolete.t
--- a/tests/test-rebase-obsolete.t
+++ b/tests/test-rebase-obsolete.t
@@ -588,5 +588,53 @@  Test hidden changesets in the rebase set
   
   $ hg rebase -s 14 -d 18 --config experimental.rebaseskipobsolete=True
   note: not rebasing 14:9ad579b4a5de "I", already in destination as 17:fc37a630c901 "K"
   rebasing 15:5ae8a643467b "J"
 
+  $ cd ..
+
+Skip obsolete changeset even with multiple hope
+-----------------------------------------------
+
+setup
+
+  $ hg init obsskip
+  $ cd obsskip
+  $ cat << EOF >> .hg/hgrc
+  > [experimental]
+  > rebaseskipobsolete = True
+  > [extensions]
+  > strip =
+  > EOF
+  $ echo A > A
+  $ hg add A
+  $ hg commit -m A
+  $ echo B > B
+  $ hg add B
+  $ hg commit -m B0
+  $ hg commit --amend -m B1
+  $ hg commit --amend -m B2
+  $ hg up --hidden 'desc(B0)'
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ echo C > C
+  $ hg add C
+  $ hg commit -m C
+
+Rebase finds its way in a chain of marker
+
+  $ hg rebase -d 'desc(B2)'
+  note: not rebasing 1:a8b11f55fb19 "B0", already in destination as 3:261e70097290 "B2"
+  rebasing 4:212cb178bcbb "C" (tip)
+
+Even when the chain include missing node
+
+  $ hg up --hidden 'desc(B0)'
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  $ echo D > D
+  $ hg add D
+  $ hg commit -m D
+  $ hg --hidden strip -r 'desc(B1)'
+  saved backup bundle to $TESTTMP/obsskip/.hg/strip-backup/86f6414ccda7-b1c452ee-backup.hg (glob)
+
+  $ hg rebase -d 'desc(B2)'
+  note: not rebasing 1:a8b11f55fb19 "B0", already in destination as 2:261e70097290 "B2"
+  rebasing 5:1a79b7535141 "D" (tip)