Patchwork [v3] commit: block amend while histedit is in progress (issue4800)

login
register
mail settings
Submitter timeless@mozdev.org
Date March 2, 2016, 10:55 p.m.
Message ID <31b049d11a8f1ba111eb.1456959316@waste.org>
Download mbox | patch
Permalink /patch/13574/
State Accepted
Commit f6b5b041c6c9a0d33bbc4115d47cafc4ff701411
Delegated to: Yuya Nishihara
Headers show

Comments

timeless@mozdev.org - March 2, 2016, 10:55 p.m.
# HG changeset patch
# User timeless <timeless@mozdev.org>
# Date 1455435350 0
#      Sun Feb 14 07:35:50 2016 +0000
# Node ID 31b049d11a8f1ba111eb91d0c41a13a8f3b1c253
# Parent  c7f89ad87baef87f00c507545dfd4cc824bc3131
commit: block amend while histedit is in progress (issue4800)
Yuya Nishihara - March 5, 2016, 8:14 a.m.
On Wed, 02 Mar 2016 16:55:16 -0600, timeless wrote:
> # HG changeset patch
> # User timeless <timeless@mozdev.org>
> # Date 1455435350 0
> #      Sun Feb 14 07:35:50 2016 +0000
> # Node ID 31b049d11a8f1ba111eb91d0c41a13a8f3b1c253
> # Parent  c7f89ad87baef87f00c507545dfd4cc824bc3131
> commit: block amend while histedit is in progress (issue4800)

I'm confused. The issue4800 is marked as resolved. Are there the other ways
to reproduce the problem?

https://bz.mercurial-scm.org/show_bug.cgi?id=4800#c12
Augie Fackler - March 8, 2016, 2:08 a.m.
On Wed, Mar 02, 2016 at 04:55:16PM -0600, timeless wrote:
> # HG changeset patch
> # User timeless <timeless@mozdev.org>
> # Date 1455435350 0
> #      Sun Feb 14 07:35:50 2016 +0000
> # Node ID 31b049d11a8f1ba111eb91d0c41a13a8f3b1c253
> # Parent  c7f89ad87baef87f00c507545dfd4cc824bc3131
> commit: block amend while histedit is in progress (issue4800)

queued this, thanks

