Patchwork [2,of,2] graft: make --force apply across continues (issue3220)

login
register
mail settings
Submitter Siddharth Agarwal
Date Aug. 2, 2014, 4:52 a.m.
Message ID <43413d440fe6ea54930a.1406955136@dev1738.prn1.facebook.com>
Download mbox | patch
Permalink /patch/5221/
State Accepted
Headers show

Comments

Siddharth Agarwal - Aug. 2, 2014, 4:52 a.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@fb.com>
# Date 1406411676 25200
#      Sat Jul 26 14:54:36 2014 -0700
# Node ID 43413d440fe6ea54930a51d76de2f91129fc726b
# Parent  b1980253ca3569886d6e647fd74d6c5a7436e2fc
graft: make --force apply across continues (issue3220)

Since --force determines the list of revisions to be grafted, it doesn't really
make sense for users to have to keep typing --force --continue as they continue
grafting.
Matt Mackall - Aug. 3, 2014, 2:05 a.m.
On Fri, 2014-08-01 at 21:52 -0700, Siddharth Agarwal wrote:
> # HG changeset patch
> # User Siddharth Agarwal <sid0@fb.com>
> # Date 1406411676 25200
> #      Sat Jul 26 14:54:36 2014 -0700
> # Node ID 43413d440fe6ea54930a51d76de2f91129fc726b
> # Parent  b1980253ca3569886d6e647fd74d6c5a7436e2fc
> graft: make --force apply across continues (issue3220)

Queued for default, thanks.

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -3089,7 +3089,8 @@ 
 
     .. note::
 
-      The -c/--continue option does not reapply earlier options.
+      The -c/--continue option does not reapply earlier options, except
+      for --force.
 
     .. container:: verbose
 
@@ -3155,8 +3156,14 @@ 
     if not revs:
         return -1
 
-    # check for ancestors of dest branch
-    if not opts.get('force'):
+    # Don't check in the --continue case, in effect retaining --force across
+    # --continues. That's because without --force, any revisions we decided to
+    # skip would have been filtered out here, so they wouldn't have made their
+    # way to the graftstate. With --force, any revisions we would have otherwise
+    # skipped would not have been filtered out, and if they hadn't been applied
+    # already, they'd have been in the graftstate.
+    if not (cont or opts.get('force')):
+        # check for ancestors of dest branch
         crev = repo['.'].rev()
         ancestors = repo.changelog.ancestors([crev], inclusive=True)
         # Cannot use x.remove(y) on smart set, this has to be a list.
diff --git a/tests/test-graft.t b/tests/test-graft.t
--- a/tests/test-graft.t
+++ b/tests/test-graft.t
@@ -661,3 +661,20 @@ 
   $ cat a
   abc
 
+graft --continue after --force
+
+  $ hg backout 30
+  reverting a
+  changeset 31:3b96c18b7a1b backs out changeset 30:8f539994be33
+  $ hg graft 28 --force --tool internal:fail
+  grafting revision 28
+  abort: unresolved conflicts, can't continue
+  (use hg resolve and hg graft --continue)
+  [255]
+  $ hg resolve --all
+  merging a
+  (no more unresolved files)
+  $ hg graft -c
+  grafting revision 28
+  $ cat a
+  abc