D1575: amend: make a copy of "extra" to avoid mutating an input

martinvonz (Martin von Zweigbergk) phabricator at mercurial-scm.org
Fri Dec 1 22:43:56 UTC 2017


martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  I don't know of any problems this has caused, it just seems less
  surprising.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D1575

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
@@ -3137,6 +3137,8 @@
         # 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())



To: martinvonz, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list