>
> diff --git a/mercurial/commands.py b/mercurial/commands.py
> --- a/mercurial/commands.py
> +++ b/mercurial/commands.py
> @@ -1682,6 +1682,15 @@
>          if not allowunstable and old.children():
>              raise error.Abort(_('cannot amend changeset with children'))
>
> +        # Currently histedit gets confused if an amend happens while histedit
> +        # is in progress. Since we have a checkunfinished command, we are
> +        # temporarily honoring it.
> +        #
> +        # Note: eventually this guard will be removed. Please do not expect
> +        # this behavior to remain.
> +        if not obsolete.isenabled(repo, obsolete.createmarkersopt):
> +            cmdutil.checkunfinished(repo)
> +
>          # commitfunc is used only for temporary amend commit by cmdutil.amend
>          def commitfunc(ui, repo, message, match, opts):
>              return repo.commit(message,
> diff --git a/tests/test-histedit-arguments.t b/tests/test-histedit-arguments.t
> --- a/tests/test-histedit-arguments.t
> +++ b/tests/test-histedit-arguments.t
> @@ -450,3 +450,46 @@
>    > pick 6f2f0241f119
>    > pick 8cde254db839
>    > EOF
> +
> +commit --amend should abort if histedit is in progress
> +(issue4800) and markers are not being created.
> +Eventually, histedit could perhaps look at `source` extra,
> +in which case this test should be revisited.
> +
> +  $ hg -q up 8cde254db839
> +  $ hg histedit 6f2f0241f119 --commands - <<EOF
> +  > pick 8cde254db839
> +  > edit 6f2f0241f119
> +  > EOF
> +  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
> +  merging foo
> +  warning: conflicts while merging foo! (edit, then use 'hg resolve --mark')
> +  Fix up the change (pick 8cde254db839)
> +  (hg histedit --continue to resume)
> +  [1]
> +  $ hg resolve -m --all
> +  (no more unresolved files)
> +  continue: hg histedit --continue
> +  $ hg histedit --cont
> +  merging foo
> +  warning: conflicts while merging foo! (edit, then use 'hg resolve --mark')
> +  Editing (6f2f0241f119), you may commit or record as needed now.
> +  (hg histedit --continue to resume)
> +  [1]
> +  $ hg resolve -m --all
> +  (no more unresolved files)
> +  continue: hg histedit --continue
> +  $ hg commit --amend -m 'reject this fold'
> +  abort: histedit in progress
> +  (use 'hg histedit --continue' or 'hg histedit --abort')
> +  [255]
> +
> +With markers enabled, histedit does not get confused, and
> +amend should not be blocked by the ongoing histedit.
> +
> +  $ cat >>$HGRCPATH <<EOF
> +  > [experimental]
> +  > evolution=createmarkers,allowunstable
> +  > EOF
> +  $ hg commit --amend -m 'allow this fold'
> +  $ hg histedit --continue
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Pierre-Yves David - March 8, 2016, 12:13 p.m.
On 03/05/2016 09:14 AM, Yuya Nishihara wrote:
> On Wed, 02 Mar 2016 16:55:16 -0600, timeless wrote:
>> # HG changeset patch
>> # User timeless <timeless@mozdev.org>
>> # Date 1455435350 0
>> #      Sun Feb 14 07:35:50 2016 +0000
>> # Node ID 31b049d11a8f1ba111eb91d0c41a13a8f3b1c253
>> # Parent  c7f89ad87baef87f00c507545dfd4cc824bc3131
>> commit: block amend while histedit is in progress (issue4800)
>
> I'm confused. The issue4800 is marked as resolved. Are there the other ways
> to reproduce the problem?
>
> https://bz.mercurial-scm.org/show_bug.cgi?id=4800#c12

It was resolved for people using evolution. It was still broken for 
every other users :-/

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -1682,6 +1682,15 @@ 
         if not allowunstable and old.children():
             raise error.Abort(_('cannot amend changeset with children'))
 
+        # Currently histedit gets confused if an amend happens while histedit
+        # is in progress. Since we have a checkunfinished command, we are
+        # temporarily honoring it.
+        #
+        # Note: eventually this guard will be removed. Please do not expect
+        # this behavior to remain.
+        if not obsolete.isenabled(repo, obsolete.createmarkersopt):
+            cmdutil.checkunfinished(repo)
+
         # commitfunc is used only for temporary amend commit by cmdutil.amend
         def commitfunc(ui, repo, message, match, opts):
             return repo.commit(message,
diff --git a/tests/test-histedit-arguments.t b/tests/test-histedit-arguments.t
--- a/tests/test-histedit-arguments.t
+++ b/tests/test-histedit-arguments.t
@@ -450,3 +450,46 @@ 
   > pick 6f2f0241f119
   > pick 8cde254db839
   > EOF
+
+commit --amend should abort if histedit is in progress
+(issue4800) and markers are not being created.
+Eventually, histedit could perhaps look at `source` extra,
+in which case this test should be revisited.
+
+  $ hg -q up 8cde254db839
+  $ hg histedit 6f2f0241f119 --commands - <<EOF
+  > pick 8cde254db839
+  > edit 6f2f0241f119
+  > EOF
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  merging foo
+  warning: conflicts while merging foo! (edit, then use 'hg resolve --mark')
+  Fix up the change (pick 8cde254db839)
+  (hg histedit --continue to resume)
+  [1]
+  $ hg resolve -m --all
+  (no more unresolved files)
+  continue: hg histedit --continue
+  $ hg histedit --cont
+  merging foo
+  warning: conflicts while merging foo! (edit, then use 'hg resolve --mark')
+  Editing (6f2f0241f119), you may commit or record as needed now.
+  (hg histedit --continue to resume)
+  [1]
+  $ hg resolve -m --all
+  (no more unresolved files)
+  continue: hg histedit --continue
+  $ hg commit --amend -m 'reject this fold'
+  abort: histedit in progress
+  (use 'hg histedit --continue' or 'hg histedit --abort')
+  [255]
+
+With markers enabled, histedit does not get confused, and
+amend should not be blocked by the ongoing histedit.
+
+  $ cat >>$HGRCPATH <<EOF
+  > [experimental]
+  > evolution=createmarkers,allowunstable
+  > EOF
+  $ hg commit --amend -m 'allow this fold'
+  $ hg histedit --continue