Patchwork D8064: split: add a --single flag to only ask for one split

login
register
mail settings
Submitter phabricator
Date Feb. 1, 2020, 7:28 a.m.
Message ID <differential-rev-PHID-DREV-emnebeedtp3hnq75lkeb-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/44863/
State New
Headers show

Comments

phabricator - Feb. 1, 2020, 7:28 a.m.
rdamazio created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  The majority of split invocations only want to split a revision in two,
  so this allows them to do that without getting a second chunk selector.
  I thought of making a generic "max_splits" flag, but that seemed like
  overkill.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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

CHANGE DETAILS




To: rdamazio, #hg-reviewers
Cc: 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
@@ -976,3 +976,60 @@ 
   2
   3
   4
+
+Test doing single splits, where it doesn't prompt to inspect what's left after
+the first split.
+------------------------------------------------------------------------------
+
+  $ hg init $TESTTMP/splitsingle
+  $ cd $TESTTMP/splitsingle
+  $ printf '1\n2\n' > file
+  $ hg ci -qAm initial
+  $ printf '0\n1\n2\n3\n' > file
+  $ hg ci -qm splitme
+  $ cat > $TESTTMP/messages <<EOF
+  > split1
+  > --
+  > split2
+  > EOF
+  $ printf 'y\ny\nn\n' | hg split --single
+  diff --git a/file b/file
+  2 hunks, 2 lines changed
+  examine changes to 'file'?
+  (enter ? for help) [Ynesfdaq?] y
+  
+  @@ -0,0 +1,1 @@
+  +0
+  record change 1/2 to 'file'?
+  (enter ? for help) [Ynesfdaq?] y
+  
+  @@ -2,0 +4,1 @@ 2
+  +3
+  record change 2/2 to 'file'?
+  (enter ? for help) [Ynesfdaq?] n
+  
+  EDITOR: HG: Splitting 82efe286d133. Write commit message for the first split changeset.
+  EDITOR: splitme
+  EDITOR: 
+  EDITOR: 
+  EDITOR: HG: Enter commit message.  Lines beginning with 'HG:' are removed.
+  EDITOR: HG: Leave message empty to abort commit.
+  EDITOR: HG: --
+  EDITOR: HG: user: test
+  EDITOR: HG: branch 'default'
+  EDITOR: HG: changed file
+  created new head
+  EDITOR: HG: Splitting 82efe286d133. So far it has been split into:
+  EDITOR: HG: - 810358029ce5: split1
+  EDITOR: HG: Write commit message for the next split changeset.
+  EDITOR: splitme
+  EDITOR: 
+  EDITOR: 
+  EDITOR: HG: Enter commit message.  Lines beginning with 'HG:' are removed.
+  EDITOR: HG: Leave message empty to abort commit.
+  EDITOR: HG: --
+  EDITOR: HG: user: test
+  EDITOR: HG: branch 'default'
+  EDITOR: HG: changed file
+  saved backup bundle to $TESTTMP/splitsingle/.hg/strip-backup/82efe286d133-1ff8b354-split.hg (obsstore-off !)
+
diff --git a/hgext/split.py b/hgext/split.py
--- a/hgext/split.py
+++ b/hgext/split.py
@@ -47,6 +47,7 @@ 
     [
         (b'r', b'rev', b'', _(b"revision to split"), _(b'REV')),
         (b'', b'rebase', True, _(b'rebase descendants after split')),
+        (b'', b'single', False, _(b'make a single split')),
     ]
     + cmdutil.commitopts2,
     _(b'hg split [--no-rebase] [[-r] REV]'),
@@ -137,8 +138,13 @@ 
         return any((st.modified, st.added, st.removed, st.deleted))
 
     # Main split loop
+    opts.update({b'edit': True, b'interactive': True})
     while incomplete(repo):
         if committed:
+            if opts[b'single']:
+                # Will make this take all changes and be the last split.
+                del opts[b'interactive']
+
             header = _(
                 b'HG: Splitting %s. So far it has been split into:\n'
             ) % short(ctx.node())
@@ -153,13 +159,8 @@ 
                 b'HG: Splitting %s. Write commit message for the '
                 b'first split changeset.\n'
             ) % short(ctx.node())
-        opts.update(
-            {
-                b'edit': True,
-                b'interactive': True,
-                b'message': header + ctx.description(),
-            }
-        )
+
+        opts.update({b'message': header + ctx.description()})
         commands.commit(ui, repo, **pycompat.strkwargs(opts))
         newctx = repo[b'.']
         committed.append(newctx)