changeset 20702:2764148aa088

merge with stable
author Matt Mackall <mpm@selenic.com>
date Thu, 13 Mar 2014 12:05:08 -0500
parents d20817ac628a (current diff) b0153cb8b64e (diff)
children 9c1665f36588
files mercurial/cmdutil.py mercurial/commands.py mercurial/scmutil.py
diffstat 6 files changed, 35 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/cmdutil.py	Tue Feb 04 18:33:25 2014 -0500
+++ b/mercurial/cmdutil.py	Thu Mar 13 12:05:08 2014 -0500
@@ -1969,7 +1969,11 @@
 
             ph = repo.ui.config('phases', 'new-commit', phases.draft)
             try:
-                repo.ui.setconfig('phases', 'new-commit', old.phase())
+                if opts.get('secret'):
+                    commitphase = 'secret'
+                else:
+                    commitphase = old.phase()
+                repo.ui.setconfig('phases', 'new-commit', commitphase)
                 newid = repo.commitctx(new)
             finally:
                 repo.ui.setconfig('phases', 'new-commit', ph)
--- a/mercurial/commands.py	Tue Feb 04 18:33:25 2014 -0500
+++ b/mercurial/commands.py	Thu Mar 13 12:05:08 2014 -0500
@@ -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()
--- a/mercurial/scmutil.py	Tue Feb 04 18:33:25 2014 -0500
+++ b/mercurial/scmutil.py	Thu Mar 13 12:05:08 2014 -0500
@@ -506,7 +506,7 @@
                 start, end = spec.split(_revrangesep, 1)
                 start = revfix(repo, start, 0)
                 end = revfix(repo, end, len(repo) - 1)
-                if end == nullrev and start <= 0:
+                if end == nullrev and start < 0:
                     start = nullrev
                 rangeiter = repo.changelog.revs(start, end)
                 if not seen and not l:
--- a/tests/test-commit-amend.t	Tue Feb 04 18:33:25 2014 -0500
+++ b/tests/test-commit-amend.t	Thu Mar 13 12:05:08 2014 -0500
@@ -765,3 +765,14 @@
   $ hg ci --close-branch -m'open and close'
   abort: can only close branch heads
   [255]
+
+Test that amend with --secret creates new secret changeset forcibly
+---------------------------------------------------------------------
+
+  $ hg phase '.^::.'
+  35: draft
+  36: draft
+  $ hg commit --amend --secret -m 'amend as secret' -q
+  $ hg phase '.^::.'
+  35: draft
+  38: secret
--- a/tests/test-glog.t	Tue Feb 04 18:33:25 2014 -0500
+++ b/tests/test-glog.t	Thu Mar 13 12:05:08 2014 -0500
@@ -2111,6 +2111,11 @@
 issue3772
 
   $ hg log -G -r :null
+  o  changeset:   0:f8035bb17114
+  |  user:        test
+  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  summary:     add a
+  |
   o  changeset:   -1:000000000000
      user:
      date:        Thu Jan 01 00:00:00 1970 +0000
--- a/tests/test-log.t	Tue Feb 04 18:33:25 2014 -0500
+++ b/tests/test-log.t	Thu Mar 13 12:05:08 2014 -0500
@@ -1356,6 +1356,12 @@
 issue3772: hg log -r :null showing revision 0 as well
 
   $ hg log -r :null
+  changeset:   0:65624cd9070a
+  tag:         tip
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     a bunch of weird directories
+  
   changeset:   -1:000000000000
   user:        
   date:        Thu Jan 01 00:00:00 1970 +0000