comparison hggit/git_handler.py @ 381:80544310834a

fix handling of spaces in hg tag names
author Dmitry Gladkov <dmitry.gladkov@gmail.com>
date Wed, 23 Mar 2011 01:03:29 +0200
parents b4f5f2729acb
children f55869b556f0
comparison
equal deleted inserted replaced
378:d27379c0abde 381:80544310834a
572 ctx = self.repo[rev] 572 ctx = self.repo[rev]
573 if getattr(ctx, 'bookmarks', None): 573 if getattr(ctx, 'bookmarks', None):
574 labels = lambda c: ctx.tags() + ctx.bookmarks() 574 labels = lambda c: ctx.tags() + ctx.bookmarks()
575 else: 575 else:
576 labels = lambda c: ctx.tags() 576 labels = lambda c: ctx.tags()
577 heads = [t for t in labels(ctx) if t in self.local_heads()] 577 prep = lambda itr: [i.replace(' ', '_') for i in itr]
578 tags = [t for t in labels(ctx) if t in self.tags] 578
579 heads = [t for t in prep(labels(ctx)) if t in self.local_heads()]
580 tags = [t for t in prep(labels(ctx)) if t in self.tags]
579 581
580 if not (heads or tags): 582 if not (heads or tags):
581 raise hgutil.Abort("revision %s cannot be pushed since" 583 raise hgutil.Abort("revision %s cannot be pushed since"
582 " it doesn't have a ref" % ctx) 584 " it doesn't have a ref" % ctx)
583 585
674 self.git.refs['refs/heads/' + key] = self.map_git_get(heads[key]) 676 self.git.refs['refs/heads/' + key] = self.map_git_get(heads[key])
675 677
676 def export_hg_tags(self): 678 def export_hg_tags(self):
677 for tag, sha in self.repo.tags().iteritems(): 679 for tag, sha in self.repo.tags().iteritems():
678 if self.repo.tagtype(tag) in ('global', 'git'): 680 if self.repo.tagtype(tag) in ('global', 'git'):
681 tag = tag.replace(' ', '_')
679 self.git.refs['refs/tags/' + tag] = self.map_git_get(hex(sha)) 682 self.git.refs['refs/tags/' + tag] = self.map_git_get(hex(sha))
680 self.tags[tag] = hex(sha) 683 self.tags[tag] = hex(sha)
681 684
682 def local_heads(self): 685 def local_heads(self):
683 try: 686 try: