2018-10-11 16:55:19 +03:00
|
|
|
# amend.py - improved amend functionality
|
2014-06-02 23:54:54 +04:00
|
|
|
#
|
|
|
|
# Copyright 2013 Facebook, Inc.
|
|
|
|
#
|
|
|
|
# This software may be used and distributed according to the terms of the
|
|
|
|
# GNU General Public License version 2 or any later version.
|
|
|
|
|
|
|
|
"""extends the existing commit amend functionality
|
|
|
|
|
2016-09-21 17:45:25 +03:00
|
|
|
Adds an hg amend command that amends the current parent changeset with the
|
2018-02-14 00:36:51 +03:00
|
|
|
changes in the working copy. Similar to the existing hg commit --amend
|
2014-06-02 23:54:54 +04:00
|
|
|
except it doesn't prompt for the commit message unless --edit is provided.
|
|
|
|
|
2016-09-21 17:45:25 +03:00
|
|
|
Allows amending changesets that have children and can automatically rebase
|
|
|
|
the children onto the new version of the changeset.
|
2014-06-02 23:54:54 +04:00
|
|
|
|
2014-06-12 09:34:21 +04:00
|
|
|
This extension is incompatible with changeset evolution. The command will
|
|
|
|
automatically disable itself if changeset evolution is enabled.
|
2016-10-25 21:10:47 +03:00
|
|
|
|
|
|
|
To disable the creation of preamend bookmarks and use obsolescence
|
2016-11-16 05:46:56 +03:00
|
|
|
markers instead to fix up amends, enable the userestack option::
|
2016-10-25 21:10:47 +03:00
|
|
|
|
2018-10-11 16:55:19 +03:00
|
|
|
[amend]
|
2016-11-16 05:46:56 +03:00
|
|
|
userestack = true
|
|
|
|
|
|
|
|
To make `hg previous` and `hg next` always pick the newest commit at
|
|
|
|
each step of walking up or down the stack instead of aborting when
|
2017-01-20 11:24:45 +03:00
|
|
|
encountering non-linearity (equivalent to the --newest flag), enable
|
2016-11-16 05:46:56 +03:00
|
|
|
the following config option::
|
|
|
|
|
2018-10-11 16:55:19 +03:00
|
|
|
[amend]
|
2016-11-16 05:46:56 +03:00
|
|
|
alwaysnewest = true
|
2016-10-25 21:10:47 +03:00
|
|
|
|
2017-06-19 19:50:32 +03:00
|
|
|
To automatically update the commit date, enable the following config option::
|
|
|
|
|
2018-10-11 16:55:19 +03:00
|
|
|
[amend]
|
2017-06-19 19:50:32 +03:00
|
|
|
date = implicitupdate
|
|
|
|
|
2018-07-20 01:57:29 +03:00
|
|
|
Commits are restacked automatically on amend, if doing so doesn't create
|
|
|
|
conflicts. To never automatically restack::
|
2018-02-14 00:36:51 +03:00
|
|
|
|
2018-07-20 01:57:29 +03:00
|
|
|
[amend]
|
|
|
|
autorestack = none
|
2018-02-14 00:36:51 +03:00
|
|
|
|
2017-06-19 19:50:32 +03:00
|
|
|
Note that if --date is specified on the command line, it takes precedence.
|
|
|
|
|
2018-10-01 16:15:01 +03:00
|
|
|
If a split creates multiple commits that have the same phabricator diff, the
|
|
|
|
following advice for resolution will be shown::
|
|
|
|
|
|
|
|
[split]
|
|
|
|
phabricatoradvice = edit the commit messages to remove the association
|
|
|
|
|
2014-06-02 23:54:54 +04:00
|
|
|
"""
|
|
|
|
|
2017-06-14 03:08:50 +03:00
|
|
|
from __future__ import absolute_import
|
|
|
|
|
2018-02-20 23:27:34 +03:00
|
|
|
import tempfile
|
|
|
|
|
Make hg next --rebase intelligently obsolete/inhibit changesets
Summary:
This change updates the behavior hg next --rebase. Specifically:
- Only one changeset can be rebased at a time. If there are multiple candidate changesets, the command aborts.
- Each time a changeset is rebased, its precursor is marked as obsolete, inhibition markers are stripped from it and its ancestors, and its preamend bookmark is deleted, if one exists.
- The result of this is that if no non-obsolete changesets depend on the existence of the pre-rebased changeset, that changeset and its ancestors will be stripped, resulting in a cleaner user experience.
- This change also adds back the --evolve flag, but makes it show in error instead of working. It turns out that removing the flag outright breaks the evolve extension.
Test Plan:
See updated unit tests for the exact commands to run to test this, as well as an overview of all of the new situations where behavior was changed.
A basic test plan would be:
1. Initialize a new repository, and create a stack of 4 commits.
2. Amend the second commit in the stack.
3. Do `hg next --rebase`. It should work as before.
4. Do `hg next --rebase` again. This time, the entire old stack should "disappear" from hg sl.
Additionally, attempting to run `hg next --rebase` when there are multiple possible child changesets should fail.
Reviewers: #sourcecontrol, durham
Reviewed By: durham
Subscribers: quark, mjpieters
Differential Revision: https://phabricator.intern.facebook.com/D3941922
Tasks: 13570554
Signature: t1:3941922:1475205056:58a8d1726cfcccbf14a38727be0220a09532ec97
2016-09-30 20:40:58 +03:00
|
|
|
from mercurial import (
|
|
|
|
bookmarks,
|
|
|
|
cmdutil,
|
|
|
|
commands,
|
2016-10-04 20:29:55 +03:00
|
|
|
error,
|
|
|
|
extensions,
|
2018-04-07 10:36:52 +03:00
|
|
|
hintutil,
|
2018-02-20 23:27:34 +03:00
|
|
|
lock as lockmod,
|
Make hg next --rebase intelligently obsolete/inhibit changesets
Summary:
This change updates the behavior hg next --rebase. Specifically:
- Only one changeset can be rebased at a time. If there are multiple candidate changesets, the command aborts.
- Each time a changeset is rebased, its precursor is marked as obsolete, inhibition markers are stripped from it and its ancestors, and its preamend bookmark is deleted, if one exists.
- The result of this is that if no non-obsolete changesets depend on the existence of the pre-rebased changeset, that changeset and its ancestors will be stripped, resulting in a cleaner user experience.
- This change also adds back the --evolve flag, but makes it show in error instead of working. It turns out that removing the flag outright breaks the evolve extension.
Test Plan:
See updated unit tests for the exact commands to run to test this, as well as an overview of all of the new situations where behavior was changed.
A basic test plan would be:
1. Initialize a new repository, and create a stack of 4 commits.
2. Amend the second commit in the stack.
3. Do `hg next --rebase`. It should work as before.
4. Do `hg next --rebase` again. This time, the entire old stack should "disappear" from hg sl.
Additionally, attempting to run `hg next --rebase` when there are multiple possible child changesets should fail.
Reviewers: #sourcecontrol, durham
Reviewed By: durham
Subscribers: quark, mjpieters
Differential Revision: https://phabricator.intern.facebook.com/D3941922
Tasks: 13570554
Signature: t1:3941922:1475205056:58a8d1726cfcccbf14a38727be0220a09532ec97
2016-09-30 20:40:58 +03:00
|
|
|
phases,
|
2017-05-22 23:38:37 +03:00
|
|
|
registrar,
|
2017-11-25 20:19:09 +03:00
|
|
|
scmutil,
|
Make hg next --rebase intelligently obsolete/inhibit changesets
Summary:
This change updates the behavior hg next --rebase. Specifically:
- Only one changeset can be rebased at a time. If there are multiple candidate changesets, the command aborts.
- Each time a changeset is rebased, its precursor is marked as obsolete, inhibition markers are stripped from it and its ancestors, and its preamend bookmark is deleted, if one exists.
- The result of this is that if no non-obsolete changesets depend on the existence of the pre-rebased changeset, that changeset and its ancestors will be stripped, resulting in a cleaner user experience.
- This change also adds back the --evolve flag, but makes it show in error instead of working. It turns out that removing the flag outright breaks the evolve extension.
Test Plan:
See updated unit tests for the exact commands to run to test this, as well as an overview of all of the new situations where behavior was changed.
A basic test plan would be:
1. Initialize a new repository, and create a stack of 4 commits.
2. Amend the second commit in the stack.
3. Do `hg next --rebase`. It should work as before.
4. Do `hg next --rebase` again. This time, the entire old stack should "disappear" from hg sl.
Additionally, attempting to run `hg next --rebase` when there are multiple possible child changesets should fail.
Reviewers: #sourcecontrol, durham
Reviewed By: durham
Subscribers: quark, mjpieters
Differential Revision: https://phabricator.intern.facebook.com/D3941922
Tasks: 13570554
Signature: t1:3941922:1475205056:58a8d1726cfcccbf14a38727be0220a09532ec97
2016-09-30 20:40:58 +03:00
|
|
|
)
|
2018-05-30 23:30:10 +03:00
|
|
|
from mercurial.i18n import _
|
|
|
|
from mercurial.node import hex, short
|
2017-06-17 01:50:01 +03:00
|
|
|
|
2017-06-14 03:08:50 +03:00
|
|
|
from . import (
|
2017-06-14 03:09:16 +03:00
|
|
|
common,
|
2017-06-17 00:06:24 +03:00
|
|
|
fold,
|
2017-07-13 21:04:56 +03:00
|
|
|
hiddenoverride,
|
2017-07-27 13:39:01 +03:00
|
|
|
hide,
|
2017-06-17 00:11:43 +03:00
|
|
|
metaedit,
|
2017-06-14 03:09:16 +03:00
|
|
|
movement,
|
2017-06-17 00:39:04 +03:00
|
|
|
prune,
|
2017-06-14 03:09:34 +03:00
|
|
|
restack,
|
2017-06-16 23:48:14 +03:00
|
|
|
revsets,
|
2017-06-16 23:59:12 +03:00
|
|
|
split,
|
2017-06-14 03:08:50 +03:00
|
|
|
unamend,
|
|
|
|
)
|
2018-05-30 23:30:10 +03:00
|
|
|
from .. import histedit, rebase as rebasemod
|
|
|
|
|
2017-06-14 03:08:50 +03:00
|
|
|
|
2017-06-16 23:48:14 +03:00
|
|
|
revsetpredicate = revsets.revsetpredicate
|
2018-04-07 10:36:49 +03:00
|
|
|
hint = registrar.hint()
|
2017-06-16 23:48:14 +03:00
|
|
|
|
2014-06-02 23:54:54 +04:00
|
|
|
cmdtable = {}
|
2017-05-22 23:38:37 +03:00
|
|
|
command = registrar.command(cmdtable)
|
2017-06-14 03:08:50 +03:00
|
|
|
|
2017-06-17 00:06:24 +03:00
|
|
|
cmdtable.update(fold.cmdtable)
|
2017-07-27 13:39:01 +03:00
|
|
|
cmdtable.update(hide.cmdtable)
|
2017-06-17 00:11:43 +03:00
|
|
|
cmdtable.update(metaedit.cmdtable)
|
2017-06-14 03:09:16 +03:00
|
|
|
cmdtable.update(movement.cmdtable)
|
2017-06-17 00:39:04 +03:00
|
|
|
cmdtable.update(prune.cmdtable)
|
2017-06-16 23:59:12 +03:00
|
|
|
cmdtable.update(split.cmdtable)
|
|
|
|
cmdtable.update(unamend.cmdtable)
|
2017-06-14 03:08:50 +03:00
|
|
|
|
2017-10-24 06:02:57 +03:00
|
|
|
configtable = {}
|
|
|
|
configitem = registrar.configitem(configtable)
|
|
|
|
|
2018-10-11 16:55:19 +03:00
|
|
|
configitem("amend", "alwaysnewest", default=False)
|
|
|
|
configitem("amend", "date", default=None)
|
|
|
|
configitem("amend", "education", default=None)
|
|
|
|
configitem("amend", "safestrip", default=True)
|
2018-05-30 12:16:33 +03:00
|
|
|
configitem("commands", "amend.autorebase", default=True)
|
2017-10-24 06:02:57 +03:00
|
|
|
|
2018-05-30 12:16:33 +03:00
|
|
|
testedwith = "ships-with-fb-hgext"
|
2014-06-02 23:54:54 +04:00
|
|
|
|
2015-02-12 22:02:34 +03:00
|
|
|
amendopts = [
|
2018-05-30 12:16:33 +03:00
|
|
|
("", "rebase", None, _("rebases children after the amend")),
|
|
|
|
("", "fixup", None, _("rebase children from a previous amend")),
|
|
|
|
("", "to", "", _("amend to a specific commit in the current stack")),
|
2018-09-28 17:13:55 +03:00
|
|
|
] + cmdutil.templateopts
|
2014-06-02 23:54:54 +04:00
|
|
|
|
2018-07-20 01:57:29 +03:00
|
|
|
# Never restack commits on amend.
|
|
|
|
RESTACK_NEVER = "never"
|
|
|
|
|
|
|
|
# Restack commits on amend only if they chage manifest, and don't change the
|
|
|
|
# commit manifest.
|
|
|
|
RESTACK_ONLY_TRIVIAL = "only-trivial"
|
|
|
|
|
|
|
|
# Restack commits on amend only if doing so won't create merge conflicts.
|
|
|
|
RESTACK_NO_CONFLICT = "no-conflict"
|
|
|
|
|
|
|
|
# Always attempt to restack commits on amend, even if doing so will leave the
|
|
|
|
# user in a conflicted state.
|
|
|
|
RESTACK_ALWAYS = "always"
|
|
|
|
|
|
|
|
# Possible restack values for `amend.autorestack`.
|
|
|
|
RESTACK_VALUES = [
|
|
|
|
RESTACK_NEVER,
|
|
|
|
RESTACK_ONLY_TRIVIAL,
|
|
|
|
RESTACK_NO_CONFLICT,
|
|
|
|
RESTACK_ALWAYS,
|
|
|
|
]
|
|
|
|
|
|
|
|
RESTACK_DEFAULT = RESTACK_ONLY_TRIVIAL
|
|
|
|
|
2018-05-30 12:16:33 +03:00
|
|
|
|
|
|
|
@hint("strip-hide")
|
2018-04-07 10:36:49 +03:00
|
|
|
def hinthide():
|
2018-05-30 12:16:33 +03:00
|
|
|
return _("'hg strip' may be deprecated in the future - " "use 'hg hide' instead")
|
2018-04-07 10:36:49 +03:00
|
|
|
|
2018-05-30 12:16:33 +03:00
|
|
|
|
|
|
|
@hint("strip-uncommit")
|
2018-04-07 10:36:49 +03:00
|
|
|
def hintstrip():
|
2018-05-30 12:16:33 +03:00
|
|
|
return _(
|
|
|
|
"'hg strip' may be deprecated in the future - "
|
|
|
|
"use 'hg uncommit' or 'hg undo -k' to undo commits"
|
|
|
|
)
|
|
|
|
|
2018-04-07 10:36:49 +03:00
|
|
|
|
2018-05-30 12:16:33 +03:00
|
|
|
@hint("amend-restack")
|
2018-04-07 10:36:52 +03:00
|
|
|
def hintrestack(node):
|
2018-05-30 12:16:33 +03:00
|
|
|
return _(
|
|
|
|
"descendants of %s are left behind - use 'hg restack' to rebase " "them"
|
|
|
|
) % short(node)
|
|
|
|
|
2018-04-07 10:36:52 +03:00
|
|
|
|
2018-05-30 12:16:33 +03:00
|
|
|
@hint("amend-autorebase")
|
2018-04-07 10:36:54 +03:00
|
|
|
def hintautorebase():
|
2018-05-30 12:16:33 +03:00
|
|
|
return _(
|
|
|
|
"descendants have been auto-rebased because no merge conflict "
|
|
|
|
"could have happened - use --no-rebase or set "
|
|
|
|
"commands.amend.autorebase=False to disable auto rebase"
|
|
|
|
)
|
2018-04-07 10:36:54 +03:00
|
|
|
|
2018-05-30 12:16:33 +03:00
|
|
|
|
|
|
|
@hint("update-prev")
|
2018-04-07 10:36:56 +03:00
|
|
|
def hintprev():
|
|
|
|
return _("use 'hg prev' to move to the parent changeset")
|
|
|
|
|
2018-05-30 12:16:33 +03:00
|
|
|
|
2018-10-01 16:15:01 +03:00
|
|
|
@hint("split-phabricator")
|
|
|
|
def hintsplitphabricator(advice):
|
|
|
|
msg = _("some split commits have the same Phabricator Diff associated with them")
|
|
|
|
if advice:
|
|
|
|
msg += "\n" + advice
|
|
|
|
return msg
|
|
|
|
|
|
|
|
|
2014-06-02 23:54:54 +04:00
|
|
|
def uisetup(ui):
|
2017-07-13 21:04:56 +03:00
|
|
|
hiddenoverride.uisetup(ui)
|
2017-06-17 00:39:04 +03:00
|
|
|
prune.uisetup(ui)
|
2018-05-30 12:16:33 +03:00
|
|
|
entry = extensions.wrapcommand(commands.table, "commit", commit)
|
2014-06-02 23:54:54 +04:00
|
|
|
for opt in amendopts:
|
|
|
|
opt = (opt[0], opt[1], opt[2], "(with --amend) " + opt[3])
|
|
|
|
entry[1].append(opt)
|
2016-09-23 20:39:36 +03:00
|
|
|
|
2014-06-12 09:34:21 +04:00
|
|
|
# manual call of the decorator
|
2018-05-30 12:16:33 +03:00
|
|
|
command(
|
|
|
|
"^amend",
|
|
|
|
[
|
|
|
|
(
|
|
|
|
"A",
|
|
|
|
"addremove",
|
|
|
|
None,
|
|
|
|
_("mark new/missing files as added/removed before committing"),
|
|
|
|
),
|
|
|
|
("e", "edit", None, _("prompt to edit the commit message")),
|
|
|
|
("i", "interactive", None, _("use interactive mode")),
|
|
|
|
]
|
|
|
|
+ amendopts
|
|
|
|
+ commands.walkopts
|
|
|
|
+ commands.commitopts
|
2017-06-19 23:24:41 +03:00
|
|
|
+ commands.commitopts2,
|
2018-05-30 12:16:33 +03:00
|
|
|
_("hg amend [OPTION]..."),
|
|
|
|
)(amend)
|
2014-06-12 09:34:21 +04:00
|
|
|
|
2016-02-04 14:03:31 +03:00
|
|
|
def has_automv(loaded):
|
|
|
|
if not loaded:
|
|
|
|
return
|
2018-05-30 12:16:33 +03:00
|
|
|
automv = extensions.find("automv")
|
|
|
|
entry = extensions.wrapcommand(cmdtable, "amend", automv.mvcheck)
|
2016-02-04 14:03:31 +03:00
|
|
|
entry[1].append(
|
2018-05-30 12:16:33 +03:00
|
|
|
("", "no-move-detection", None, _("disable automatic file move detection"))
|
|
|
|
)
|
|
|
|
|
|
|
|
extensions.afterloaded("automv", has_automv)
|
2016-02-04 14:03:31 +03:00
|
|
|
|
2016-11-03 21:11:39 +03:00
|
|
|
def evolveloaded(loaded):
|
2016-09-23 20:39:36 +03:00
|
|
|
if not loaded:
|
|
|
|
return
|
Make hg next --rebase intelligently obsolete/inhibit changesets
Summary:
This change updates the behavior hg next --rebase. Specifically:
- Only one changeset can be rebased at a time. If there are multiple candidate changesets, the command aborts.
- Each time a changeset is rebased, its precursor is marked as obsolete, inhibition markers are stripped from it and its ancestors, and its preamend bookmark is deleted, if one exists.
- The result of this is that if no non-obsolete changesets depend on the existence of the pre-rebased changeset, that changeset and its ancestors will be stripped, resulting in a cleaner user experience.
- This change also adds back the --evolve flag, but makes it show in error instead of working. It turns out that removing the flag outright breaks the evolve extension.
Test Plan:
See updated unit tests for the exact commands to run to test this, as well as an overview of all of the new situations where behavior was changed.
A basic test plan would be:
1. Initialize a new repository, and create a stack of 4 commits.
2. Amend the second commit in the stack.
3. Do `hg next --rebase`. It should work as before.
4. Do `hg next --rebase` again. This time, the entire old stack should "disappear" from hg sl.
Additionally, attempting to run `hg next --rebase` when there are multiple possible child changesets should fail.
Reviewers: #sourcecontrol, durham
Reviewed By: durham
Subscribers: quark, mjpieters
Differential Revision: https://phabricator.intern.facebook.com/D3941922
Tasks: 13570554
Signature: t1:3941922:1475205056:58a8d1726cfcccbf14a38727be0220a09532ec97
2016-09-30 20:40:58 +03:00
|
|
|
|
2018-05-30 12:16:33 +03:00
|
|
|
evolvemod = extensions.find("evolve")
|
2016-11-16 05:46:56 +03:00
|
|
|
|
2017-06-16 23:59:12 +03:00
|
|
|
# Remove conflicted commands from evolve.
|
2017-06-14 03:09:16 +03:00
|
|
|
table = evolvemod.cmdtable
|
2018-05-30 12:16:33 +03:00
|
|
|
for name in ["prev", "next", "split", "fold", "metaedit", "prune"]:
|
2017-06-15 20:35:28 +03:00
|
|
|
todelete = [k for k in table if name in k]
|
|
|
|
for k in todelete:
|
|
|
|
oldentry = table[k]
|
2018-05-30 12:16:33 +03:00
|
|
|
table["debugevolve%s" % name] = oldentry
|
2017-06-15 20:35:28 +03:00
|
|
|
del table[k]
|
2017-01-20 11:24:45 +03:00
|
|
|
|
2018-05-30 12:16:33 +03:00
|
|
|
extensions.afterloaded("evolve", evolveloaded)
|
2016-02-04 14:03:31 +03:00
|
|
|
|
2016-11-03 21:11:39 +03:00
|
|
|
def rebaseloaded(loaded):
|
Add hg rebase --restack
Summary:
This change adds a `--restack` option to `hg rebase`. When invoked, the command will rebase all descendants of precursors of the current changeset onto the current changeset. This is similar to the behavior of `hg evolve --all`, except it only handles unstable changesets, and not other issues that can arise from shared mutable history such as divergence or bumping.
I've been playing around with some of the more advanced features (such as allowing the command to be run from anywhere in the old stack or new stack, as well as allowing the user to specify the number of changesets to rebase), but I wanted to upload the most simple iteration of this command for feedback.
Test Plan:
See unit tests for complete commands.
1. Create a stack of commits.
2. Somewhere in the middle of the stack, amend a commit, potentially several times.
3. Run `hg rebase --restack`.
4. The top half of the stack should be rebased onto the amended commit, and the preamend bookmark should be gone.
Reviewers: #sourcecontrol, durham
Reviewed By: durham
Subscribers: rmcelroy, quark, mjpieters
Differential Revision: https://phabricator.intern.facebook.com/D3972103
Tasks: 13651947
Signature: t1:3972103:1476230834:8f77eac4e8d8681dd9f8125747c1ff75c8da1ad8
2016-10-12 03:41:07 +03:00
|
|
|
if not loaded:
|
|
|
|
return
|
2018-05-30 12:16:33 +03:00
|
|
|
entry = extensions.wrapcommand(rebasemod.cmdtable, "rebase", wraprebase)
|
|
|
|
entry[1].append(
|
|
|
|
(
|
|
|
|
"",
|
|
|
|
"restack",
|
|
|
|
False,
|
|
|
|
_(
|
|
|
|
"rebase all changesets in the current "
|
|
|
|
"stack onto the latest version of their "
|
|
|
|
"respective parents"
|
|
|
|
),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
extensions.afterloaded("rebase", rebaseloaded)
|
|
|
|
|
Add hg rebase --restack
Summary:
This change adds a `--restack` option to `hg rebase`. When invoked, the command will rebase all descendants of precursors of the current changeset onto the current changeset. This is similar to the behavior of `hg evolve --all`, except it only handles unstable changesets, and not other issues that can arise from shared mutable history such as divergence or bumping.
I've been playing around with some of the more advanced features (such as allowing the command to be run from anywhere in the old stack or new stack, as well as allowing the user to specify the number of changesets to rebase), but I wanted to upload the most simple iteration of this command for feedback.
Test Plan:
See unit tests for complete commands.
1. Create a stack of commits.
2. Somewhere in the middle of the stack, amend a commit, potentially several times.
3. Run `hg rebase --restack`.
4. The top half of the stack should be rebased onto the amended commit, and the preamend bookmark should be gone.
Reviewers: #sourcecontrol, durham
Reviewed By: durham
Subscribers: rmcelroy, quark, mjpieters
Differential Revision: https://phabricator.intern.facebook.com/D3972103
Tasks: 13651947
Signature: t1:3972103:1476230834:8f77eac4e8d8681dd9f8125747c1ff75c8da1ad8
2016-10-12 03:41:07 +03:00
|
|
|
|
2018-09-28 17:13:55 +03:00
|
|
|
def showtemplate(ui, repo, rev, **opts):
|
|
|
|
if opts.get("template"):
|
|
|
|
displayer = cmdutil.show_changeset(ui, repo, opts)
|
|
|
|
displayer.show(rev)
|
|
|
|
|
|
|
|
|
2014-06-02 23:54:54 +04:00
|
|
|
def commit(orig, ui, repo, *pats, **opts):
|
|
|
|
if opts.get("amend"):
|
|
|
|
# commit --amend default behavior is to prompt for edit
|
2018-05-30 12:16:33 +03:00
|
|
|
opts["noeditmessage"] = True
|
2014-06-02 23:54:54 +04:00
|
|
|
return amend(ui, repo, *pats, **opts)
|
|
|
|
else:
|
2018-05-30 12:16:33 +03:00
|
|
|
badflags = [flag for flag in ["rebase", "fixup"] if opts.get(flag, None)]
|
2015-10-27 02:19:40 +03:00
|
|
|
if badflags:
|
2018-05-30 12:16:33 +03:00
|
|
|
raise error.Abort(_("--%s must be called with --amend") % badflags[0])
|
2015-10-27 02:19:40 +03:00
|
|
|
|
2018-09-28 17:13:55 +03:00
|
|
|
rc = orig(ui, repo, *pats, **opts)
|
|
|
|
current = repo["."]
|
|
|
|
showtemplate(ui, repo, current, **opts)
|
|
|
|
return rc
|
2014-06-02 23:54:54 +04:00
|
|
|
|
2018-05-30 12:16:33 +03:00
|
|
|
|
2014-06-02 23:54:54 +04:00
|
|
|
def amend(ui, repo, *pats, **opts):
|
2018-05-30 12:16:33 +03:00
|
|
|
"""amend the current changeset with more changes
|
|
|
|
"""
|
2017-12-28 09:54:03 +03:00
|
|
|
# 'rebase' is a tristate option: None=auto, True=force, False=disable
|
2018-05-30 12:16:33 +03:00
|
|
|
rebase = opts.get("rebase")
|
|
|
|
to = opts.get("to")
|
2014-06-02 23:54:54 +04:00
|
|
|
|
2015-02-12 22:02:34 +03:00
|
|
|
if rebase and _histediting(repo):
|
|
|
|
# if a histedit is in flight, it's dangerous to remove old commits
|
2018-05-30 12:16:33 +03:00
|
|
|
hint = _("during histedit, use amend without --rebase")
|
|
|
|
raise error.Abort("histedit in progress", hint=hint)
|
2015-02-12 22:02:34 +03:00
|
|
|
|
2018-05-30 12:16:33 +03:00
|
|
|
badflags = [flag for flag in ["rebase", "fixup"] if opts.get(flag, None)]
|
|
|
|
if opts.get("interactive") and badflags:
|
|
|
|
raise error.Abort(
|
|
|
|
_("--interactive and --%s are mutually exclusive") % badflags[0]
|
|
|
|
)
|
2015-10-24 03:00:56 +03:00
|
|
|
|
2018-05-30 12:16:33 +03:00
|
|
|
fixup = opts.get("fixup")
|
2017-07-14 22:06:22 +03:00
|
|
|
|
|
|
|
badtoflags = [
|
2018-05-30 12:16:33 +03:00
|
|
|
"rebase",
|
|
|
|
"fixup",
|
|
|
|
"addremove",
|
|
|
|
"edit",
|
|
|
|
"interactive",
|
|
|
|
"include",
|
|
|
|
"exclude",
|
|
|
|
"message",
|
|
|
|
"logfile",
|
|
|
|
"date",
|
|
|
|
"user",
|
|
|
|
"no-move-detection",
|
|
|
|
"stack",
|
2018-09-28 17:13:55 +03:00
|
|
|
"template",
|
2017-07-14 22:06:22 +03:00
|
|
|
]
|
|
|
|
|
|
|
|
if to and any(opts.get(flag, None) for flag in badtoflags):
|
2018-05-30 12:16:33 +03:00
|
|
|
raise error.Abort(_("--to cannot be used with any other options"))
|
2017-07-14 22:06:22 +03:00
|
|
|
|
2014-06-02 23:54:54 +04:00
|
|
|
if fixup:
|
|
|
|
fixupamend(ui, repo)
|
|
|
|
return
|
|
|
|
|
2017-07-14 22:06:22 +03:00
|
|
|
if to:
|
|
|
|
amendtocommit(ui, repo, to)
|
|
|
|
return
|
|
|
|
|
2018-05-30 12:16:33 +03:00
|
|
|
old = repo["."]
|
2014-06-02 23:54:54 +04:00
|
|
|
if old.phase() == phases.public:
|
2018-05-30 12:16:33 +03:00
|
|
|
raise error.Abort(_("cannot amend public changesets"))
|
2014-06-02 23:54:54 +04:00
|
|
|
if len(repo[None].parents()) > 1:
|
2018-05-30 12:16:33 +03:00
|
|
|
raise error.Abort(_("cannot amend while merging"))
|
2014-06-02 23:54:54 +04:00
|
|
|
|
|
|
|
haschildren = len(old.children()) > 0
|
|
|
|
|
2018-10-27 21:30:08 +03:00
|
|
|
opts["message"] = cmdutil.logmessage(ui, opts, oldmessage=old.description())
|
2015-10-28 00:37:20 +03:00
|
|
|
# Avoid further processing of any logfile. If such a file existed, its
|
|
|
|
# contents have been copied into opts['message'] by logmessage
|
2018-05-30 12:16:33 +03:00
|
|
|
opts["logfile"] = ""
|
2015-10-28 00:37:20 +03:00
|
|
|
|
2018-05-30 12:16:33 +03:00
|
|
|
if not opts.get("noeditmessage") and not opts.get("message"):
|
|
|
|
opts["message"] = old.description()
|
2014-06-02 23:54:54 +04:00
|
|
|
|
2018-05-30 12:16:33 +03:00
|
|
|
commitdate = opts.get("date")
|
2017-06-19 19:50:32 +03:00
|
|
|
if not commitdate:
|
2018-10-11 16:55:19 +03:00
|
|
|
if ui.config("amend", "date") == "implicitupdate":
|
2018-05-30 12:16:33 +03:00
|
|
|
commitdate = "now"
|
2017-06-19 19:50:32 +03:00
|
|
|
else:
|
|
|
|
commitdate = old.date()
|
2014-06-02 23:54:54 +04:00
|
|
|
|
|
|
|
oldbookmarks = old.bookmarks()
|
2015-12-14 22:30:33 +03:00
|
|
|
tr = None
|
2015-08-04 19:10:50 +03:00
|
|
|
wlock = None
|
|
|
|
lock = None
|
|
|
|
try:
|
|
|
|
wlock = repo.wlock()
|
|
|
|
lock = repo.lock()
|
2015-10-24 03:00:56 +03:00
|
|
|
|
2018-05-30 12:16:33 +03:00
|
|
|
if opts.get("interactive"):
|
2015-10-24 03:00:56 +03:00
|
|
|
# Strip the interactive flag to avoid infinite recursive loop
|
2018-05-30 12:16:33 +03:00
|
|
|
opts.pop("interactive")
|
|
|
|
cmdutil.dorecord(
|
|
|
|
ui, repo, amend, None, False, cmdutil.recordfilter, *pats, **opts
|
|
|
|
)
|
2015-10-24 03:00:56 +03:00
|
|
|
return
|
|
|
|
|
|
|
|
else:
|
2017-09-08 20:07:41 +03:00
|
|
|
node = cmdutil.amend(ui, repo, old, {}, pats, opts)
|
2015-08-04 19:10:50 +03:00
|
|
|
|
|
|
|
if node == old.node():
|
|
|
|
ui.status(_("nothing changed\n"))
|
2017-06-17 01:50:01 +03:00
|
|
|
return 1
|
2015-08-04 19:10:50 +03:00
|
|
|
|
2018-07-20 01:57:29 +03:00
|
|
|
conf = ui.config("amend", "autorestack", RESTACK_DEFAULT)
|
|
|
|
noconflict = None
|
|
|
|
|
|
|
|
# RESTACK_NO_CONFLICT requires IMM.
|
|
|
|
if conf == RESTACK_NO_CONFLICT and not ui.config(
|
|
|
|
"rebase", "experimental.inmemory", False
|
|
|
|
):
|
|
|
|
conf = RESTACK_DEFAULT
|
|
|
|
|
|
|
|
# If they explicitly disabled the old behavior, disable the new behavior
|
|
|
|
# too, for now.
|
|
|
|
# internal config: commands.amend.autorebase
|
|
|
|
if ui.configbool("commands", "amend.autorebase") is False:
|
|
|
|
# In the future we'll add a nag message here.
|
|
|
|
conf = RESTACK_NEVER
|
|
|
|
|
|
|
|
if conf not in RESTACK_VALUES:
|
|
|
|
ui.warn(
|
|
|
|
_('invalid amend.autorestack config of "%s"; falling back to %s\n')
|
|
|
|
% (conf, RESTACK_DEFAULT)
|
|
|
|
)
|
|
|
|
conf = RESTACK_DEFAULT
|
|
|
|
|
2017-12-28 09:54:03 +03:00
|
|
|
if haschildren and rebase is None and not _histediting(repo):
|
2018-07-20 01:57:29 +03:00
|
|
|
if conf == RESTACK_ALWAYS:
|
|
|
|
rebase = True
|
|
|
|
elif conf == RESTACK_NO_CONFLICT:
|
|
|
|
if repo[None].dirty():
|
|
|
|
# For now, only restack if the WC is clean (t31742174).
|
|
|
|
ui.status(_("not restacking because working copy is dirty\n"))
|
2018-02-14 00:36:51 +03:00
|
|
|
rebase = False
|
2018-07-20 01:57:29 +03:00
|
|
|
else:
|
|
|
|
# internal config: amend.autorestackmsg
|
|
|
|
msg = ui.config(
|
|
|
|
"amend",
|
|
|
|
"autorestackmsg",
|
|
|
|
_("restacking children automatically (unless they conflict)"),
|
|
|
|
)
|
|
|
|
if msg:
|
|
|
|
ui.status("%s\n" % msg)
|
|
|
|
rebase = True
|
|
|
|
noconflict = True
|
|
|
|
elif conf == RESTACK_ONLY_TRIVIAL:
|
|
|
|
newcommit = repo[node]
|
|
|
|
# If the rebase did not change the manifest and the
|
|
|
|
# working copy is clean, force the children to be
|
|
|
|
# restacked.
|
|
|
|
rebase = (
|
|
|
|
old.manifestnode() == newcommit.manifestnode()
|
|
|
|
and not repo[None].dirty()
|
|
|
|
)
|
|
|
|
if rebase:
|
|
|
|
hintutil.trigger("amend-autorebase")
|
|
|
|
else:
|
|
|
|
rebase = False
|
2017-12-28 09:54:03 +03:00
|
|
|
|
2018-04-07 10:36:52 +03:00
|
|
|
if haschildren and not rebase and not _histediting(repo):
|
2018-05-30 12:16:33 +03:00
|
|
|
hintutil.trigger("amend-restack", old.node())
|
2015-08-04 19:10:50 +03:00
|
|
|
|
2017-07-18 20:09:28 +03:00
|
|
|
changes = []
|
2015-08-04 19:10:50 +03:00
|
|
|
# move old bookmarks to new node
|
|
|
|
for bm in oldbookmarks:
|
2017-07-18 20:09:28 +03:00
|
|
|
changes.append((bm, node))
|
2015-08-04 19:10:50 +03:00
|
|
|
|
2018-05-30 12:16:33 +03:00
|
|
|
tr = repo.transaction("fixupamend")
|
2017-07-18 20:09:28 +03:00
|
|
|
repo._bookmarks.applychanges(repo, tr, changes)
|
2015-12-14 22:30:33 +03:00
|
|
|
tr.close()
|
2015-08-04 19:10:50 +03:00
|
|
|
|
|
|
|
if rebase and haschildren:
|
2018-07-20 01:57:29 +03:00
|
|
|
noconflictmsg = _(
|
|
|
|
"restacking would create conflicts (%s in %s), so you must run it manually\n(run `hg restack` manually to restack this commit's children)"
|
|
|
|
)
|
|
|
|
fixupamend(ui, repo, noconflict=noconflict, noconflictmsg=noconflictmsg)
|
2018-09-28 17:13:55 +03:00
|
|
|
|
|
|
|
showtemplate(ui, repo, repo[node], **opts)
|
2015-08-04 19:10:50 +03:00
|
|
|
finally:
|
2015-12-14 22:30:33 +03:00
|
|
|
lockmod.release(wlock, lock, tr)
|
2014-06-02 23:54:54 +04:00
|
|
|
|
2018-05-30 12:16:33 +03:00
|
|
|
|
2018-07-20 01:57:29 +03:00
|
|
|
def fixupamend(ui, repo, noconflict=None, noconflictmsg=None):
|
2016-09-21 17:45:25 +03:00
|
|
|
"""rebases any children found on the preamend changset and strips the
|
|
|
|
preamend changset
|
2014-06-02 23:54:54 +04:00
|
|
|
"""
|
2015-08-04 19:10:50 +03:00
|
|
|
wlock = None
|
|
|
|
lock = None
|
2015-12-14 22:30:33 +03:00
|
|
|
tr = None
|
2015-08-04 19:10:50 +03:00
|
|
|
try:
|
|
|
|
wlock = repo.wlock()
|
|
|
|
lock = repo.lock()
|
2018-05-30 12:16:33 +03:00
|
|
|
current = repo["."]
|
2014-06-02 23:54:54 +04:00
|
|
|
|
2018-02-20 23:27:34 +03:00
|
|
|
# Use obsolescence information to fix up the amend.
|
2018-07-20 01:57:29 +03:00
|
|
|
common.restackonce(
|
|
|
|
ui, repo, current.rev(), noconflict=noconflict, noconflictmsg=noconflictmsg
|
|
|
|
)
|
2015-08-04 19:10:50 +03:00
|
|
|
finally:
|
2015-12-14 22:30:33 +03:00
|
|
|
lockmod.release(wlock, lock, tr)
|
2015-02-12 12:26:20 +03:00
|
|
|
|
2018-05-30 12:16:33 +03:00
|
|
|
|
2017-11-25 20:19:09 +03:00
|
|
|
def amendtocommit(ui, repo, commitspec):
|
2017-07-14 22:06:22 +03:00
|
|
|
"""amend to a specific commit
|
|
|
|
"""
|
|
|
|
with repo.wlock(), repo.lock():
|
|
|
|
originalcommits = list(repo.set("::. - public()"))
|
2017-11-25 20:19:09 +03:00
|
|
|
try:
|
|
|
|
revs = scmutil.revrange(repo, [commitspec])
|
|
|
|
except error.RepoLookupError:
|
2018-05-30 12:16:33 +03:00
|
|
|
raise error.Abort(_("revision '%s' cannot be found") % commitspec)
|
2017-11-25 20:19:09 +03:00
|
|
|
if len(revs) > 1:
|
2018-05-30 12:16:33 +03:00
|
|
|
raise error.Abort(_("'%s' refers to multiple changesets") % commitspec)
|
2017-11-25 20:19:09 +03:00
|
|
|
targetcommit = repo[revs.first()]
|
|
|
|
if targetcommit not in originalcommits:
|
2018-05-30 12:16:33 +03:00
|
|
|
raise error.Abort(
|
2018-05-30 23:30:10 +03:00
|
|
|
_("revision '%s' is not a parent of the working copy") % commitspec
|
2018-05-30 12:16:33 +03:00
|
|
|
)
|
2017-11-25 20:19:09 +03:00
|
|
|
|
2017-07-14 22:06:22 +03:00
|
|
|
tempcommit = repo.commit(text="tempCommit")
|
|
|
|
|
|
|
|
if not tempcommit:
|
2018-05-30 12:16:33 +03:00
|
|
|
raise error.Abort(_("no pending changes to amend"))
|
2017-07-14 22:06:22 +03:00
|
|
|
|
|
|
|
tempcommithex = hex(tempcommit)
|
|
|
|
|
|
|
|
fp = tempfile.NamedTemporaryFile()
|
|
|
|
try:
|
|
|
|
found = False
|
2017-11-25 20:19:09 +03:00
|
|
|
for curcommit in originalcommits:
|
|
|
|
fp.write("pick " + str(curcommit) + "\n")
|
|
|
|
if curcommit == targetcommit:
|
2017-07-14 22:06:22 +03:00
|
|
|
fp.write("roll " + tempcommithex[:12] + "\n")
|
|
|
|
found = True
|
|
|
|
if not found:
|
2018-05-30 12:16:33 +03:00
|
|
|
raise error.Abort(_("revision '%s' cannot be found") % commitspec)
|
2017-07-14 22:06:22 +03:00
|
|
|
fp.flush()
|
|
|
|
try:
|
|
|
|
histedit.histedit(ui, repo, commands=fp.name)
|
|
|
|
except error.InterventionRequired:
|
2018-05-30 12:16:33 +03:00
|
|
|
ui.warn(
|
|
|
|
_(
|
|
|
|
"amend --to encountered an issue - "
|
|
|
|
"use hg histedit to continue or abort"
|
|
|
|
)
|
|
|
|
)
|
2017-07-14 22:06:22 +03:00
|
|
|
raise
|
|
|
|
finally:
|
|
|
|
fp.close()
|
|
|
|
|
2018-05-30 12:16:33 +03:00
|
|
|
|
2018-06-07 01:21:34 +03:00
|
|
|
def wraprebase(orig, ui, repo, *pats, **opts):
|
Add hg rebase --restack
Summary:
This change adds a `--restack` option to `hg rebase`. When invoked, the command will rebase all descendants of precursors of the current changeset onto the current changeset. This is similar to the behavior of `hg evolve --all`, except it only handles unstable changesets, and not other issues that can arise from shared mutable history such as divergence or bumping.
I've been playing around with some of the more advanced features (such as allowing the command to be run from anywhere in the old stack or new stack, as well as allowing the user to specify the number of changesets to rebase), but I wanted to upload the most simple iteration of this command for feedback.
Test Plan:
See unit tests for complete commands.
1. Create a stack of commits.
2. Somewhere in the middle of the stack, amend a commit, potentially several times.
3. Run `hg rebase --restack`.
4. The top half of the stack should be rebased onto the amended commit, and the preamend bookmark should be gone.
Reviewers: #sourcecontrol, durham
Reviewed By: durham
Subscribers: rmcelroy, quark, mjpieters
Differential Revision: https://phabricator.intern.facebook.com/D3972103
Tasks: 13651947
Signature: t1:3972103:1476230834:8f77eac4e8d8681dd9f8125747c1ff75c8da1ad8
2016-10-12 03:41:07 +03:00
|
|
|
"""Wrapper around `hg rebase` adding the `--restack` option, which rebases
|
2016-10-14 21:05:53 +03:00
|
|
|
all "unstable" descendants of an obsolete changeset onto the latest
|
|
|
|
version of that changeset. This is similar to (and intended as a
|
|
|
|
replacement for) the `hg evolve --all` command.
|
Add hg rebase --restack
Summary:
This change adds a `--restack` option to `hg rebase`. When invoked, the command will rebase all descendants of precursors of the current changeset onto the current changeset. This is similar to the behavior of `hg evolve --all`, except it only handles unstable changesets, and not other issues that can arise from shared mutable history such as divergence or bumping.
I've been playing around with some of the more advanced features (such as allowing the command to be run from anywhere in the old stack or new stack, as well as allowing the user to specify the number of changesets to rebase), but I wanted to upload the most simple iteration of this command for feedback.
Test Plan:
See unit tests for complete commands.
1. Create a stack of commits.
2. Somewhere in the middle of the stack, amend a commit, potentially several times.
3. Run `hg rebase --restack`.
4. The top half of the stack should be rebased onto the amended commit, and the preamend bookmark should be gone.
Reviewers: #sourcecontrol, durham
Reviewed By: durham
Subscribers: rmcelroy, quark, mjpieters
Differential Revision: https://phabricator.intern.facebook.com/D3972103
Tasks: 13651947
Signature: t1:3972103:1476230834:8f77eac4e8d8681dd9f8125747c1ff75c8da1ad8
2016-10-12 03:41:07 +03:00
|
|
|
"""
|
2018-05-30 12:16:33 +03:00
|
|
|
if opts["restack"]:
|
2017-01-11 00:53:43 +03:00
|
|
|
# We can't abort if --dest is passed because some extensions
|
|
|
|
# (namely remotenames) will automatically add this flag.
|
|
|
|
# So just silently drop it instead.
|
2018-05-30 12:16:33 +03:00
|
|
|
opts.pop("dest", None)
|
2017-01-11 00:53:43 +03:00
|
|
|
|
2018-05-30 12:16:33 +03:00
|
|
|
if opts["rev"]:
|
2016-11-03 21:11:39 +03:00
|
|
|
raise error.Abort(_("cannot use both --rev and --restack"))
|
2018-05-30 12:16:33 +03:00
|
|
|
if opts["source"]:
|
2016-11-03 21:11:39 +03:00
|
|
|
raise error.Abort(_("cannot use both --source and --restack"))
|
2018-05-30 12:16:33 +03:00
|
|
|
if opts["base"]:
|
2016-11-03 21:11:39 +03:00
|
|
|
raise error.Abort(_("cannot use both --base and --restack"))
|
2018-05-30 12:16:33 +03:00
|
|
|
if opts["abort"]:
|
2016-11-03 21:11:39 +03:00
|
|
|
raise error.Abort(_("cannot use both --abort and --restack"))
|
2018-05-30 12:16:33 +03:00
|
|
|
if opts["continue"]:
|
2016-11-03 21:11:39 +03:00
|
|
|
raise error.Abort(_("cannot use both --continue and --restack"))
|
2017-01-26 02:48:12 +03:00
|
|
|
|
|
|
|
# The --hidden option is handled at a higher level, so instead of
|
|
|
|
# checking for it directly we have to check whether the repo
|
|
|
|
# is unfiltered.
|
|
|
|
if repo == repo.unfiltered():
|
|
|
|
raise error.Abort(_("cannot use both --hidden and --restack"))
|
|
|
|
|
2017-06-14 03:09:34 +03:00
|
|
|
return restack.restack(ui, repo, opts)
|
Add hg rebase --restack
Summary:
This change adds a `--restack` option to `hg rebase`. When invoked, the command will rebase all descendants of precursors of the current changeset onto the current changeset. This is similar to the behavior of `hg evolve --all`, except it only handles unstable changesets, and not other issues that can arise from shared mutable history such as divergence or bumping.
I've been playing around with some of the more advanced features (such as allowing the command to be run from anywhere in the old stack or new stack, as well as allowing the user to specify the number of changesets to rebase), but I wanted to upload the most simple iteration of this command for feedback.
Test Plan:
See unit tests for complete commands.
1. Create a stack of commits.
2. Somewhere in the middle of the stack, amend a commit, potentially several times.
3. Run `hg rebase --restack`.
4. The top half of the stack should be rebased onto the amended commit, and the preamend bookmark should be gone.
Reviewers: #sourcecontrol, durham
Reviewed By: durham
Subscribers: rmcelroy, quark, mjpieters
Differential Revision: https://phabricator.intern.facebook.com/D3972103
Tasks: 13651947
Signature: t1:3972103:1476230834:8f77eac4e8d8681dd9f8125747c1ff75c8da1ad8
2016-10-12 03:41:07 +03:00
|
|
|
|
2018-06-07 01:21:34 +03:00
|
|
|
return orig(ui, repo, *pats, **opts)
|
2016-10-25 21:10:47 +03:00
|
|
|
|
2018-05-30 12:16:33 +03:00
|
|
|
|
2015-02-12 13:16:28 +03:00
|
|
|
def _preamendname(repo, node):
|
2018-05-30 12:16:33 +03:00
|
|
|
suffix = ".preamend"
|
2018-10-18 18:23:26 +03:00
|
|
|
name = repo._activebookmark
|
2015-02-12 13:16:28 +03:00
|
|
|
if not name:
|
2015-02-13 07:43:29 +03:00
|
|
|
name = hex(node)[:12]
|
2015-02-12 13:16:28 +03:00
|
|
|
return name + suffix
|
|
|
|
|
2018-05-30 12:16:33 +03:00
|
|
|
|
2015-02-12 22:02:34 +03:00
|
|
|
def _histediting(repo):
|
2018-09-28 17:08:56 +03:00
|
|
|
return repo.localvfs.exists("histedit-state")
|
2018-05-30 12:16:33 +03:00
|
|
|
|
2015-02-12 22:02:34 +03:00
|
|
|
|
2017-02-02 02:14:17 +03:00
|
|
|
def _fixbookmarks(repo, revs):
|
|
|
|
"""Make any bookmarks pointing to the given revisions point to the
|
|
|
|
latest version of each respective revision.
|
|
|
|
"""
|
|
|
|
repo = repo.unfiltered()
|
|
|
|
cl = repo.changelog
|
2018-05-30 12:16:33 +03:00
|
|
|
with repo.wlock(), repo.lock(), repo.transaction("movebookmarks") as tr:
|
2017-07-18 20:09:28 +03:00
|
|
|
changes = []
|
2017-07-17 22:02:08 +03:00
|
|
|
for rev in revs:
|
|
|
|
latest = cl.node(common.latest(repo, rev))
|
|
|
|
for bm in repo.nodebookmarks(cl.node(rev)):
|
2017-07-18 20:09:28 +03:00
|
|
|
changes.append((bm, latest))
|
|
|
|
repo._bookmarks.applychanges(repo, tr, changes)
|