Patchwork rebase: abort if *any* commit in rebase set is public

login
register
mail settings
Submitter via Mercurial-devel
Date March 11, 2017, 6:47 p.m.
Message ID <de5616a5d81c49449fde.1489258045@martinvonz.mtv.corp.google.com>
Download mbox | patch
Permalink /patch/19098/
State Accepted
Headers show

Comments

via Mercurial-devel - March 11, 2017, 6:47 p.m.
# HG changeset patch
# User Martin von Zweigbergk <martinvonz@google.com>
# Date 1489257344 28800
#      Sat Mar 11 10:35:44 2017 -0800
# Node ID de5616a5d81c49449fdebc80af76b15ed5adc795
# Parent  c134a33b1d73896a616475127797ad7fcfa0608d
rebase: abort if *any* commit in rebase set is public
Yuya Nishihara - March 11, 2017, 7:56 p.m.
On Sat, 11 Mar 2017 10:47:25 -0800, Martin von Zweigbergk via Mercurial-devel wrote:
> # HG changeset patch
> # User Martin von Zweigbergk <martinvonz@google.com>
> # Date 1489257344 28800
> #      Sat Mar 11 10:35:44 2017 -0800
> # Node ID de5616a5d81c49449fdebc80af76b15ed5adc795
> # Parent  c134a33b1d73896a616475127797ad7fcfa0608d
> rebase: abort if *any* commit in rebase set is public

Good catch. Queued, thanks.

> --- a/hgext/rebase.py	Wed Mar 01 16:19:41 2017 -0800
> +++ b/hgext/rebase.py	Sat Mar 11 10:35:44 2017 -0800
> @@ -326,11 +326,11 @@
>              self.ui.status(_('nothing to rebase\n'))
>              return _nothingtorebase()
>  
> -        root = min(rebaseset)
> -        if not self.keepf and not self.repo[root].mutable():
> -            raise error.Abort(_("can't rebase public changeset %s")
> -                             % self.repo[root],
> -                             hint=_("see 'hg help phases' for details"))
> +        for root in self.repo.set('roots(%ld)', rebaseset):
> +            if not self.keepf and not self.repo[root].mutable():
> +                raise error.Abort(_("can't rebase public changeset %s")
> +                                 % self.repo[root],
> +                                 hint=_("see 'hg help phases' for details"))

repo.set() yields context objects, so repo[root] isn't necessary. Fixed in
flight.
via Mercurial-devel - March 11, 2017, 8:03 p.m.
On Sat, Mar 11, 2017 at 11:56 AM, Yuya Nishihara <yuya@tcha.org> wrote:
> On Sat, 11 Mar 2017 10:47:25 -0800, Martin von Zweigbergk via Mercurial-devel wrote:
>> # HG changeset patch
>> # User Martin von Zweigbergk <martinvonz@google.com>
>> # Date 1489257344 28800
>> #      Sat Mar 11 10:35:44 2017 -0800
>> # Node ID de5616a5d81c49449fdebc80af76b15ed5adc795
>> # Parent  c134a33b1d73896a616475127797ad7fcfa0608d
>> rebase: abort if *any* commit in rebase set is public
>
> Good catch. Queued, thanks.
>
>> --- a/hgext/rebase.py Wed Mar 01 16:19:41 2017 -0800
>> +++ b/hgext/rebase.py Sat Mar 11 10:35:44 2017 -0800
>> @@ -326,11 +326,11 @@
>>              self.ui.status(_('nothing to rebase\n'))
>>              return _nothingtorebase()
>>
>> -        root = min(rebaseset)
>> -        if not self.keepf and not self.repo[root].mutable():
>> -            raise error.Abort(_("can't rebase public changeset %s")
>> -                             % self.repo[root],
>> -                             hint=_("see 'hg help phases' for details"))
>> +        for root in self.repo.set('roots(%ld)', rebaseset):
>> +            if not self.keepf and not self.repo[root].mutable():
>> +                raise error.Abort(_("can't rebase public changeset %s")
>> +                                 % self.repo[root],
>> +                                 hint=_("see 'hg help phases' for details"))
>
> repo.set() yields context objects, so repo[root] isn't necessary. Fixed in
> flight.

Oops, I think I meant to use repo.revs(), but set() is actually better
with your fix on top. Thanks!

Patch

diff -r c134a33b1d73 -r de5616a5d81c hgext/rebase.py
--- a/hgext/rebase.py	Wed Mar 01 16:19:41 2017 -0800
+++ b/hgext/rebase.py	Sat Mar 11 10:35:44 2017 -0800
@@ -326,11 +326,11 @@ 
             self.ui.status(_('nothing to rebase\n'))
             return _nothingtorebase()
 
-        root = min(rebaseset)
-        if not self.keepf and not self.repo[root].mutable():
-            raise error.Abort(_("can't rebase public changeset %s")
-                             % self.repo[root],
-                             hint=_("see 'hg help phases' for details"))
+        for root in self.repo.set('roots(%ld)', rebaseset):
+            if not self.keepf and not self.repo[root].mutable():
+                raise error.Abort(_("can't rebase public changeset %s")
+                                 % self.repo[root],
+                                 hint=_("see 'hg help phases' for details"))
 
         (self.originalwd, self.target, self.state) = result
         if self.collapsef:
diff -r c134a33b1d73 -r de5616a5d81c tests/test-rebase-scenario-global.t
--- a/tests/test-rebase-scenario-global.t	Wed Mar 01 16:19:41 2017 -0800
+++ b/tests/test-rebase-scenario-global.t	Sat Mar 11 10:35:44 2017 -0800
@@ -329,6 +329,10 @@ 
   abort: can't rebase public changeset e1c4361dd923
   (see 'hg help phases' for details)
   [255]
+  $ hg rebase -d 5 -r '1 + (6::)'
+  abort: can't rebase public changeset e1c4361dd923
+  (see 'hg help phases' for details)
+  [255]
 
   $ hg rebase -d 5 -b 6 --keep
   rebasing 6:e1c4361dd923 "C"