Skip to content

Commit fa7285d

Browse files
felipecgitster
authored andcommitted
remote-bzr: improve tag handling
revision_history() is deprecated and doesn't do what we want (revno instead of dotted_revno?). Signed-off-by: Felipe Contreras <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5ff4fc6 commit fa7285d

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

contrib/remote-helpers/git-remote-bzr

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ bzrlib.plugin.load_plugins()
2525

2626
import bzrlib.generate_ids
2727
import bzrlib.transport
28+
import bzrlib.errors
2829

2930
import sys
3031
import os
@@ -335,12 +336,9 @@ def export_branch(branch, name):
335336

336337
def export_tag(repo, name):
337338
global tags
338-
try:
339-
print "reset refs/tags/%s" % name
340-
print "from :%u" % rev_to_mark(tags[name])
341-
print
342-
except KeyError:
343-
warn("TODO: fetch tag '%s'" % name)
339+
print "reset refs/tags/%s" % name
340+
print "from :%u" % rev_to_mark(tags[name])
341+
print
344342

345343
def do_import(parser):
346344
global dirname
@@ -660,16 +658,25 @@ def do_capabilities(parser):
660658

661659
print
662660

661+
def ref_is_valid(name):
662+
return not True in [c in name for c in '~^: \\']
663+
663664
def do_list(parser):
664665
global tags
665666
print "? refs/heads/%s" % 'master'
666667

667-
history = parser.repo.revision_history()
668-
for tag, revid in parser.repo.tags.get_tag_dict().items():
669-
if revid not in history:
668+
branch = parser.repo
669+
branch.lock_read()
670+
for tag, revid in branch.tags.get_tag_dict().items():
671+
try:
672+
branch.revision_id_to_dotted_revno(revid)
673+
except bzrlib.errors.NoSuchRevision:
674+
continue
675+
if not ref_is_valid(tag):
670676
continue
671677
print "? refs/tags/%s" % tag
672678
tags[tag] = revid
679+
branch.unlock()
673680
print "@refs/heads/%s HEAD" % 'master'
674681
print
675682

0 commit comments

Comments
 (0)