Mercurial > hg
changeset 20773:efbf15979538
merge with stable
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Tue, 18 Mar 2014 14:25:28 -0500 |
parents | d9378bfa0af0 (current diff) 03774a2b6991 (diff) |
children | cdc3ac896997 |
files | hgext/histedit.py hgext/mq.py hgext/rebase.py mercurial/cmdutil.py mercurial/commands.py mercurial/localrepo.py tests/test-commit.t |
diffstat | 14 files changed, 309 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/histedit.py Sat Mar 15 15:44:51 2014 +0100 +++ b/hgext/histedit.py Tue Mar 18 14:25:28 2014 -0500 @@ -299,6 +299,7 @@ date=date, extra=extra) new._text = cmdutil.commitforceeditor(repo, new, []) + repo.savecommitmessage(new.description()) return repo.commitctx(new) def pick(ui, repo, ctx, ha, opts):
--- a/hgext/mq.py Sat Mar 15 15:44:51 2014 +0100 +++ b/hgext/mq.py Tue Mar 18 14:25:28 2014 -0500 @@ -1083,6 +1083,7 @@ p.write("# Date %s %s\n\n" % date) if util.safehasattr(msg, '__call__'): msg = msg() + repo.savecommitmessage(msg) commitmsg = msg and msg or ("[mq]: %s" % patchfn) n = newcommit(repo, None, commitmsg, user, date, match=match, force=True) @@ -2577,6 +2578,7 @@ if opts.get('edit'): message = ui.edit(message, user or ui.username()) + repo.savecommitmessage(message) diffopts = q.patchopts(q.diffopts(), *patches) wlock = repo.wlock()
--- a/hgext/rebase.py Sat Mar 15 15:44:51 2014 +0100 +++ b/hgext/rebase.py Tue Mar 18 14:25:28 2014 -0500 @@ -369,7 +369,7 @@ for rebased in state: if rebased not in skipped and state[rebased] > nullmerge: commitmsg += '\n* %s' % repo[rebased].description() - commitmsg = ui.edit(commitmsg, repo.ui.username()) + editor = cmdutil.commitforceeditor newrev = concludenode(repo, rev, p1, external, commitmsg=commitmsg, extrafn=extrafn, editor=editor) for oldrev in state.iterkeys():
--- a/mercurial/cmdutil.py Sat Mar 15 15:44:51 2014 +0100 +++ b/mercurial/cmdutil.py Tue Mar 18 14:25:28 2014 -0500 @@ -1962,6 +1962,7 @@ extra=extra) if editmsg: new._text = commitforceeditor(repo, new, []) + repo.savecommitmessage(new.description()) newdesc = changelog.stripdesc(new.description()) if ((not node)
--- a/mercurial/commands.py Sat Mar 15 15:44:51 2014 +0100 +++ b/mercurial/commands.py Tue Mar 18 14:25:28 2014 -0500 @@ -1437,11 +1437,14 @@ try: if opts.get('secret'): ui.setconfig('phases', 'new-commit', 'secret') + # Propagate to subrepos + repo.baseui.setconfig('phases', 'new-commit', 'secret') return repo.commit(message, opts.get('user'), opts.get('date'), match, editor=e, extra=extra) finally: ui.setconfig('phases', 'new-commit', oldcommitphase) + repo.baseui.setconfig('phases', 'new-commit', oldcommitphase) node = cmdutil.commit(ui, repo, commitfunc, pats, opts) @@ -5645,6 +5648,7 @@ if opts.get('edit'): message = ui.edit(message, ui.username()) + repo.savecommitmessage(message) # don't allow tagging the null rev if (not opts.get('remove') and
--- a/mercurial/localrepo.py Sat Mar 15 15:44:51 2014 +0100 +++ b/mercurial/localrepo.py Tue Mar 18 14:25:28 2014 -0500 @@ -1280,6 +1280,11 @@ cctx._text = editor(self, cctx, subs) edited = (text != cctx._text) + # Save commit message in case this transaction gets rolled back + # (e.g. by a pretxncommit hook). Leave the content alone on + # the assumption that the user will use the same editor again. + msgfn = self.savecommitmessage(cctx._text) + # commit subs and write new state if subs: for s in sorted(commitsubs): @@ -1290,11 +1295,6 @@ newstate[s] = (newstate[s][0], sr) subrepo.writestate(self, newstate) - # Save commit message in case this transaction gets rolled back - # (e.g. by a pretxncommit hook). Leave the content alone on - # the assumption that the user will use the same editor again. - msgfn = self.savecommitmessage(cctx._text) - p1, p2 = self.dirstate.parents() hookp1, hookp2 = hex(p1), (p2 != nullid and hex(p2) or '') try:
--- a/tests/test-commit-amend.t Sat Mar 15 15:44:51 2014 +0100 +++ b/tests/test-commit-amend.t Tue Mar 18 14:25:28 2014 -0500 @@ -165,6 +165,57 @@ > cat $1 > echo "another precious commit message" > "$1" > __EOF__ + +at first, test saving last-message.txt + + $ cat > .hg/hgrc << '__EOF__' + > [hooks] + > pretxncommit.test-saving-last-message = false + > __EOF__ + + $ rm -f .hg/last-message.txt + $ hg commit --amend -v -m "message given from command line" + amending changeset 5f357c7560ab + copying changeset 5f357c7560ab to ad120869acf0 + a + running hook pretxncommit.test-saving-last-message: false + transaction abort! + rollback completed + abort: pretxncommit.test-saving-last-message hook exited with status 1 + [255] + $ cat .hg/last-message.txt + message given from command line (no-eol) + + $ rm -f .hg/last-message.txt + $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit --amend -v + amending changeset 5f357c7560ab + copying changeset 5f357c7560ab to ad120869acf0 + no changes, new message + + + HG: Enter commit message. Lines beginning with 'HG:' are removed. + HG: Leave message empty to abort commit. + HG: -- + HG: user: foo + HG: branch 'default' + HG: changed a + a + running hook pretxncommit.test-saving-last-message: false + transaction abort! + rollback completed + abort: pretxncommit.test-saving-last-message hook exited with status 1 + [255] + + $ cat .hg/last-message.txt + another precious commit message + + $ cat > .hg/hgrc << '__EOF__' + > [hooks] + > pretxncommit.test-saving-last-message = + > __EOF__ + +then, test editing custom commit message + $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit --amend -v amending changeset 5f357c7560ab copying changeset 5f357c7560ab to ad120869acf0
--- a/tests/test-commit.t Sat Mar 15 15:44:51 2014 +0100 +++ b/tests/test-commit.t Tue Mar 18 14:25:28 2014 -0500 @@ -285,6 +285,52 @@ HG: removed removed abort: empty commit message [255] + +test saving last-message.txt + + $ hg init sub + $ echo a > sub/a + $ hg -R sub add sub/a + $ cat > sub/.hg/hgrc <<EOF + > [hooks] + > precommit.test-saving-last-message = false + > EOF + + $ echo 'sub = sub' > .hgsub + $ hg add .hgsub + + $ cat > $TESTDIR/editor.sh <<EOF + > echo "==== before editing:" + > cat \$1 + > echo "====" + > echo "test saving last-message.txt" >> \$1 + > EOF + + $ rm -f .hg/last-message.txt + $ HGEDITOR="sh $TESTDIR/editor.sh" hg commit -S -q + ==== before editing: + + + HG: Enter commit message. Lines beginning with 'HG:' are removed. + HG: Leave message empty to abort commit. + HG: -- + HG: user: test + HG: branch 'default' + HG: bookmark 'currentbookmark' + HG: subrepo sub + HG: added .hgsub + HG: added added + HG: changed .hgsubstate + HG: changed changed + HG: removed removed + ==== + abort: precommit.test-saving-last-message hook exited with status 1 (in subrepo sub) + [255] + $ cat .hg/last-message.txt + + + test saving last-message.txt + $ cd ..
--- a/tests/test-histedit-fold.t Sat Mar 15 15:44:51 2014 +0100 +++ b/tests/test-histedit-fold.t Tue Mar 18 14:25:28 2014 -0500 @@ -105,6 +105,69 @@ +check saving last-message.txt + + $ cat > $TESTDIR/abortfolding.py <<EOF + > from mercurial import util + > def abortfolding(ui, repo, hooktype, **kwargs): + > ctx = repo[kwargs.get('node')] + > if set(ctx.files()) == set(['c', 'd', 'f']): + > return True # abort folding commit only + > ui.warn('allow non-folding commit\\n') + > EOF + $ cat > .hg/hgrc <<EOF + > [hooks] + > pretxncommit.abortfolding = python:$TESTDIR/abortfolding.py:abortfolding + > EOF + + $ cat > $TESTDIR/editor.sh << EOF + > echo "==== before editing" + > cat \$1 + > echo "====" + > echo "check saving last-message.txt" >> \$1 + > EOF + + $ rm -f .hg/last-message.txt + $ HGEDITOR="sh $TESTDIR/editor.sh" hg histedit 6de59d13424a --commands - 2>&1 <<EOF | fixbundle + > pick 6de59d13424a f + > fold 9c277da72c9b d + > EOF + 0 files updated, 0 files merged, 1 files removed, 0 files unresolved + allow non-folding commit + 0 files updated, 0 files merged, 3 files removed, 0 files unresolved + ==== before editing + f + *** + c + *** + d + + + + HG: Enter commit message. Lines beginning with 'HG:' are removed. + HG: Leave message empty to abort commit. + HG: -- + HG: user: test + HG: branch 'default' + HG: changed c + HG: changed d + HG: changed f + ==== + transaction abort! + rollback completed + abort: pretxncommit.abortfolding hook failed + + $ cat .hg/last-message.txt + f + *** + c + *** + d + + + + check saving last-message.txt + $ cd .. folding and creating no new change doesn't break:
--- a/tests/test-mq-qfold.t Sat Mar 15 15:44:51 2014 +0100 +++ b/tests/test-mq-qfold.t Tue Mar 18 14:25:28 2014 -0500 @@ -140,5 +140,41 @@ b +b +Test saving last-message.txt: + + $ hg qrefresh -m "original message" + + $ cat > $TESTDIR/commitfailure.py <<EOF + > from mercurial import util + > def reposetup(ui, repo): + > class commitfailure(repo.__class__): + > def commit(self, *args, **kwargs): + > raise util.Abort('emulating unexpected abort') + > repo.__class__ = commitfailure + > EOF + + $ cat > .hg/hgrc <<EOF + > [extensions] + > commitfailure = $TESTDIR/commitfailure.py + > EOF + + $ cat > $TESTDIR/editor.sh << EOF + > echo "==== before editing" + > cat \$1 + > echo "====" + > (echo; echo "test saving last-message.txt") >> \$1 + > EOF + + $ rm -f .hg/last-message.txt + $ HGEDITOR="sh $TESTDIR/editor.sh" hg qfold -e p3 + ==== before editing + original message==== + refresh interrupted while patch was popped! (revert --all, qpush to recover) + abort: emulating unexpected abort + [255] + $ cat .hg/last-message.txt + original message + test saving last-message.txt + $ cd ..
--- a/tests/test-mq-qnew.t Sat Mar 15 15:44:51 2014 +0100 +++ b/tests/test-mq-qnew.t Tue Mar 18 14:25:28 2014 -0500 @@ -233,3 +233,39 @@ use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon abort: cannot manage merge changesets $ rm -r sandbox + +Test saving last-message.txt + + $ hg init repo + $ cd repo + + $ cat > $TESTDIR/commitfailure.py <<EOF + > from mercurial import util + > def reposetup(ui, repo): + > class commitfailure(repo.__class__): + > def commit(self, *args, **kwargs): + > raise util.Abort('emulating unexpected abort') + > repo.__class__ = commitfailure + > EOF + $ cat > .hg/hgrc <<EOF + > [extensions] + > commitfailure = $TESTDIR/commitfailure.py + > EOF + + $ cat > $TESTDIR/editor.sh << EOF + > echo "==== before editing" + > cat \$1 + > echo "====" + > echo "test saving last-message.txt" >> \$1 + > EOF + + $ rm -f .hg/last-message.txt + $ HGEDITOR="sh $TESTDIR/editor.sh" hg qnew -e patch + ==== before editing + ==== + abort: emulating unexpected abort + [255] + $ cat .hg/last-message.txt + test saving last-message.txt + + $ cd ..
--- a/tests/test-rebase-collapse.t Sat Mar 15 15:44:51 2014 +0100 +++ b/tests/test-rebase-collapse.t Tue Mar 18 14:25:28 2014 -0500 @@ -52,14 +52,39 @@ $ hg phase --force --secret 3 - $ hg rebase --collapse --keepbranches + $ cat > $TESTTMP/editor.sh <<EOF + > echo "==== before editing" + > cat \$1 + > echo "====" + > echo "edited manually" >> \$1 + > EOF + $ HGEDITOR="sh $TESTTMP/editor.sh" hg rebase --collapse --keepbranches -e + ==== before editing + Collapsed revision + * B + * C + * D + + + HG: Enter commit message. Lines beginning with 'HG:' are removed. + HG: Leave message empty to abort commit. + HG: -- + HG: user: Nicolas Dumazet <nicdumz.commits@gmail.com> + HG: branch 'default' + HG: changed B + HG: changed C + HG: changed D + ==== saved backup bundle to $TESTTMP/a1/.hg/strip-backup/*-backup.hg (glob) $ hg tglogp @ 5:secret 'Collapsed revision | * B | * C - | * D' + | * D + | + | + | edited manually' o 4:draft 'H' | | o 3:draft 'G'
--- a/tests/test-subrepo.t Sat Mar 15 15:44:51 2014 +0100 +++ b/tests/test-subrepo.t Tue Mar 18 14:25:28 2014 -0500 @@ -1294,3 +1294,18 @@ 15: secret $ cd .. + + +Test that comit --secret works on both repo and subrepo (issue4182) + + $ cd main + $ echo secret >> b + $ echo secret >> s/b + $ hg commit --secret --subrepo -m "secret" + committing subrepository s + $ hg phase -r . + 6: secret + $ cd s + $ hg phase -r . + 6: secret + $ cd ../../
--- a/tests/test-tag.t Sat Mar 15 15:44:51 2014 +0100 +++ b/tests/test-tag.t Tue Mar 18 14:25:28 2014 -0500 @@ -222,6 +222,27 @@ > echo "custom tag message" > "$1" > echo "second line" >> "$1" > __EOF__ + +at first, test saving last-message.txt + + $ cat > .hg/hgrc << '__EOF__' + > [hooks] + > pretag.test-saving-lastmessage = false + > __EOF__ + $ rm -f .hg/last-message.txt + $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg tag custom-tag -e + abort: pretag.test-saving-lastmessage hook exited with status 1 + [255] + $ cat .hg/last-message.txt + custom tag message + second line + $ cat > .hg/hgrc << '__EOF__' + > [hooks] + > pretag.test-saving-lastmessage = + > __EOF__ + +then, test custom commit message itself + $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg tag custom-tag -e $ hg log -l1 --template "{desc}\n" custom tag message