--- a/hgext/split.py Sun Oct 06 09:45:02 2019 -0400
+++ b/hgext/split.py Sun Oct 06 09:48:39 2019 -0400
@@ -40,17 +40,17 @@
# extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
# be specifying the version(s) of Mercurial they are tested with, or
# leave the attribute unspecified.
-testedwith = 'ships-with-hg-core'
+testedwith = b'ships-with-hg-core'
@command(
- 'split',
+ b'split',
[
- ('r', 'rev', '', _("revision to split"), _('REV')),
- ('', 'rebase', True, _('rebase descendants after split')),
+ (b'r', b'rev', b'', _(b"revision to split"), _(b'REV')),
+ (b'', b'rebase', True, _(b'rebase descendants after split')),
]
+ cmdutil.commitopts2,
- _('hg split [--no-rebase] [[-r] REV]'),
+ _(b'hg split [--no-rebase] [[-r] REV]'),
helpcategory=command.CATEGORY_CHANGE_MANAGEMENT,
helpbasic=True,
)
@@ -67,21 +67,21 @@
"""
opts = pycompat.byteskwargs(opts)
revlist = []
- if opts.get('rev'):
- revlist.append(opts.get('rev'))
+ if opts.get(b'rev'):
+ revlist.append(opts.get(b'rev'))
revlist.extend(revs)
- with repo.wlock(), repo.lock(), repo.transaction('split') as tr:
- revs = scmutil.revrange(repo, revlist or ['.'])
+ with repo.wlock(), repo.lock(), repo.transaction(b'split') as tr:
+ revs = scmutil.revrange(repo, revlist or [b'.'])
if len(revs) > 1:
- raise error.Abort(_('cannot split multiple revisions'))
+ raise error.Abort(_(b'cannot split multiple revisions'))
rev = revs.first()
ctx = repo[rev]
if rev is None or ctx.node() == nullid:
- ui.status(_('nothing to split\n'))
+ ui.status(_(b'nothing to split\n'))
return 1
if ctx.node() is None:
- raise error.Abort(_('cannot split working directory'))
+ raise error.Abort(_(b'cannot split working directory'))
# rewriteutil.precheck is not very useful here because:
# 1. null check is done above and it's more friendly to return 1
@@ -92,33 +92,33 @@
# 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"),
+ _(b'cannot split public changeset'),
+ hint=_(b"see 'hg help phases' for details"),
)
- descendants = list(repo.revs('(%d::) - (%d)', rev, rev))
+ descendants = list(repo.revs(b'(%d::) - (%d)', rev, rev))
alloworphaned = obsolete.isenabled(repo, obsolete.allowunstableopt)
- if opts.get('rebase'):
+ if opts.get(b'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
+ b'%ld - (%ld & obsolete())::', descendants, descendants
)
)
if not alloworphaned and len(torebase) != len(descendants):
raise error.Abort(
- _('split would leave orphaned changesets ' 'behind')
+ _(b'split would leave orphaned changesets ' b'behind')
)
else:
if not alloworphaned and descendants:
raise error.Abort(
- _('cannot split changeset with children without rebase')
+ _(b'cannot split changeset with children without rebase')
)
torebase = ()
if len(ctx.parents()) > 1:
- raise error.Abort(_('cannot split a merge changeset'))
+ raise error.Abort(_(b'cannot split a merge changeset'))
cmdutil.bailifchanged(repo)
@@ -127,7 +127,7 @@
if bname and repo._bookmarks[bname] != ctx.node():
bookmarks.deactivate(repo)
- wnode = repo['.'].node()
+ wnode = repo[b'.'].node()
top = None
try:
top = dosplit(ui, repo, tr, ctx, opts)
@@ -158,37 +158,37 @@
while incomplete(repo):
if committed:
header = _(
- 'HG: Splitting %s. So far it has been split into:\n'
+ b'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)
+ firstline = c.description().split(b'\n', 1)[0]
+ header += _(b'HG: - %s: %s\n') % (short(c.node()), firstline)
header += _(
- 'HG: Write commit message for the next split ' 'changeset.\n'
+ b'HG: Write commit message for the next split ' b'changeset.\n'
)
else:
header = _(
- 'HG: Splitting %s. Write commit message for the '
- 'first split changeset.\n'
+ b'HG: Splitting %s. Write commit message for the '
+ b'first split changeset.\n'
) % short(ctx.node())
opts.update(
{
- 'edit': True,
- 'interactive': True,
- 'message': header + ctx.description(),
+ b'edit': True,
+ b'interactive': True,
+ b'message': header + ctx.description(),
}
)
commands.commit(ui, repo, **pycompat.strkwargs(opts))
- newctx = repo['.']
+ newctx = repo[b'.']
committed.append(newctx)
if not committed:
- raise error.Abort(_('cannot split an empty revision'))
+ raise error.Abort(_(b'cannot split an empty revision'))
scmutil.cleanupnodes(
repo,
{ctx.node(): [c.node() for c in committed]},
- operation='split',
+ operation=b'split',
fixphase=True,
)
@@ -199,6 +199,6 @@
rebase.rebase(
ui,
repo,
- rev=[revsetlang.formatspec('%ld', src)],
- dest=revsetlang.formatspec('%d', destctx.rev()),
+ rev=[revsetlang.formatspec(b'%ld', src)],
+ dest=revsetlang.formatspec(b'%d', destctx.rev()),
)