Patchwork D10389: split: avoid strip if split is a no-op (identical to original)

login
register
mail settings
Submitter phabricator
Date April 13, 2021, 6:53 p.m.
Message ID <differential-rev-PHID-DREV-y3i5uqflaadplzx3exnn-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/48706/
State Superseded
Headers show

Comments

phabricator - April 13, 2021, 6:53 p.m.
spectral created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D10389

AFFECTED FILES
  hgext/split.py
  tests/test-split.t

CHANGE DETAILS




To: spectral, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/tests/test-split.t b/tests/test-split.t
--- a/tests/test-split.t
+++ b/tests/test-split.t
@@ -1086,16 +1086,9 @@ 
   HG: branch 'default'
   HG: added foo
   warning: commit already existed in the repository!
-  saved backup bundle to $TESTTMP/noop/.hg/strip-backup/ae694b2901bb-28e0b457-split.hg (obsstore-off !)
-  transaction abort! (obsstore-on !)
-  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)
   $ 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 !)
+  @  draft 1:ae694b2901bb foo
+  |
   o  public 0:222799e2f90b r0
   
 
diff --git a/hgext/split.py b/hgext/split.py
--- a/hgext/split.py
+++ b/hgext/split.py
@@ -182,12 +182,15 @@ 
     if not committed:
         raise error.InputError(_(b'cannot split an empty revision'))
 
-    scmutil.cleanupnodes(
-        repo,
-        {ctx.node(): [c.node() for c in committed]},
-        operation=b'split',
-        fixphase=True,
-    )
+    if len(committed) != 1 or committed[0].node() != ctx.node():
+        # Ensure we don't strip a node if we produce the same commit as already
+        # exists
+        scmutil.cleanupnodes(
+            repo,
+            {ctx.node(): [c.node() for c in committed]},
+            operation=b'split',
+            fixphase=True,
+        )
 
     return committed[-1]