Skip to content

Commit 45a1e8f

Browse files
committed
hg bookmarks to local git branches
1 parent c77ed6d commit 45a1e8f

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

git_handler.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,23 @@ def remote_name_to_url(self, remote_name):
154154
return self._config['remote.' + remote_name + '.url']
155155

156156
def update_references(self):
157-
# TODO : if bookmarks exist, add them as git branches
157+
try:
158+
# We only care about bookmarks of the form 'name',
159+
# not 'remote/name'.
160+
def is_local_ref(item): return item[0].count('/') == 0
161+
bms = bookmarks.parse(self.repo)
162+
bms = dict(filter(is_local_ref, bms.items()))
163+
164+
# Create a local Git branch name for each
165+
# Mercurial bookmark.
166+
for key in bms:
167+
hg_sha = hex(bms[key])
168+
git_sha = self.map_git_get(hg_sha)
169+
self.git.set_ref('refs/heads/' + key, git_sha)
170+
except AttributeError:
171+
# No bookmarks extension
172+
pass
173+
158174
c = self.map_git_get(hex(self.repo.changelog.tip()))
159175
self.git.set_ref('refs/heads/master', c)
160176

0 commit comments

Comments
 (0)