Show More
@@ -5684,15 +5684,18 b' def tag(ui, repo, name1, *names, **opts)' | |||
|
5684 | 5684 | date = util.parsedate(date) |
|
5685 | 5685 | |
|
5686 | 5686 | if opts.get('edit'): |
|
5687 | message = ui.edit(message, ui.username()) | |
|
5688 | repo.savecommitmessage(message) | |
|
5687 | def editor(repo, ctx, subs): | |
|
5688 | return ui.edit(ctx.description() + "\n", ctx.user()) | |
|
5689 | else: | |
|
5690 | editor = False | |
|
5689 | 5691 | |
|
5690 | 5692 | # don't allow tagging the null rev |
|
5691 | 5693 | if (not opts.get('remove') and |
|
5692 | 5694 | scmutil.revsingle(repo, rev_).rev() == nullrev): |
|
5693 | 5695 | raise util.Abort(_("cannot tag null revision")) |
|
5694 | 5696 | |
|
5695 |
repo.tag(names, r, message, opts.get('local'), opts.get('user'), date |
|
|
5697 | repo.tag(names, r, message, opts.get('local'), opts.get('user'), date, | |
|
5698 | editor=editor) | |
|
5696 | 5699 | finally: |
|
5697 | 5700 | release(lock, wlock) |
|
5698 | 5701 |
@@ -479,7 +479,8 b' class localrepository(object):' | |||
|
479 | 479 | return hook.hook(self.ui, self, name, throw, **args) |
|
480 | 480 | |
|
481 | 481 | @unfilteredmethod |
|
482 |
def _tag(self, names, node, message, local, user, date, extra={} |
|
|
482 | def _tag(self, names, node, message, local, user, date, extra={}, | |
|
483 | editor=False): | |
|
483 | 484 | if isinstance(names, str): |
|
484 | 485 | names = (names,) |
|
485 | 486 | |
@@ -539,14 +540,15 b' class localrepository(object):' | |||
|
539 | 540 | self[None].add(['.hgtags']) |
|
540 | 541 | |
|
541 | 542 | m = matchmod.exact(self.root, '', ['.hgtags']) |
|
542 |
tagnode = self.commit(message, user, date, extra=extra, match=m |
|
|
543 | tagnode = self.commit(message, user, date, extra=extra, match=m, | |
|
544 | editor=editor) | |
|
543 | 545 | |
|
544 | 546 | for name in names: |
|
545 | 547 | self.hook('tag', node=hex(node), tag=name, local=local) |
|
546 | 548 | |
|
547 | 549 | return tagnode |
|
548 | 550 | |
|
549 | def tag(self, names, node, message, local, user, date): | |
|
551 | def tag(self, names, node, message, local, user, date, editor=False): | |
|
550 | 552 | '''tag a revision with one or more symbolic names. |
|
551 | 553 | |
|
552 | 554 | names is a list of strings or, when adding a single tag, names may be a |
@@ -574,7 +576,7 b' class localrepository(object):' | |||
|
574 | 576 | '(please commit .hgtags manually)')) |
|
575 | 577 | |
|
576 | 578 | self.tags() # instantiate the cache |
|
577 | self._tag(names, node, message, local, user, date) | |
|
579 | self._tag(names, node, message, local, user, date, editor=editor) | |
|
578 | 580 | |
|
579 | 581 | @filteredpropertycache |
|
580 | 582 | def _tagscache(self): |
@@ -225,8 +225,11 b' test custom commit messages' | |||
|
225 | 225 | |
|
226 | 226 | at first, test saving last-message.txt |
|
227 | 227 | |
|
228 | (test that editor is not invoked before transaction starting) | |
|
229 | ||
|
228 | 230 | $ cat > .hg/hgrc << '__EOF__' |
|
229 | 231 | > [hooks] |
|
232 | > # this failure occurs before editor invocation | |
|
230 | 233 | > pretag.test-saving-lastmessage = false |
|
231 | 234 | > __EOF__ |
|
232 | 235 | $ rm -f .hg/last-message.txt |
@@ -234,12 +237,37 b' at first, test saving last-message.txt' | |||
|
234 | 237 | abort: pretag.test-saving-lastmessage hook exited with status 1 |
|
235 | 238 | [255] |
|
236 | 239 | $ cat .hg/last-message.txt |
|
240 | cat: .hg/last-message.txt: No such file or directory | |
|
241 | [1] | |
|
242 | ||
|
243 | (test that editor is invoked and commit message is saved into | |
|
244 | "last-message.txt") | |
|
245 | ||
|
246 | $ cat >> .hg/hgrc << '__EOF__' | |
|
247 | > [hooks] | |
|
248 | > pretag.test-saving-lastmessage = | |
|
249 | > # this failure occurs after editor invocation | |
|
250 | > pretxncommit.unexpectedabort = false | |
|
251 | > __EOF__ | |
|
252 | ||
|
253 | $ rm -f .hg/last-message.txt | |
|
254 | $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg tag custom-tag -e | |
|
255 | transaction abort! | |
|
256 | rollback completed | |
|
257 | note: commit message saved in .hg/last-message.txt | |
|
258 | abort: pretxncommit.unexpectedabort hook exited with status 1 | |
|
259 | [255] | |
|
260 | $ cat .hg/last-message.txt | |
|
237 | 261 | custom tag message |
|
238 | 262 | second line |
|
239 | $ cat > .hg/hgrc << '__EOF__' | |
|
263 | ||
|
264 | $ cat >> .hg/hgrc << '__EOF__' | |
|
240 | 265 | > [hooks] |
|
241 | > pretag.test-saving-lastmessage = | |
|
266 | > pretxncommit.unexpectedabort = | |
|
242 | 267 | > __EOF__ |
|
268 | $ hg status .hgtags | |
|
269 | M .hgtags | |
|
270 | $ hg revert --no-backup -q .hgtags | |
|
243 | 271 | |
|
244 | 272 | then, test custom commit message itself |
|
245 | 273 |
General Comments 0
You need to be logged in to leave comments.
Login now