Patchwork histedit: use the unfiltered repository to get rulectx

login
register
mail settings
Submitter timeless
Date June 3, 2016, 2:54 p.m.
Message ID <bdcf6e2abe8ff449de33.1464965654@gcc2-power8.osuosl.org>
Download mbox | patch
Permalink /patch/15371/
State Changes Requested
Headers show

Comments

timeless - June 3, 2016, 2:54 p.m.
# HG changeset patch
# User timeless <timeless@mozdev.org>
# Date 1464965033 0
#      Fri Jun 03 14:43:53 2016 +0000
# Node ID bdcf6e2abe8ff449de33fb58d2488f7f60564e22
# Parent  9ac309946df9e69bb73ded75f2fc5b84a4e785c2
# Available At https://bitbucket.org/timeless/mercurial-crew
#              hg pull https://bitbucket.org/timeless/mercurial-crew -r bdcf6e2abe8f
histedit: use the unfiltered repository to get rulectx

Without this, histedit fails if a node was pruned.
But histedit just wants the commit info, it does not need to care if
a node is dead or alive.
Jun Wu - June 3, 2016, 6:47 p.m.
I like this change and the code looks good to me.

Excerpts from timeless's message of 2016-06-03 14:54:14 +0000:
> # HG changeset patch
> # User timeless <timeless@mozdev.org>
> # Date 1464965033 0
> #      Fri Jun 03 14:43:53 2016 +0000
> # Node ID bdcf6e2abe8ff449de33fb58d2488f7f60564e22
> # Parent  9ac309946df9e69bb73ded75f2fc5b84a4e785c2
> # Available At https://bitbucket.org/timeless/mercurial-crew 
> #              hg pull https://bitbucket.org/timeless/mercurial-crew  -r bdcf6e2abe8f
> histedit: use the unfiltered repository to get rulectx
> 
> Without this, histedit fails if a node was pruned.
> But histedit just wants the commit info, it does not need to care if
> a node is dead or alive.
Pierre-Yves David - June 3, 2016, 7:22 p.m.
On 06/03/2016 04:54 PM, timeless wrote:
> # HG changeset patch
> # User timeless <timeless@mozdev.org>
> # Date 1464965033 0
> #      Fri Jun 03 14:43:53 2016 +0000
> # Node ID bdcf6e2abe8ff449de33fb58d2488f7f60564e22
> # Parent  9ac309946df9e69bb73ded75f2fc5b84a4e785c2
> # Available At https://bitbucket.org/timeless/mercurial-crew
> #              hg pull https://bitbucket.org/timeless/mercurial-crew -r bdcf6e2abe8f
> histedit: use the unfiltered repository to get rulectx
> 
> Without this, histedit fails if a node was pruned.
> But histedit just wants the commit info, it does not need to care if
> a node is dead or alive.

I'm not super excited by this. This would give histedit access to a
bunch a hidden not possibly silently leading to issue.

The way we have been doing this for rebase (and maybe part of histedit)
is that these command keep a list of involved changesets and these are
prevented from being hidden while the operation proceed.

Cheers,
Augie Fackler - June 4, 2016, 2:28 a.m.
On Fri, Jun 03, 2016 at 09:22:57PM +0200, Pierre-Yves David wrote:
>
>
> On 06/03/2016 04:54 PM, timeless wrote:
> > # HG changeset patch
> > # User timeless <timeless@mozdev.org>
> > # Date 1464965033 0
> > #      Fri Jun 03 14:43:53 2016 +0000
> > # Node ID bdcf6e2abe8ff449de33fb58d2488f7f60564e22
> > # Parent  9ac309946df9e69bb73ded75f2fc5b84a4e785c2
> > # Available At https://bitbucket.org/timeless/mercurial-crew
> > #              hg pull https://bitbucket.org/timeless/mercurial-crew -r bdcf6e2abe8f
> > histedit: use the unfiltered repository to get rulectx
> >
> > Without this, histedit fails if a node was pruned.
> > But histedit just wants the commit info, it does not need to care if
> > a node is dead or alive.
>
> I'm not super excited by this. This would give histedit access to a
> bunch a hidden not possibly silently leading to issue.

I'm inclined to agree with this - it feels wrong to let histedit
potentially create divergence accidentally.

>
> The way we have been doing this for rebase (and maybe part of histedit)
> is that these command keep a list of involved changesets and these are
> prevented from being hidden while the operation proceed.
>
> Cheers,
>
> --
> Pierre-Yves David
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

diff -r 9ac309946df9 -r bdcf6e2abe8f hgext/histedit.py
--- a/hgext/histedit.py	Fri May 27 05:24:45 2016 +0000
+++ b/hgext/histedit.py	Fri Jun 03 14:43:53 2016 +0000
@@ -413,13 +413,17 @@ 
             raise error.ParseError(_('unknown changeset %s listed')
                               % ha[:12])
 
