hgext/split.py
author Augie Fackler <augie@google.com>
Tue, 18 Jun 2019 09:57:06 -0400
changeset 42512 df1419c5756a
parent 41971 42e2c7c52e1b
child 43076 2372284d9457
permissions -rw-r--r--
remotefilelog: tell runbgcommand to not block on child process startup These two invocations will always find a binary because they're re-running hg. As a result, we can skip waiting for the subprocess to start running and save a little bit of wall-time. Differential Revision: https://phab.mercurial-scm.org/D6539
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
35459
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
     1
# split.py - split a changeset into smaller ones
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
     2
#
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
     3
# Copyright 2015 Laurent Charignon <lcharignon@fb.com>
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
     4
# Copyright 2017 Facebook, Inc.
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
     5
#
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
     6
# This software may be used and distributed according to the terms of the
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
     7
# GNU General Public License version 2 or any later version.
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
     8
"""command to split a changeset into smaller ones (EXPERIMENTAL)"""
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
     9
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
    10
from __future__ import absolute_import
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
    11
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
    12
from mercurial.i18n import _
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
    13
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
    14
from mercurial.node import (
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
    15
    nullid,
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
    16
    short,
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
    17
)
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
    18
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
    19
from mercurial import (
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
    20
    bookmarks,
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
    21
    cmdutil,
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
    22
    commands,
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
    23
    error,
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
    24
    hg,
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
    25
    obsolete,
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
    26
    phases,
36430
7b86aa31b004 py3: fix handling of keyword arguments at more places
Pulkit Goyal <7895pulkit@gmail.com>
parents: 35459
diff changeset
    27
    pycompat,
35459
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
    28
    registrar,
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
    29
    revsetlang,
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
    30
    scmutil,
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
    31
)
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
    32
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
    33
# allow people to use split without explicitly enabling rebase extension
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
    34
from . import (
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
    35
    rebase,
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
    36
)
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
    37
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
    38
cmdtable = {}
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
    39
command = registrar.command(cmdtable)
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
    40
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
    41
# Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
    42
# extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
    43
# be specifying the version(s) of Mercurial they are tested with, or
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
    44
# leave the attribute unspecified.
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
    45
testedwith = 'ships-with-hg-core'
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
    46
40295
fa88170c10bb help: adding a proper declaration for shortlist/basic commands (API)
Rodrigo Damazio <rdamazio@google.com>
parents: 40293
diff changeset
    47
@command('split',
35459
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
    48
    [('r', 'rev', '', _("revision to split"), _('REV')),
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
    49
     ('', 'rebase', True, _('rebase descendants after split')),
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
    50
    ] + cmdutil.commitopts2,
40293
c303d65d2e34 help: assigning categories to existing commands
rdamazio@google.com
parents: 38430
diff changeset
    51
    _('hg split [--no-rebase] [[-r] REV]'),
40295
fa88170c10bb help: adding a proper declaration for shortlist/basic commands (API)
Rodrigo Damazio <rdamazio@google.com>
parents: 40293
diff changeset
    52
    helpcategory=command.CATEGORY_CHANGE_MANAGEMENT, helpbasic=True)
35459
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
    53
def split(ui, repo, *revs, **opts):
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
    54
    """split a changeset into smaller ones
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
    55
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
    56
    Repeatedly prompt changes and commit message for new changesets until there
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
    57
    is nothing left in the original changeset.
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
    58
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
    59
    If --rev was not given, split the working directory parent.
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
    60
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
    61
    By default, rebase connected non-obsoleted descendants onto the new
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
    62
    changeset. Use --no-rebase to avoid the rebase.
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
    63
    """
38102
5ba0cf22e4d0 py3: fix kwargs handling in hgext/split.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 36438
diff changeset
    64
    opts = pycompat.byteskwargs(opts)
