diff hgext/split.py @ 43076:2372284d9457

formatting: blacken the codebase This is using my patch to black (https://github.com/psf/black/pull/826) so we don't un-wrap collection literals. Done with: hg files 'set:**.py - mercurial/thirdparty/** - "contrib/python-zstandard/**"' | xargs black -S # skip-blame mass-reformatting only # no-check-commit reformats foo_bar functions Differential Revision: https://phab.mercurial-scm.org/D6971
author Augie Fackler <augie@google.com>
date Sun, 06 Oct 2019 09:45:02 -0400
parents 42e2c7c52e1b
children 687b865b95ad
line wrap: on
line diff
--- a/hgext/split.py	Sat Oct 05 10:29:34 2019 -0400
+++ b/hgext/split.py	Sun Oct 06 09:45:02 2019 -0400
@@ -31,9 +31,7 @@
 )
 
 # allow people to use split without explicitly enabling rebase extension
-from . import (
-    rebase,
-)
+from . import rebase
 
 cmdtable = {}
 command = registrar.command(cmdtable)
@@ -44,12 +42,18 @@
 # leave the attribute unspecified.
 testedwith = 'ships-with-hg-core'
 
-@command('split',
-    [('r', 'rev', '', _("revision to split"), _('REV')),
-     ('', 'rebase', True, _('rebase descendants after split')),
-    ] + cmdutil.commitopts2,
+
+@command(
+    'split',
+    [
+        ('r', 'rev', '', _("revision to split"), _('REV')),
+        ('', 'rebase', True, _('rebase descendants after split')),
+    ]
+    + cmdutil.commitopts2,
     _('hg split [--no-rebase] [[-r] REV]'),
-    helpcategory=command.CATEGORY_CHANGE_MANAGEMENT, helpbasic=True)
+    helpcategory=command.CATEGORY_CHANGE_MANAGEMENT,
+    helpbasic=True,
+)
 def split(ui, repo, *revs, **opts):
     """split a changeset into smaller ones
 
@@ -87,23 +91,30 @@
         #
         # So only "public" check is useful and it's checked directly here.
         if ctx.phase() == phases.public:
-            raise error.Abort(_('cannot split public changeset'),
-                              hint=_("see 'hg help phases' for details"))
+            raise error.Abort(
+                _('cannot split public changeset'),
+                hint=_("see 'hg help phases' for details"),
+            )
 
         descendants = list(repo.revs('(%d::) - (%d)', rev, rev))
         alloworphaned = obsolete.isenabled(repo, obsolete.allowunstableopt)
         if opts.get('rebase'):
             # Skip obsoleted descendants and their descendants so the rebase
             # won't cause conflicts for sure.
-            torebase = list(repo.revs('%ld - (%ld & obsolete())::',
-                                      descendants, descendants))
+            torebase = list(
+                repo.revs(
+                    '%ld - (%ld & obsolete())::', descendants, descendants
+                )
+            )
             if not alloworphaned and len(torebase) != len(descendants):
-                raise error.Abort(_('split would leave orphaned changesets '
-                                    'behind'))
+                raise error.Abort(
+                    _('split would leave orphaned changesets ' 'behind')
+                )
         else:
             if not alloworphaned and descendants:
                 raise error.Abort(
-                    _('cannot split changeset with children without rebase'))
+                    _('cannot split changeset with children without rebase')
+                )
             torebase = ()
 
         if len(ctx.parents()) > 1:
@@ -130,8 +141,9 @@
         if torebase and top:
             dorebase(ui, repo, torebase, top)
 
+
 def dosplit(ui, repo, tr, ctx, opts):
-    committed = [] # [ctx]
+    committed = []  # [ctx]
 
     # Set working parent to ctx.p1(), and keep working copy as ctx's content
     if ctx.node() != repo.dirstate.p1():
@@ -145,21 +157,27 @@
     # Main split loop
     while incomplete(repo):
         if committed:
-            header = (_('HG: Splitting %s. So far it has been split into:\n')
-                      % short(ctx.node()))
+            header = _(
+                'HG: Splitting %s. So far it has been split into:\n'
+            ) % short(ctx.node())
             for c in committed:
                 firstline = c.description().split('\n', 1)[0]
                 header += _('HG: - %s: %s\n') % (short(c.node()), firstline)
-            header += _('HG: Write commit message for the next split '
-                        'changeset.\n')
+            header += _(
+                'HG: Write commit message for the next split ' 'changeset.\n'
+            )
         else:
-            header = _('HG: Splitting %s. Write commit message for the '
-                       'first split changeset.\n') % short(ctx.node())
-        opts.update({
-            'edit': True,
-            'interactive': True,
-            'message': header + ctx.description(),
-        })
+            header = _(
+                'HG: Splitting %s. Write commit message for the '
+                'first split changeset.\n'
+            ) % short(ctx.node())
+        opts.update(
+            {
+                'edit': True,
+                'interactive': True,
+                'message': header + ctx.description(),
+            }
+        )
         commands.commit(ui, repo, **pycompat.strkwargs(opts))
         newctx = repo['.']
         committed.append(newctx)
@@ -167,11 +185,20 @@
     if not committed:
         raise error.Abort(_('cannot split an empty revision'))
 
-    scmutil.cleanupnodes(repo, {ctx.node(): [c.node() for c in committed]},
-                         operation='split', fixphase=True)
+    scmutil.cleanupnodes(
+        repo,
+        {ctx.node(): [c.node() for c in committed]},
+        operation='split',
+        fixphase=True,
+    )
 
     return committed[-1]
 
+
 def dorebase(ui, repo, src, destctx):
-    rebase.rebase(ui, repo, rev=[revsetlang.formatspec('%ld', src)],
-                  dest=revsetlang.formatspec('%d', destctx.rev()))
+    rebase.rebase(
+        ui,
+        repo,
+        rev=[revsetlang.formatspec('%ld', src)],
+        dest=revsetlang.formatspec('%d', destctx.rev()),
+    )