Show More
@@ -299,6 +299,7 b' def collapse(repo, first, last, commitop' | |||
|
299 | 299 | date=date, |
|
300 | 300 | extra=extra) |
|
301 | 301 | new._text = cmdutil.commitforceeditor(repo, new, []) |
|
302 | repo.savecommitmessage(new.description()) | |
|
302 | 303 | return repo.commitctx(new) |
|
303 | 304 | |
|
304 | 305 | def pick(ui, repo, ctx, ha, opts): |
@@ -1083,6 +1083,7 b' class queue(object):' | |||
|
1083 | 1083 | p.write("# Date %s %s\n\n" % date) |
|
1084 | 1084 | if util.safehasattr(msg, '__call__'): |
|
1085 | 1085 | msg = msg() |
|
1086 | repo.savecommitmessage(msg) | |
|
1086 | 1087 | commitmsg = msg and msg or ("[mq]: %s" % patchfn) |
|
1087 | 1088 | n = newcommit(repo, None, commitmsg, user, date, match=match, |
|
1088 | 1089 | force=True) |
@@ -2577,6 +2578,7 b' def fold(ui, repo, *files, **opts):' | |||
|
2577 | 2578 | |
|
2578 | 2579 | if opts.get('edit'): |
|
2579 | 2580 | message = ui.edit(message, user or ui.username()) |
|
2581 | repo.savecommitmessage(message) | |
|
2580 | 2582 | |
|
2581 | 2583 | diffopts = q.patchopts(q.diffopts(), *patches) |
|
2582 | 2584 | wlock = repo.wlock() |
@@ -369,7 +369,7 b' def rebase(ui, repo, **opts):' | |||
|
369 | 369 | for rebased in state: |
|
370 | 370 | if rebased not in skipped and state[rebased] > nullmerge: |
|
371 | 371 | commitmsg += '\n* %s' % repo[rebased].description() |
|
372 | commitmsg = ui.edit(commitmsg, repo.ui.username()) | |
|
372 | editor = cmdutil.commitforceeditor | |
|
373 | 373 | newrev = concludenode(repo, rev, p1, external, commitmsg=commitmsg, |
|
374 | 374 | extrafn=extrafn, editor=editor) |
|
375 | 375 | for oldrev in state.iterkeys(): |
@@ -1962,6 +1962,7 b' def amend(ui, repo, commitfunc, old, ext' | |||
|
1962 | 1962 | extra=extra) |
|
1963 | 1963 | if editmsg: |
|
1964 | 1964 | new._text = commitforceeditor(repo, new, []) |
|
1965 | repo.savecommitmessage(new.description()) | |
|
1965 | 1966 | |
|
1966 | 1967 | newdesc = changelog.stripdesc(new.description()) |
|
1967 | 1968 | if ((not node) |
@@ -1437,11 +1437,14 b' def commit(ui, repo, *pats, **opts):' | |||
|
1437 | 1437 | try: |
|
1438 | 1438 | if opts.get('secret'): |
|
1439 | 1439 | ui.setconfig('phases', 'new-commit', 'secret') |
|
1440 | # Propagate to subrepos | |
|
1441 | repo.baseui.setconfig('phases', 'new-commit', 'secret') | |
|
1440 | 1442 | |
|
1441 | 1443 | return repo.commit(message, opts.get('user'), opts.get('date'), |
|
1442 | 1444 | match, editor=e, extra=extra) |
|
1443 | 1445 | finally: |
|
1444 | 1446 | ui.setconfig('phases', 'new-commit', oldcommitphase) |
|
1447 | repo.baseui.setconfig('phases', 'new-commit', oldcommitphase) | |
|
1445 | 1448 | |
|
1446 | 1449 | |
|
1447 | 1450 | node = cmdutil.commit(ui, repo, commitfunc, pats, opts) |
@@ -5645,6 +5648,7 b' def tag(ui, repo, name1, *names, **opts)' | |||
|
5645 | 5648 | |
|
5646 | 5649 | if opts.get('edit'): |
|
5647 | 5650 | message = ui.edit(message, ui.username()) |
|
5651 | repo.savecommitmessage(message) | |
|
5648 | 5652 | |
|
5649 | 5653 | # don't allow tagging the null rev |
|
5650 | 5654 | if (not opts.get('remove') and |
@@ -1280,6 +1280,11 b' class localrepository(object):' | |||
|
1280 | 1280 | cctx._text = editor(self, cctx, subs) |
|
1281 | 1281 | edited = (text != cctx._text) |
|
1282 | 1282 | |
|
1283 | # Save commit message in case this transaction gets rolled back | |
|
1284 | # (e.g. by a pretxncommit hook). Leave the content alone on | |
|
1285 | # the assumption that the user will use the same editor again. | |
|
1286 | msgfn = self.savecommitmessage(cctx._text) | |
|
1287 | ||
|
1283 | 1288 | # commit subs and write new state |
|
1284 | 1289 | if subs: |
|
1285 | 1290 | for s in sorted(commitsubs): |
@@ -1290,11 +1295,6 b' class localrepository(object):' | |||
|
1290 | 1295 | newstate[s] = (newstate[s][0], sr) |
|
1291 | 1296 | subrepo.writestate(self, newstate) |
|
1292 | 1297 | |
|
1293 | # Save commit message in case this transaction gets rolled back | |
|
1294 | # (e.g. by a pretxncommit hook). Leave the content alone on | |
|
1295 | # the assumption that the user will use the same editor again. | |
|
1296 | msgfn = self.savecommitmessage(cctx._text) | |
|
1297 | ||
|
1298 | 1298 | p1, p2 = self.dirstate.parents() |
|
1299 | 1299 | hookp1, hookp2 = hex(p1), (p2 != nullid and hex(p2) or '') |
|
1300 | 1300 | try: |
@@ -165,6 +165,57 b' Open editor with old commit message if a' | |||
|
165 | 165 | > cat $1 |
|
166 | 166 | > echo "another precious commit message" > "$1" |
|
167 | 167 | > __EOF__ |
|
168 | ||
|
169 | at first, test saving last-message.txt | |
|
170 | ||
|
171 | $ cat > .hg/hgrc << '__EOF__' | |
|
172 | > [hooks] | |
|
173 | > pretxncommit.test-saving-last-message = false | |
|
174 | > __EOF__ | |
|
175 | ||
|
176 | $ rm -f .hg/last-message.txt | |
|
177 | $ hg commit --amend -v -m "message given from command line" | |
|
178 | amending changeset 5f357c7560ab | |
|
179 | copying changeset 5f357c7560ab to ad120869acf0 | |
|
180 | a | |
|
181 | running hook pretxncommit.test-saving-last-message: false | |
|
182 | transaction abort! | |
|
183 | rollback completed | |
|
184 | abort: pretxncommit.test-saving-last-message hook exited with status 1 | |
|
185 | [255] | |
|
186 | $ cat .hg/last-message.txt | |
|
187 | message given from command line (no-eol) | |
|
188 | ||
|
189 | $ rm -f .hg/last-message.txt | |
|
190 | $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit --amend -v | |
|
191 | amending changeset 5f357c7560ab | |
|
192 | copying changeset 5f357c7560ab to ad120869acf0 | |
|
193 | no changes, new message | |
|
194 | ||
|
195 | ||
|
196 | HG: Enter commit message. Lines beginning with 'HG:' are removed. | |
|
197 | HG: Leave message empty to abort commit. | |
|
198 | HG: -- | |
|
199 | HG: user: foo | |
|
200 | HG: branch 'default' | |
|
201 | HG: changed a | |
|
202 | a | |
|
203 | running hook pretxncommit.test-saving-last-message: false | |
|
204 | transaction abort! | |
|
205 | rollback completed | |
|
206 | abort: pretxncommit.test-saving-last-message hook exited with status 1 | |
|
207 | [255] | |
|
208 | ||
|
209 | $ cat .hg/last-message.txt | |
|
210 | another precious commit message | |
|
211 | ||
|
212 | $ cat > .hg/hgrc << '__EOF__' | |
|
213 | > [hooks] | |
|
214 | > pretxncommit.test-saving-last-message = | |
|
215 | > __EOF__ | |
|
216 | ||
|
217 | then, test editing custom commit message | |
|
218 | ||
|
168 | 219 |
$ |
|
169 | 220 | amending changeset 5f357c7560ab |
|
170 | 221 | copying changeset 5f357c7560ab to ad120869acf0 |
@@ -285,6 +285,52 b' test commit message content' | |||
|
285 | 285 | HG: removed removed |
|
286 | 286 | abort: empty commit message |
|
287 | 287 | [255] |
|
288 | ||
|
289 | test saving last-message.txt | |
|
290 | ||
|
291 | $ hg init sub | |
|
292 | $ echo a > sub/a | |
|
293 | $ hg -R sub add sub/a | |
|
294 | $ cat > sub/.hg/hgrc <<EOF | |
|
295 | > [hooks] | |
|
296 | > precommit.test-saving-last-message = false | |
|
297 | > EOF | |
|
298 | ||
|
299 | $ echo 'sub = sub' > .hgsub | |
|
300 | $ hg add .hgsub | |
|
301 | ||
|
302 | $ cat > $TESTDIR/editor.sh <<EOF | |
|
303 | > echo "==== before editing:" | |
|
304 | > cat \$1 | |
|
305 | > echo "====" | |
|
306 | > echo "test saving last-message.txt" >> \$1 | |
|
307 | > EOF | |
|
308 | ||
|
309 | $ rm -f .hg/last-message.txt | |
|
310 | $ HGEDITOR="sh $TESTDIR/editor.sh" hg commit -S -q | |
|
311 | ==== before editing: | |
|
312 | ||
|
313 | ||
|
314 | HG: Enter commit message. Lines beginning with 'HG:' are removed. | |
|
315 | HG: Leave message empty to abort commit. | |
|
316 | HG: -- | |
|
317 | HG: user: test | |
|
318 | HG: branch 'default' | |
|
319 | HG: bookmark 'currentbookmark' | |
|
320 | HG: subrepo sub | |
|
321 | HG: added .hgsub | |
|
322 | HG: added added | |
|
323 | HG: changed .hgsubstate | |
|
324 | HG: changed changed | |
|
325 | HG: removed removed | |
|
326 | ==== | |
|
327 | abort: precommit.test-saving-last-message hook exited with status 1 (in subrepo sub) | |
|
328 | [255] | |
|
329 | $ cat .hg/last-message.txt | |
|
330 | ||
|
331 | ||
|
332 | test saving last-message.txt | |
|
333 | ||
|
288 | 334 | $ cd .. |
|
289 | 335 | |
|
290 | 336 |
@@ -105,6 +105,69 b' check histedit_source' | |||
|
105 | 105 | |
|
106 | 106 | |
|
107 | 107 | |
|
108 | check saving last-message.txt | |
|
109 | ||
|
110 | $ cat > $TESTDIR/abortfolding.py <<EOF | |
|
111 | > from mercurial import util | |
|
112 | > def abortfolding(ui, repo, hooktype, **kwargs): | |
|
113 | > ctx = repo[kwargs.get('node')] | |
|
114 | > if set(ctx.files()) == set(['c', 'd', 'f']): | |
|
115 | > return True # abort folding commit only | |
|
116 | > ui.warn('allow non-folding commit\\n') | |
|
117 | > EOF | |
|
118 | $ cat > .hg/hgrc <<EOF | |
|
119 | > [hooks] | |
|
120 | > pretxncommit.abortfolding = python:$TESTDIR/abortfolding.py:abortfolding | |
|
121 | > EOF | |
|
122 | ||
|
123 | $ cat > $TESTDIR/editor.sh << EOF | |
|
124 | > echo "==== before editing" | |
|
125 | > cat \$1 | |
|
126 | > echo "====" | |
|
127 | > echo "check saving last-message.txt" >> \$1 | |
|
128 | > EOF | |
|
129 | ||
|
130 | $ rm -f .hg/last-message.txt | |
|
131 | $ HGEDITOR="sh $TESTDIR/editor.sh" hg histedit 6de59d13424a --commands - 2>&1 <<EOF | fixbundle | |
|
132 | > pick 6de59d13424a f | |
|
133 | > fold 9c277da72c9b d | |
|
134 | > EOF | |
|
135 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved | |
|
136 | allow non-folding commit | |
|
137 | 0 files updated, 0 files merged, 3 files removed, 0 files unresolved | |
|
138 | ==== before editing | |
|
139 | f | |
|
140 | *** | |
|
141 | c | |
|
142 | *** | |
|
143 | d | |
|
144 | ||
|
145 | ||
|
146 | ||
|
147 | HG: Enter commit message. Lines beginning with 'HG:' are removed. | |
|
148 | HG: Leave message empty to abort commit. | |
|
149 | HG: -- | |
|
150 | HG: user: test | |
|
151 | HG: branch 'default' | |
|
152 | HG: changed c | |
|
153 | HG: changed d | |
|
154 | HG: changed f | |
|
155 | ==== | |
|
156 | transaction abort! | |
|
157 | rollback completed | |
|
158 | abort: pretxncommit.abortfolding hook failed | |
|
159 | ||
|
160 | $ cat .hg/last-message.txt | |
|
161 | f | |
|
162 | *** | |
|
163 | c | |
|
164 | *** | |
|
165 | d | |
|
166 | ||
|
167 | ||
|
168 | ||
|
169 | check saving last-message.txt | |
|
170 | ||
|
108 | 171 | $ cd .. |
|
109 | 172 | |
|
110 | 173 | folding and creating no new change doesn't break: |
@@ -140,5 +140,41 b' Fold regular patch into a git patch, exp' | |||
|
140 | 140 | b |
|
141 | 141 | +b |
|
142 | 142 | |
|
143 | Test saving last-message.txt: | |
|
144 | ||
|
145 | $ hg qrefresh -m "original message" | |
|
146 | ||
|
147 | $ cat > $TESTDIR/commitfailure.py <<EOF | |
|
148 | > from mercurial import util | |
|
149 | > def reposetup(ui, repo): | |
|
150 | > class commitfailure(repo.__class__): | |
|
151 | > def commit(self, *args, **kwargs): | |
|
152 | > raise util.Abort('emulating unexpected abort') | |
|
153 | > repo.__class__ = commitfailure | |
|
154 | > EOF | |
|
155 | ||
|
156 | $ cat > .hg/hgrc <<EOF | |
|
157 | > [extensions] | |
|
158 | > commitfailure = $TESTDIR/commitfailure.py | |
|
159 | > EOF | |
|
160 | ||
|
161 | $ cat > $TESTDIR/editor.sh << EOF | |
|
162 | > echo "==== before editing" | |
|
163 | > cat \$1 | |
|
164 | > echo "====" | |
|
165 | > (echo; echo "test saving last-message.txt") >> \$1 | |
|
166 | > EOF | |
|
167 | ||
|
168 | $ rm -f .hg/last-message.txt | |
|
169 | $ HGEDITOR="sh $TESTDIR/editor.sh" hg qfold -e p3 | |
|
170 | ==== before editing | |
|
171 | original message==== | |
|
172 | refresh interrupted while patch was popped! (revert --all, qpush to recover) | |
|
173 | abort: emulating unexpected abort | |
|
174 | [255] | |
|
175 | $ cat .hg/last-message.txt | |
|
176 | original message | |
|
177 | test saving last-message.txt | |
|
178 | ||
|
143 | 179 | $ cd .. |
|
144 | 180 |
@@ -233,3 +233,39 b' hg headers' | |||
|
233 | 233 | use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon |
|
234 | 234 | abort: cannot manage merge changesets |
|
235 | 235 | $ rm -r sandbox |
|
236 | ||
|
237 | Test saving last-message.txt | |
|
238 | ||
|
239 | $ hg init repo | |
|
240 | $ cd repo | |
|
241 | ||
|
242 | $ cat > $TESTDIR/commitfailure.py <<EOF | |
|
243 | > from mercurial import util | |
|
244 | > def reposetup(ui, repo): | |
|
245 | > class commitfailure(repo.__class__): | |
|
246 | > def commit(self, *args, **kwargs): | |
|
247 | > raise util.Abort('emulating unexpected abort') | |
|
248 | > repo.__class__ = commitfailure | |
|
249 | > EOF | |
|
250 | $ cat > .hg/hgrc <<EOF | |
|
251 | > [extensions] | |
|
252 | > commitfailure = $TESTDIR/commitfailure.py | |
|
253 | > EOF | |
|
254 | ||
|
255 | $ cat > $TESTDIR/editor.sh << EOF | |
|
256 | > echo "==== before editing" | |
|
257 | > cat \$1 | |
|
258 | > echo "====" | |
|
259 | > echo "test saving last-message.txt" >> \$1 | |
|
260 | > EOF | |
|
261 | ||
|
262 | $ rm -f .hg/last-message.txt | |
|
263 | $ HGEDITOR="sh $TESTDIR/editor.sh" hg qnew -e patch | |
|
264 | ==== before editing | |
|
265 | ==== | |
|
266 | abort: emulating unexpected abort | |
|
267 | [255] | |
|
268 | $ cat .hg/last-message.txt | |
|
269 | test saving last-message.txt | |
|
270 | ||
|
271 | $ cd .. |
@@ -52,14 +52,39 b' Rebasing B onto H and collapsing changes' | |||
|
52 | 52 | |
|
53 | 53 | $ hg phase --force --secret 3 |
|
54 | 54 | |
|
55 | $ hg rebase --collapse --keepbranches | |
|
55 | $ cat > $TESTTMP/editor.sh <<EOF | |
|
56 | > echo "==== before editing" | |
|
57 | > cat \$1 | |
|
58 | > echo "====" | |
|
59 | > echo "edited manually" >> \$1 | |
|
60 | > EOF | |
|
61 | $ HGEDITOR="sh $TESTTMP/editor.sh" hg rebase --collapse --keepbranches -e | |
|
62 | ==== before editing | |
|
63 | Collapsed revision | |
|
64 | * B | |
|
65 | * C | |
|
66 | * D | |
|
67 | ||
|
68 | ||
|
69 | HG: Enter commit message. Lines beginning with 'HG:' are removed. | |
|
70 | HG: Leave message empty to abort commit. | |
|
71 | HG: -- | |
|
72 | HG: user: Nicolas Dumazet <nicdumz.commits@gmail.com> | |
|
73 | HG: branch 'default' | |
|
74 | HG: changed B | |
|
75 | HG: changed C | |
|
76 | HG: changed D | |
|
77 | ==== | |
|
56 | 78 | saved backup bundle to $TESTTMP/a1/.hg/strip-backup/*-backup.hg (glob) |
|
57 | 79 | |
|
58 | 80 | $ hg tglogp |
|
59 | 81 | @ 5:secret 'Collapsed revision |
|
60 | 82 | | * B |
|
61 | 83 | | * C |
|
62 |
| * D |
|
|
84 | | * D | |
|
85 | | | |
|
86 | | | |
|
87 | | edited manually' | |
|
63 | 88 | o 4:draft 'H' |
|
64 | 89 | | |
|
65 | 90 | | o 3:draft 'G' |
@@ -1294,3 +1294,18 b' configuration' | |||
|
1294 | 1294 | 15: secret |
|
1295 | 1295 | |
|
1296 | 1296 | $ cd .. |
|
1297 | ||
|
1298 | ||
|
1299 | Test that comit --secret works on both repo and subrepo (issue4182) | |
|
1300 | ||
|
1301 | $ cd main | |
|
1302 | $ echo secret >> b | |
|
1303 | $ echo secret >> s/b | |
|
1304 | $ hg commit --secret --subrepo -m "secret" | |
|
1305 | committing subrepository s | |
|
1306 | $ hg phase -r . | |
|
1307 | 6: secret | |
|
1308 | $ cd s | |
|
1309 | $ hg phase -r . | |
|
1310 | 6: secret | |
|
1311 | $ cd ../../ |
@@ -222,6 +222,27 b' test custom commit messages' | |||
|
222 | 222 | > echo "custom tag message" > "$1" |
|
223 | 223 | > echo "second line" >> "$1" |
|
224 | 224 | > __EOF__ |
|
225 | ||
|
226 | at first, test saving last-message.txt | |
|
227 | ||
|
228 | $ cat > .hg/hgrc << '__EOF__' | |
|
229 | > [hooks] | |
|
230 | > pretag.test-saving-lastmessage = false | |
|
231 | > __EOF__ | |
|
232 | $ rm -f .hg/last-message.txt | |
|
233 | $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg tag custom-tag -e | |
|
234 | abort: pretag.test-saving-lastmessage hook exited with status 1 | |
|
235 | [255] | |
|
236 | $ cat .hg/last-message.txt | |
|
237 | custom tag message | |
|
238 | second line | |
|
239 | $ cat > .hg/hgrc << '__EOF__' | |
|
240 | > [hooks] | |
|
241 | > pretag.test-saving-lastmessage = | |
|
242 | > __EOF__ | |
|
243 | ||
|
244 | then, test custom commit message itself | |
|
245 | ||
|
225 | 246 |
$ |
|
226 | 247 | $ hg log -l1 --template "{desc}\n" |
|
227 | 248 | custom tag message |
General Comments 0
You need to be logged in to leave comments.
Login now