Signed-off-by: Felipe Contreras <[email protected]>
---
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
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html