35459
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
    65
    revlist = []
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
    66
    if opts.get('rev'):
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
    67
        revlist.append(opts.get('rev'))
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
    68
    revlist.extend(revs)
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
    69
    with repo.wlock(), repo.lock(), repo.transaction('split') as tr:
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
    70
        revs = scmutil.revrange(repo, revlist or ['.'])
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
    71
        if len(revs) > 1:
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
    72
            raise error.Abort(_('cannot split multiple revisions'))
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
    73
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
    74
        rev = revs.first()
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
    75
        ctx = repo[rev]
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
    76
        if rev is None or ctx.node() == nullid:
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
    77
            ui.status(_('nothing to split\n'))
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
    78
            return 1
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
    79
        if ctx.node() is None:
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
    80
            raise error.Abort(_('cannot split working directory'))
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
    81
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
    82
        # rewriteutil.precheck is not very useful here because:
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
    83
        # 1. null check is done above and it's more friendly to return 1
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
    84
        #    instead of abort
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
    85
        # 2. mergestate check is done below by cmdutil.bailifchanged
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
    86
        # 3. unstable check is more complex here because of --rebase
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
    87
        #
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
    88
        # So only "public" check is useful and it's checked directly here.
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
    89
        if ctx.phase() == phases.public:
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
    90
            raise error.Abort(_('cannot split public changeset'),
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
    91
                              hint=_("see 'hg help phases' for details"))
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
    92
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
    93
        descendants = list(repo.revs('(%d::) - (%d)', rev, rev))
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
    94
        alloworphaned = obsolete.isenabled(repo, obsolete.allowunstableopt)
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
    95
        if opts.get('rebase'):
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
    96
            # Skip obsoleted descendants and their descendants so the rebase
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
    97
            # won't cause conflicts for sure.
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
    98
            torebase = list(repo.revs('%ld - (%ld & obsolete())::',
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
    99
                                      descendants, descendants))
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
   100
            if not alloworphaned and len(torebase) != len(descendants):
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
   101
                raise error.Abort(_('split would leave orphaned changesets '
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
   102
                                    'behind'))
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
   103
        else:
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
   104
            if not alloworphaned and descendants:
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
   105
                raise error.Abort(
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
   106
                    _('cannot split changeset with children without rebase'))
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
   107
            torebase = ()
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
   108
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
   109
        if len(ctx.parents()) > 1:
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
   110
            raise error.Abort(_('cannot split a merge changeset'))
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
   111
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
   112
        cmdutil.bailifchanged(repo)
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
   113
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
   114
        # Deactivate bookmark temporarily so it won't get moved unintentionally
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
   115
        bname = repo._activebookmark
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
   116
        if bname and repo._bookmarks[bname] != ctx.node():
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
   117
            bookmarks.deactivate(repo)
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
   118
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
   119
        wnode = repo['.'].node()
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
   120
        top = None
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
   121
        try:
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
   122
            top = dosplit(ui, repo, tr, ctx, opts)
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
   123
        finally:
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
   124
            # top is None: split failed, need update --clean recovery.
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
   125
            # wnode == ctx.node(): wnode split, no need to update.
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
   126
            if top is None or wnode != ctx.node():
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
   127
                hg.clean(repo, wnode, show_stats=False)
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
   128
            if bname:
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
   129
                bookmarks.activate(repo, bname)
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
   130
        if torebase and top:
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
   131
            dorebase(ui, repo, torebase, top)
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
   132
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
   133
def dosplit(ui, repo, tr, ctx, opts):
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
   134
    committed = [] # [ctx]
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
   135
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
   136
    # Set working parent to ctx.p1(), and keep working copy as ctx's content
41971
42e2c7c52e1b split: use the new movedirstate() we now have in scmutil
Martin von Zweigbergk <martinvonz@google.com>
parents: 40295
diff changeset
   137
    if ctx.node() != repo.dirstate.p1():
42e2c7c52e1b split: use the new movedirstate() we now have in scmutil
Martin von Zweigbergk <martinvonz@google.com>
parents: 40295
diff changeset
   138
        hg.clean(repo, ctx.node(), show_stats=False)
42e2c7c52e1b split: use the new movedirstate() we now have in scmutil
Martin von Zweigbergk <martinvonz@google.com>
parents: 40295
diff changeset
   139
    with repo.dirstate.parentchange():
42e2c7c52e1b split: use the new movedirstate() we now have in scmutil
Martin von Zweigbergk <martinvonz@google.com>
parents: 40295
diff changeset
   140
        scmutil.movedirstate(repo, ctx.p1())
35459
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
   141
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
   142
    # Any modified, added, removed, deleted result means split is incomplete
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
   143
    incomplete = lambda repo: any(repo.status()[:4])
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
   144
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
   145
    # Main split loop
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
   146
    while incomplete(repo):
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
   147
        if committed:
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
   148
            header = (_('HG: Splitting %s. So far it has been split into:\n')
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
   149
                      % short(ctx.node()))
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
   150
            for c in committed:
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
   151
                firstline = c.description().split('\n', 1)[0]
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
   152
                header += _('HG: - %s: %s\n') % (short(c.node()), firstline)
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
   153
            header += _('HG: Write commit message for the next split '
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
   154
                        'changeset.\n')
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
   155
        else:
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
   156
            header = _('HG: Splitting %s. Write commit message for the '
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
   157
                       'first split changeset.\n') % short(ctx.node())
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
   158
        opts.update({
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
   159
            'edit': True,
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
   160
            'interactive': True,
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
   161
            'message': header + ctx.description(),
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
   162
        })
36430
7b86aa31b004 py3: fix handling of keyword arguments at more places
Pulkit Goyal <7895pulkit@gmail.com>
parents: 35459
diff changeset
   163
        commands.commit(ui, repo, **pycompat.strkwargs(opts))
35459
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
   164
        newctx = repo['.']
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
   165
        committed.append(newctx)
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
   166
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
   167
    if not committed:
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
   168
        raise error.Abort(_('cannot split an empty revision'))
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
   169
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
   170
    scmutil.cleanupnodes(repo, {ctx.node(): [c.node() for c in committed]},
38430
4f885770c4a2 split: preserve phase of commit that is being split
Martin von Zweigbergk <martinvonz@google.com>
parents: 38102
diff changeset
   171
                         operation='split', fixphase=True)
35459
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
   172
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
   173
    return committed[-1]
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
   174
36438
83bade6206d4 split: use ctx.rev() instead of %d % ctx
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36430
diff changeset
   175
def dorebase(ui, repo, src, destctx):
35459
02ea370c2baa split: new extension to split changesets
Jun Wu <quark@fb.com>
parents:
diff changeset
   176
    rebase.rebase(ui, repo, rev=[revsetlang.formatspec('%ld', src)],
36438
83bade6206d4 split: use ctx.rev() instead of %d % ctx
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36430
diff changeset
   177
                  dest=revsetlang.formatspec('%d', destctx.rev()))