git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/2] remote-bzr: improve tag handling

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
Apr 8, 2013, 18:36 UTC
Message-ID
<1365446199-11382-3-git-send-email-felipe.contreras@gmail.com>
In-Reply-To
<1365446199-11382-1-git-send-email-felipe.contreras@gmail.com>

revision_history() is deprecated and doesn't do what we want (revno instead of dotted_revno?).

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 contrib/remote-helpers/git-remote-bzr | 25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)
diff --git a/contrib/remote-helpers/git-remote-bzr b/contrib/remote-helpers/git-remote-bzr
index 55ebf19..bd25e08 100755
--- a/contrib/remote-helpers/git-remote-bzr
+++ b/contrib/remote-helpers/git-remote-bzr
@@ -25,6 +25,7 @@ bzrlib.plugin.load_plugins()
 
 import bzrlib.generate_ids
 import bzrlib.transport
+import bzrlib.errors
 
 import sys
 import os
@@ -335,12 +336,9 @@ def export_branch(branch, name):
 
 def export_tag(repo, name):
     global tags
-    try:
-        print "reset refs/tags/%s" % name
-        print "from :%u" % rev_to_mark(tags[name])
-        print
-    except KeyError:
-        warn("TODO: fetch tag '%s'" % name)
+    print "reset refs/tags/%s" % name
+    print "from :%u" % rev_to_mark(tags[name])
+    print
 
 def do_import(parser):
     global dirname
@@ -660,16 +658,25 @@ def do_capabilities(parser):
 
     print
 
+def ref_is_valid(name):
+    return not True in [c in name for c in '~^: \\']
+
 def do_list(parser):
     global tags
     print "? refs/heads/%s" % 'master'
 
-    history = parser.repo.revision_history()
-    for tag, revid in parser.repo.tags.get_tag_dict().items():
-        if revid not in history:
+    branch = parser.repo
+    branch.lock_read()
+    for tag, revid in branch.tags.get_tag_dict().items():
+        try:
+            branch.revision_id_to_dotted_revno(revid)
+        except bzrlib.errors.NoSuchRevision:
+            continue
+        if not ref_is_valid(tag):
             continue
         print "? refs/tags/%s" % tag
         tags[tag] = revid
+    branch.unlock()
     print "@refs/heads/%s HEAD" % 'master'
     print
 
-- 
1.8.2
Previous: Felipe Contreras
Message 3 of 3 in “remote-bzr: fixes”
  1. 0/2 remote-bzr: fixesFelipe Contreras, Apr 8, 2013
  2. 1/2 remote-bzr: fix utf-8 support for fetchingFelipe Contreras, Apr 8, 2013
  3. 2/2 remote-bzr: improve tag handlingFelipe Contreras, Apr 8, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.