Replace check with nullid with a check on the simpler nullrev.
Details
Details
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Branch
- default
- Lint
No Linters Available - Unit
No Unit Test Coverage
hg-reviewers |
Replace check with nullid with a check on the simpler nullrev.
No Linters Available |
No Unit Test Coverage |
Path | Packages | |||
---|---|---|---|---|
M | hgext/split.py (8 lines) |
Commit | Parents | Author | Summary | Date |
---|---|---|---|---|
38c61cffdaa4 | 166fe33b1418 | Joerg Sonnenberger | Mar 28 2021, 4:41 PM |
# split.py - split a changeset into smaller ones | # split.py - split a changeset into smaller ones | ||||
# | # | ||||
# Copyright 2015 Laurent Charignon <lcharignon@fb.com> | # Copyright 2015 Laurent Charignon <lcharignon@fb.com> | ||||
# Copyright 2017 Facebook, Inc. | # Copyright 2017 Facebook, Inc. | ||||
# | # | ||||
# This software may be used and distributed according to the terms of the | # This software may be used and distributed according to the terms of the | ||||
# GNU General Public License version 2 or any later version. | # GNU General Public License version 2 or any later version. | ||||
"""command to split a changeset into smaller ones (EXPERIMENTAL)""" | """command to split a changeset into smaller ones (EXPERIMENTAL)""" | ||||
from __future__ import absolute_import | from __future__ import absolute_import | ||||
from mercurial.i18n import _ | from mercurial.i18n import _ | ||||
from mercurial.node import ( | from mercurial.node import ( | ||||
nullid, | nullrev, | ||||
short, | short, | ||||
) | ) | ||||
from mercurial import ( | from mercurial import ( | ||||
bookmarks, | bookmarks, | ||||
cmdutil, | cmdutil, | ||||
commands, | commands, | ||||
error, | error, | ||||
# If the rebase somehow runs into conflicts, make sure | # If the rebase somehow runs into conflicts, make sure | ||||
# we close the transaction so the user can continue it. | # we close the transaction so the user can continue it. | ||||
with util.acceptintervention(tr): | with util.acceptintervention(tr): | ||||
revs = scmutil.revrange(repo, revlist or [b'.']) | revs = scmutil.revrange(repo, revlist or [b'.']) | ||||
if len(revs) > 1: | if len(revs) > 1: | ||||
raise error.InputError(_(b'cannot split multiple revisions')) | raise error.InputError(_(b'cannot split multiple revisions')) | ||||
rev = revs.first() | rev = revs.first() | ||||
ctx = repo[rev] | # Handle nullrev specially here (instead of leaving for precheck() | ||||
# Handle nullid specially here (instead of leaving for precheck() | |||||
# below) so we get a nicer message and error code. | # below) so we get a nicer message and error code. | ||||
if rev is None or ctx.node() == nullid: | if rev is None or rev == nullrev: | ||||
ui.status(_(b'nothing to split\n')) | ui.status(_(b'nothing to split\n')) | ||||
return 1 | return 1 | ||||
ctx = repo[rev] | |||||
if ctx.node() is None: | if ctx.node() is None: | ||||
raise error.InputError(_(b'cannot split working directory')) | raise error.InputError(_(b'cannot split working directory')) | ||||
if opts.get(b'rebase'): | if opts.get(b'rebase'): | ||||
# Skip obsoleted descendants and their descendants so the rebase | # Skip obsoleted descendants and their descendants so the rebase | ||||
# won't cause conflicts for sure. | # won't cause conflicts for sure. | ||||
descendants = list(repo.revs(b'(%d::) - (%d)', rev, rev)) | descendants = list(repo.revs(b'(%d::) - (%d)', rev, rev)) | ||||
torebase = list( | torebase = list( |