diff hgext/split.py @ 41966:42e2c7c52e1b

split: use the new movedirstate() we now have in scmutil This avoids unnecessarily touching the working copy when splitting the parent of the working copy. That also makes the test-removeemptydirs.t case invalid, so we can just delete it. Differential Revision: https://phab.mercurial-scm.org/D6127
author Martin von Zweigbergk <martinvonz@google.com>
date Wed, 13 Mar 2019 11:30:04 -0700
parents fa88170c10bb
children 2372284d9457
line wrap: on
line diff
--- a/hgext/split.py	Thu Mar 14 00:40:11 2019 +0000
+++ b/hgext/split.py	Wed Mar 13 11:30:04 2019 -0700
@@ -134,13 +134,10 @@
     committed = [] # [ctx]
 
     # Set working parent to ctx.p1(), and keep working copy as ctx's content
-    # NOTE: if we can have "update without touching working copy" API, the
-    # revert step could be cheaper.
-    hg.clean(repo, ctx.p1().node(), show_stats=False)
-    parents = repo.changelog.parents(ctx.node())
-    ui.pushbuffer()
-    cmdutil.revert(ui, repo, ctx, parents)
-    ui.popbuffer() # discard "reverting ..." messages
+    if ctx.node() != repo.dirstate.p1():
+        hg.clean(repo, ctx.node(), show_stats=False)
+    with repo.dirstate.parentchange():
+        scmutil.movedirstate(repo, ctx.p1())
 
     # Any modified, added, removed, deleted result means split is incomplete
     incomplete = lambda repo: any(repo.status()[:4])