+    def rulectx(self):
+        """Get the rulectx -- even if it's obsolete"""
+        return self.repo.unfiltered()[self.node]
+
     def torule(self, initial=False):
         """build a histedit rule line for an action
 
         by default lines are in the form:
         <hash> <rev> <summary>
         """
-        ctx = self.repo[self.node]
+        ctx = self.rulectx()
         summary = ''
         if ctx.description():
             summary = ctx.description().splitlines()[0]
@@ -468,7 +472,7 @@ 
         """Applies the changes from this action's rulectx onto the current
         parentctx, but does not commit them."""
         repo = self.repo
-        rulectx = repo[self.node]
+        rulectx = self.rulectx()
         repo.ui.pushbuffer(error=True, labeled=True)
         hg.update(repo, self.state.parentctxnode, quietempty=True)
         stats = applychanges(repo.ui, repo, rulectx, {})
@@ -486,7 +490,7 @@ 
         """Continues the action when changes have been applied to the working
         copy. The default behavior is to commit the dirty changes."""
         repo = self.repo
-        rulectx = repo[self.node]
+        rulectx = self.rulectx()
 
         editor = self.commiteditor()
         commit = commitfuncfor(repo, rulectx)
@@ -666,7 +670,7 @@ 
         priority=True)
 class pick(histeditaction):
     def run(self):
-        rulectx = self.repo[self.node]
+        rulectx = self.rulectx()
         if rulectx.parents()[0].node() == self.state.parentctxnode:
             self.repo.ui.debug('node %s unchanged\n' % node.short(self.node))
             return rulectx, []
@@ -679,7 +683,7 @@ 
 class edit(histeditaction):
     def run(self):
         repo = self.repo
-        rulectx = repo[self.node]
+        rulectx = self.rulectx()
         hg.update(repo, self.state.parentctxnode, quietempty=True)
         applychanges(repo.ui, repo, rulectx, {})
         raise error.InterventionRequired(
@@ -698,7 +702,7 @@ 
         super(fold, self).verify(prev)
         repo = self.repo
         if not prev:
-            c = repo[self.node].parents()[0]
+            c = self.rulectx().parents()[0]
         elif not prev.verb in ('pick', 'base'):
             return
         else:
@@ -710,7 +714,7 @@ 
 
     def continuedirty(self):
         repo = self.repo
-        rulectx = repo[self.node]
+        rulectx = self.rulectx()
 
         commit = commitfuncfor(repo, rulectx)
         commit(text='fold-temp-revision %s' % node.short(self.node),
@@ -720,7 +724,7 @@ 
     def continueclean(self):
         repo = self.repo
         ctx = repo['.']
-        rulectx = repo[self.node]
+        rulectx = self.rulectx()
         parentctxnode = self.state.parentctxnode
         if ctx.node() == parentctxnode:
             repo.ui.warn(_('%s: empty changeset\n') %
@@ -1156,6 +1160,7 @@ 
             movebookmarks(ui, repo, mapping, state.topmost, ntm)
             # TODO update mq state
         if supportsmarkers:
+            repo = repo.unfiltered()
             markers = []
             # sort by revision number because it sound "right"
             for prec in sorted(mapping, key=repo.changelog.rev):
diff -r 9ac309946df9 -r bdcf6e2abe8f tests/test-histedit-obsolete.t
--- a/tests/test-histedit-obsolete.t	Fri May 27 05:24:45 2016 +0000
+++ b/tests/test-histedit-obsolete.t	Fri Jun 03 14:43:53 2016 +0000
@@ -88,6 +88,22 @@ 
   2ca853e48edbd6453a0674dc0fe28a0974c51b9c aba7da93703075eec9fb1dbaf143ff2bc1c49d46 0 (*) {'user': 'test'} (glob)
   49d44ab2be1b67a79127568a67c9c99430633b48 273c1f3b86267ed3ec684bb13af1fa4d6ba56e02 0 (*) {'user': 'test'} (glob)
   46abc7c4d8738e8563e577f7889e1b6db3da4199 aba7da93703075eec9fb1dbaf143ff2bc1c49d46 0 (*) {'user': 'test'} (glob)
+
+Test that a pruned leaf does not break histedit
+
+  $ echo pick `hg log -r 8 -T '{node}'` 8 a > plan
+  $ echo edit `hg log -r 9 -T '{node}'` 9 b >> plan
+  $ hg histedit --commands plan 8
+  0 files updated, 0 files merged, 2 files removed, 0 files unresolved
+  adding b
+  adding d
+  Editing (273c1f3b8626), you may commit or record as needed now.
+  (hg histedit --continue to resume)
+  [1]
+  $ hg debugobsolete `hg log -r 9 -T '{node}'`
+  $ hg mv c e
+  $ hg histedit --cont
+
   $ cd ..
 
 Base setup for the rest of the testing