diff mercurial/commands.py @ 20700:b0153cb8b64e stable

commit: create new amend changeset as secret correctly for "--secret" option Before this patch, "hg commit --amend --secret" doesn't create new amend changeset as secret, even though the internal function "commitfunc()" passed to "cmdutil.amend()" make "phases.new-commit" configuration as "secret" temporarily. "cmdutil.amend()" uses specified "commitfunc" only for temporary amend commit, and creates the final amend commit changeset by "localrepository.commitctx()" directly with memctx. This patch creates new amend changeset as secret correctly for "--secret" option, by changing "phases.new-commit" configuration temporarily before "localrepository.commitctx()".
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Thu, 13 Mar 2014 19:48:41 +0900
parents 2d183dd54384
children 2764148aa088 bcfc4f625e57
line wrap: on
line diff
--- a/mercurial/commands.py	Wed Mar 12 10:26:48 2014 +0200
+++ b/mercurial/commands.py	Thu Mar 13 19:48:41 2014 +0900
@@ -1397,6 +1397,7 @@
         if opts.get('force_editor'):
             e = cmdutil.commitforceeditor
 
+        # commitfunc is used only for temporary amend commit by cmdutil.amend
         def commitfunc(ui, repo, message, match, opts):
             editor = e
             # message contains text from -m or -l, if it's empty,
@@ -1404,18 +1405,12 @@
             if not message:
                 message = old.description()
                 editor = cmdutil.commitforceeditor
-            try:
-                if opts.get('secret'):
-                    ui.setconfig('phases', 'new-commit', 'secret')
-
-                return repo.commit(message,
-                                   opts.get('user') or old.user(),
-                                   opts.get('date') or old.date(),
-                                   match,
-                                   editor=editor,
-                                   extra=extra)
-            finally:
-                ui.setconfig('phases', 'new-commit', oldcommitphase)
+            return repo.commit(message,
+                               opts.get('user') or old.user(),
+                               opts.get('date') or old.date(),
+                               match,
+                               editor=editor,
+                               extra=extra)
 
         current = repo._bookmarkcurrent
         marks = old.bookmarks()