Mercurial > hg
changeset 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 | e4ac7e63c213 |
children | 21cc92fea2aa |
files | hgext/split.py tests/test-removeemptydirs.t |
diffstat | 2 files changed, 4 insertions(+), 95 deletions(-) [+] |
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])
--- a/tests/test-removeemptydirs.t Thu Mar 14 00:40:11 2019 +0000 +++ b/tests/test-removeemptydirs.t Wed Mar 13 11:30:04 2019 -0700 @@ -265,91 +265,3 @@ 0:d17db4b0303a add bar $ cd $TESTTMP - -Testing `hg split` being run from inside of a directory that was created in the -commit being split: - - $ hg init hgsplit - $ cd hgsplit - $ cat >> .hg/hgrc << EOF - > [ui] - > interactive = 1 - > [extensions] - > split = - > EOF - $ echo anchor > anchor.txt - $ hg ci -qAm anchor - -Create a changeset with '/otherfile_in_root' and 'somedir/foo', then try to -split it. - $ echo otherfile > otherfile_in_root - $ mkdir somedir - $ cd somedir - $ echo hi > foo - $ hg ci -qAm split_me -(Note: need to make this file not in this directory, or else the bug doesn't -reproduce; we're using a separate file due to concerns of portability on -`echo -e`) - $ cat > ../split_commands << EOF - > n - > y - > y - > a - > EOF - -The split succeeds on no-rmcwd platforms, which alters the rest of the tests -#if rmcwd - $ cat ../split_commands | hg split - current directory was removed - (consider changing to repo root: $TESTTMP/hgsplit) - diff --git a/otherfile_in_root b/otherfile_in_root - new file mode 100644 - examine changes to 'otherfile_in_root'? [Ynesfdaq?] n - - diff --git a/somedir/foo b/somedir/foo - new file mode 100644 - examine changes to 'somedir/foo'? [Ynesfdaq?] y - - @@ -0,0 +1,1 @@ - +hi - record change 2/2 to 'somedir/foo'? [Ynesfdaq?] y - - abort: $ENOENT$ - [255] -#endif - -Let's try that again without the rmdir - $ cd $TESTTMP/hgsplit/somedir -Show that the previous split didn't do anything - $ hg log -T '{rev}:{node|short} {desc}\n' - 1:e26b22a4f0b7 split_me - 0:7e53273730c0 anchor - $ hg status - ? split_commands -Try again - $ cat ../split_commands | hg $NO_RM split - diff --git a/otherfile_in_root b/otherfile_in_root - new file mode 100644 - examine changes to 'otherfile_in_root'? [Ynesfdaq?] n - - diff --git a/somedir/foo b/somedir/foo - new file mode 100644 - examine changes to 'somedir/foo'? [Ynesfdaq?] y - - @@ -0,0 +1,1 @@ - +hi - record change 2/2 to 'somedir/foo'? [Ynesfdaq?] y - - created new head - diff --git a/otherfile_in_root b/otherfile_in_root - new file mode 100644 - examine changes to 'otherfile_in_root'? [Ynesfdaq?] a - - saved backup bundle to $TESTTMP/hgsplit/.hg/strip-backup/*-split.hg (glob) -Show that this split did something - $ hg log -T '{rev}:{node|short} {desc}\n' - 2:a440f24fca4f split_me - 1:c994f20276ab split_me - 0:7e53273730c0 anchor - $ hg status - ? split_commands