comparison mercurial/localrepo.py @ 21237:0054a77f49df

localrepo: add "editor" argument to "tag()" Before this patch, "localrepository.tag()" doesn't take "editor" argument, and this prevents callers from passing "editor" argument to "localrepository.commit()" invoked internally. This patch adds "editor" argument to "localrepository.tag()" (and "_tag()", too), and makes "commands.tag()" invoke it with "editor" argument. This patch also omits explicit "localrepository.savecommitmesssage()" invocation, because "localrepository.commit()" will invoke specified "editor" and save edited commit message into ".hg/last-message.txt" automatically.
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Mon, 05 May 2014 21:26:40 +0900
parents 9f3652e851f8
children 3b4c75690206
comparison
equal deleted inserted replaced
21236:49148d7868df 21237:0054a77f49df
477 477
478 def hook(self, name, throw=False, **args): 478 def hook(self, name, throw=False, **args):
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
486 branches = self.branchmap() 487 branches = self.branchmap()
487 for name in names: 488 for name in names:
537 538
538 if '.hgtags' not in self.dirstate: 539 if '.hgtags' not in self.dirstate:
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
553 string. 555 string.
554 556
572 if '.hgtags' in x: 574 if '.hgtags' in x:
573 raise util.Abort(_('working copy of .hgtags is changed ' 575 raise util.Abort(_('working copy of .hgtags is changed '
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):
581 '''Returns a tagscache object that contains various tags related 583 '''Returns a tagscache object that contains various tags related
582 caches.''' 584 caches.'''