D1576: amend: extract function for calculating changeset extras
martinvonz (Martin von Zweigbergk)
phabricator at mercurial-scm.org
Fri Dec 1 22:43:59 UTC 2017
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.
REVISION SUMMARY
We (Google) have extensions that would like to put their own entries
in the extras. Some of these don't make sense to keep on amend
(e.g. an entry saying "this corresponds to snaphot X of review unit
Y"). So this patch extracts a function for calculating the extras so
our extension can more easily override it.
REPOSITORY
rHG Mercurial
REVISION DETAIL
https://phab.mercurial-scm.org/D1576
AFFECTED FILES
mercurial/cmdutil.py
CHANGE DETAILS
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -3114,6 +3114,22 @@
else:
return f not in ctx2.manifest()
+def _amendextras(extra, old, wctx):
+ """Calculated extras for amended changeset.
+
+ This is a separate function so extensions can override it and filter out
+ (or add) certain entries.
+ """
+ # Copy to avoid mutating input
+ extra = extra.copy()
+ # Update extra dict from amended commit (e.g. to preserve graft
+ # source)
+ extra.update(old.extra())
+
+ # Also update it from the from the wctx
+ extra.update(wctx.extra())
+ return extra
+
def amend(ui, repo, old, extra, pats, opts):
# avoid cycle context -> subrepo -> cmdutil
from . import context
@@ -3137,14 +3153,7 @@
# base o - first parent of the changeset to amend
wctx = repo[None]
- # Copy to avoid mutating input
- extra = extra.copy()
- # Update extra dict from amended commit (e.g. to preserve graft
- # source)
- extra.update(old.extra())
-
- # Also update it from the from the wctx
- extra.update(wctx.extra())
+ extra = _amendextras(extra, old, wctx)
user = opts.get('user') or old.user()
date = opts.get('date') or old.date()
To: martinvonz, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list