##// END OF EJS Templates
localrepo: add "editor" argument to "tag()"...
FUJIWARA Katsunori -
r21237:0054a77f default
parent child Browse files
Show More
@@ -5684,15 +5684,18 b' def tag(ui, repo, name1, *names, **opts)'
5684 date = util.parsedate(date)
5684 date = util.parsedate(date)
5685
5685
5686 if opts.get('edit'):
5686 if opts.get('edit'):
5687 message = ui.edit(message, ui.username())
5687 def editor(repo, ctx, subs):
5688 repo.savecommitmessage(message)
5688 return ui.edit(ctx.description() + "\n", ctx.user())
5689 else:
5690 editor = False
5689
5691
5690 # don't allow tagging the null rev
5692 # don't allow tagging the null rev
5691 if (not opts.get('remove') and
5693 if (not opts.get('remove') and
5692 scmutil.revsingle(repo, rev_).rev() == nullrev):
5694 scmutil.revsingle(repo, rev_).rev() == nullrev):
5693 raise util.Abort(_("cannot tag null revision"))
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 finally:
5699 finally:
5697 release(lock, wlock)
5700 release(lock, wlock)
5698
5701
@@ -479,7 +479,8 b' class localrepository(object):'
479 return hook.hook(self.ui, self, name, throw, **args)
479 return hook.hook(self.ui, self, name, throw, **args)
480
480
481 @unfilteredmethod
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 if isinstance(names, str):
484 if isinstance(names, str):
484 names = (names,)
485 names = (names,)
485
486
@@ -539,14 +540,15 b' class localrepository(object):'
539 self[None].add(['.hgtags'])
540 self[None].add(['.hgtags'])
540
541
541 m = matchmod.exact(self.root, '', ['.hgtags'])
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 for name in names:
546 for name in names:
545 self.hook('tag', node=hex(node), tag=name, local=local)
547 self.hook('tag', node=hex(node), tag=name, local=local)
546
548
547 return tagnode
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 '''tag a revision with one or more symbolic names.
552 '''tag a revision with one or more symbolic names.
551
553
552 names is a list of strings or, when adding a single tag, names may be a
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 '(please commit .hgtags manually)'))
576 '(please commit .hgtags manually)'))
575
577
576 self.tags() # instantiate the cache
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 @filteredpropertycache
581 @filteredpropertycache
580 def _tagscache(self):
582 def _tagscache(self):
@@ -225,8 +225,11 b' test custom commit messages'
225
225
226 at first, test saving last-message.txt
226 at first, test saving last-message.txt
227
227
228 (test that editor is not invoked before transaction starting)
229
228 $ cat > .hg/hgrc << '__EOF__'
230 $ cat > .hg/hgrc << '__EOF__'
229 > [hooks]
231 > [hooks]
232 > # this failure occurs before editor invocation
230 > pretag.test-saving-lastmessage = false
233 > pretag.test-saving-lastmessage = false
231 > __EOF__
234 > __EOF__
232 $ rm -f .hg/last-message.txt
235 $ rm -f .hg/last-message.txt
@@ -234,12 +237,37 b' at first, test saving last-message.txt'
234 abort: pretag.test-saving-lastmessage hook exited with status 1
237 abort: pretag.test-saving-lastmessage hook exited with status 1
235 [255]
238 [255]
236 $ cat .hg/last-message.txt
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 custom tag message
261 custom tag message
238 second line
262 second line
239 $ cat > .hg/hgrc << '__EOF__'
263
264 $ cat >> .hg/hgrc << '__EOF__'
240 > [hooks]
265 > [hooks]
241 > pretag.test-saving-lastmessage =
266 > pretxncommit.unexpectedabort =
242 > __EOF__
267 > __EOF__
268 $ hg status .hgtags
269 M .hgtags
270 $ hg revert --no-backup -q .hgtags
243
271
244 then, test custom commit message itself
272 then, test custom commit message itself
245
273
General Comments 0
You need to be logged in to leave comments. Login now