# HG changeset patch # User Matt Mackall # Date 2014-03-13 17:05:08 # Node ID 2764148aa088da248f74d1bf92e5d504f7f4db9a # Parent d20817ac628a22ff5f3adf2551c33203a9b01eb7 # Parent b0153cb8b64efb546cbf3bd6bba5a6770ab2563f merge with stable diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -1969,7 +1969,11 @@ def amend(ui, repo, commitfunc, old, ext 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) diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -1397,6 +1397,7 @@ def commit(ui, repo, *pats, **opts): 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 @@ def commit(ui, repo, *pats, **opts): 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() diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py --- a/mercurial/scmutil.py +++ b/mercurial/scmutil.py @@ -506,7 +506,7 @@ def revrange(repo, revs): 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: diff --git a/tests/test-commit-amend.t b/tests/test-commit-amend.t --- a/tests/test-commit-amend.t +++ b/tests/test-commit-amend.t @@ -765,3 +765,14 @@ This silliness fails: $ 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 diff --git a/tests/test-glog.t b/tests/test-glog.t --- a/tests/test-glog.t +++ b/tests/test-glog.t @@ -2111,6 +2111,11 @@ The almost-empty template should do some 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 diff --git a/tests/test-log.t b/tests/test-log.t --- a/tests/test-log.t +++ b/tests/test-log.t @@ -1356,6 +1356,12 @@ test hg log on non-existent files and on 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