split: fix issue with empty splits adjusting phases
authorKyle Lippincott <spectral@google.com>
Mon, 12 Apr 2021 17:52:46 -0700
changeset 46923 8ee1ac083ee7
parent 46922 17368844f786
child 46924 ca0049946e9a
split: fix issue with empty splits adjusting phases Differential Revision: https://phab.mercurial-scm.org/D10388
hgext/split.py
tests/test-split.t
--- a/hgext/split.py	Mon Apr 12 17:51:56 2021 -0700
+++ b/hgext/split.py	Mon Apr 12 17:52:46 2021 -0700
@@ -171,9 +171,13 @@
                 b'message': header + ctx.description(),
             }
         )
+        origctx = repo[b'.']
         commands.commit(ui, repo, **pycompat.strkwargs(opts))
         newctx = repo[b'.']
-        committed.append(newctx)
+        # Ensure user didn't do a "no-op" split (such as deselecting
+        # everything).
+        if origctx.node() != newctx.node():
+            committed.append(newctx)
 
     if not committed:
         raise error.InputError(_(b'cannot split an empty revision'))
--- a/tests/test-split.t	Mon Apr 12 17:51:56 2021 -0700
+++ b/tests/test-split.t	Mon Apr 12 17:52:46 2021 -0700
@@ -1063,7 +1063,6 @@
   |
   o  public 0:222799e2f90b r0
   
-FIXME: This should not show "So far it has been split into"
   $ printf 'd\na\n' | HGEDITOR=cat hg split || true
   diff --git a/foo b/foo
   new file mode 100644
@@ -1076,9 +1075,7 @@
   examine changes to 'foo'?
   (enter ? for help) [Ynesfdaq?] a
   
-  HG: Splitting ae694b2901bb. So far it has been split into:
-  HG: - 0:222799e2f90b "r0"
-  HG: Write commit message for the next split changeset.
+  HG: Splitting ae694b2901bb. Write commit message for the first split changeset.
   foo
   
   
@@ -1094,13 +1091,12 @@
   rollback completed (obsstore-on !)
   abort: changeset ae694b2901bb cannot obsolete itself (obsstore-on !)
 FIXME: this should not have stripped the commit we just no-op split
-(obsstore-off only), or made r0 draft.
+(obsstore-off only)
   $ hg log -G -T'{phase} {rev}:{node|short} {desc}'
   warning: ignoring unknown working parent ae694b2901bb! (obsstore-off !)
   @  draft 1:ae694b2901bb foo (obsstore-on !)
   | (obsstore-on !)
-  o  public 0:222799e2f90b r0 (obsstore-on !)
-  o  draft 0:222799e2f90b r0 (obsstore-off !)
+  o  public 0:222799e2f90b r0
   
 
 Now try the same thing but modifying the message so we don't trigger the
@@ -1121,7 +1117,6 @@
   $ cat > $TESTTMP/messages <<EOF
   > message1
   > EOF
-FIXME: This should not show "So far it has been split into"
   $ printf 'd\na\n' | HGEDITOR="\"$PYTHON\" $TESTTMP/editor.py" hg split
   diff --git a/foo b/foo
   new file mode 100644
@@ -1134,9 +1129,7 @@
   examine changes to 'foo'?
   (enter ? for help) [Ynesfdaq?] a
   
-  EDITOR: HG: Splitting ae694b2901bb. So far it has been split into:
-  EDITOR: HG: - 0:222799e2f90b "r0"
-  EDITOR: HG: Write commit message for the next split changeset.
+  EDITOR: HG: Splitting ae694b2901bb. Write commit message for the first split changeset.
   EDITOR: foo
   EDITOR: 
   EDITOR: 
@@ -1148,15 +1141,13 @@
   EDITOR: HG: added foo
   created new head
   saved backup bundle to $TESTTMP/noop2/.hg/strip-backup/ae694b2901bb-28e0b457-split.hg (obsstore-off !)
-FIXME: this should not have made r0 draft
   $ hg log -G -T'{phase} {rev}:{node|short} {desc}'
   @  draft 1:de675559d3f9 message1 (obsstore-off !)
   @  draft 2:de675559d3f9 message1 (obsstore-on !)
   |
-  o  draft 0:222799e2f90b r0
+  o  public 0:222799e2f90b r0
   
 #if obsstore-on
-FIXME: this should not have marked 222799e (r0) as a precursor of anything.
   $ hg debugobsolete
-  ae694b2901bb8b0f8c4b5e075ddec0d63468d57a 222799e2f90be09ccbe49f519c4615d8375a9242 de675559d3f93ffc822c6eb7490e5c73033f17c7 0 * (glob)
+  ae694b2901bb8b0f8c4b5e075ddec0d63468d57a de675559d3f93ffc822c6eb7490e5c73033f17c7 0 * (glob)
 #endif