Skip to content

Instantly share code, notes, and snippets.

@undees
Created May 16, 2009 09:15
Show Gist options
  • Save undees/112636 to your computer and use it in GitHub Desktop.
Save undees/112636 to your computer and use it in GitHub Desktop.
# This version of update_references just updates the local branch names.
# We need to map these sensibly to remote names, but since this method
# is also used by gexport (which doesn't take a remote repo), that
# mapping probably needs to go elsewhere--which brings us to gpush....
#
# gpush takes an as-yet-unused branch name parameter. A decent first
# approach would probably be to create a remote ref for the pushed-to
# repo with the same as the local branch name, bailing if the local
# branch doesn't exist.
#
# Before I undertake that bit, though, I'm seeking a quick "yup, that's
# the intent" or "nope, people will expect it to act like so" first.
#
# Twitter: @undees
def update_references(self):
try:
# We only care about bookmarks of the form 'name',
# not 'remote/name'.
def is_local_ref(item): return item[0].count('/') == 0
bms = bookmarks.parse(self.repo)
bms = dict(filter(is_local_ref, bms.items()))
# Create a local Git branch name for each
# Mercurial bookmark.
for key in bms:
hg_sha = hex(bms[key])
git_sha = self.map_git_get(hg_sha)
self.git.set_ref('refs/heads/' + key, git_sha)
except AttributeError:
# No bookmarks extension
pass
c = self.map_git_get(hex(self.repo.changelog.tip()))
self.git.set_ref('refs/heads/master', c)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment