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

[PATCH v5 02/14] remote-hg: add support for bookmarks

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
Oct 30, 2012, 04:35 UTC
Message-ID
<1351571736-4682-3-git-send-email-felipe.contreras@gmail.com>
In-Reply-To
<1351571736-4682-1-git-send-email-felipe.contreras@gmail.com>
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 contrib/remote-hg/git-remote-hg | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)
diff --git a/contrib/remote-hg/git-remote-hg b/contrib/remote-hg/git-remote-hg
index 67d39fa..9e29daa 100755
--- a/contrib/remote-hg/git-remote-hg
+++ b/contrib/remote-hg/git-remote-hg
@@ -9,7 +9,7 @@
 # Then you can clone with:
 # git clone hg::/path/to/mercurial/repo/
 
-from mercurial import hg, ui
+from mercurial import hg, ui, bookmarks
 
 import re
 import sys
@@ -232,6 +232,10 @@ def export_ref(repo, name, kind, head):
 def export_tag(repo, tag):
     export_ref(repo, tag, 'tags', repo[tag])
 
+def export_bookmark(repo, bmark):
+    head = bmarks[bmark]
+    export_ref(repo, bmark, 'bookmarks', head)
+
 def export_branch(repo, branch):
     tip = get_branch_tip(repo, branch)
     head = repo[tip]
@@ -246,6 +250,7 @@ def do_capabilities(parser):
 
     print "import"
     print "refspec refs/heads/branches/*:%s/branches/*" % prefix
+    print "refspec refs/heads/*:%s/bookmarks/*" % prefix
     print "refspec refs/tags/*:%s/tags/*" % prefix
     print
 
@@ -272,7 +277,7 @@ def list_branch_head(repo, cur):
     g_head = (head, 'branches', repo[tip])
 
 def do_list(parser):
-    global branches
+    global branches, bmarks
 
     repo = parser.repo
     for branch in repo.branchmap():
@@ -280,11 +285,16 @@ def do_list(parser):
         if len(heads):
             branches[branch] = heads
 
+    for bmark, node in bookmarks.listbookmarks(repo).iteritems():
+        bmarks[bmark] = repo[node]
+
     cur = repo.dirstate.branch()
 
     list_branch_head(repo, cur)
     for branch in branches:
         print "? refs/heads/branches/%s" % branch
+    for bmark in bmarks:
+        print "? refs/heads/%s" % bmark
 
     for tag, node in repo.tagslist():
         if tag == 'tip':
@@ -313,6 +323,9 @@ def do_import(parser):
         elif ref.startswith('refs/heads/branches/'):
             branch = ref[len('refs/heads/branches/'):]
             export_branch(repo, branch)
+        elif ref.startswith('refs/heads/'):
+            bmark = ref[len('refs/heads/'):]
+            export_bookmark(repo, bmark)
         elif ref.startswith('refs/tags/'):
             tag = ref[len('refs/tags/'):]
             export_tag(repo, tag)
@@ -322,7 +335,7 @@ def do_import(parser):
     print 'done'
 
 def main(args):
-    global prefix, dirname, marks, branches
+    global prefix, dirname, marks, branches, bmarks
 
     alias = args[1]
     url = args[2]
@@ -330,6 +343,7 @@ def main(args):
     gitdir = os.environ['GIT_DIR']
     dirname = os.path.join(gitdir, 'hg', alias)
     branches = {}
+    bmarks = {}
 
     repo = get_repo(url, alias)
     prefix = 'refs/hg/%s' % alias
-- 
1.8.0
Previous: Felipe ContrerasNext: Felipe Contreras
Message 3 of 26 in “New remote-hg helper”
  1. 00/14 New remote-hg helperFelipe Contreras, Oct 30, 2012
  2. 01/14 Add new remote-hg transport helperFelipe Contreras, Oct 30, 2012
  3. 02/14 remote-hg: add support for bookmarksFelipe Contreras, Oct 30, 2012
  4. 03/14 remote-hg: add support for pushingFelipe Contreras, Oct 30, 2012
  5. 04/14 remote-hg: add support for remote pushingFelipe Contreras, Oct 30, 2012
  6. 05/14 remote-hg: add support to push URLsFelipe Contreras, Oct 30, 2012
  7. 06/14 remote-hg: make sure the encoding is correctFelipe Contreras, Oct 30, 2012
  8. 07/14 remote-hg: match hg merge behaviorFelipe Contreras, Oct 30, 2012
  9. 08/14 remote-hg: add support for hg-git compat modeFelipe Contreras, Oct 30, 2012
  10. 09/14 remote-hg: add compat for hg-git author fixesFelipe Contreras, Oct 30, 2012
  11. 10/14 remote-hg: fake bookmark when there's noneFelipe Contreras, Oct 30, 2012
  12. 11/14 remote-hg: add support for fake remoteFelipe Contreras, Oct 30, 2012
  13. 12/14 remote-hg: add biridectional testsFelipe Contreras, Oct 30, 2012
  14. 13/14 remote-hg: add tests to compare with hg-gitFelipe Contreras, Oct 30, 2012
  15. 14/14 remote-hg: add extra author testFelipe Contreras, Oct 30, 2012
  16. Chris WebbOct 30, 2012
  17. Chris WebbOct 30, 2012
  18. Felipe ContrerasOct 30, 2012
  19. Chris WebbOct 30, 2012
  20. Chris WebbOct 30, 2012
  21. Felipe ContrerasOct 30, 2012
  22. Felipe ContrerasNov 1, 2012
  23. Chris WebbNov 11, 2012
  24. Felipe ContrerasNov 13, 2012
  25. Johannes SchindelinOct 30, 2012
  26. Felipe ContrerasOct 30, 2012

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.