remote-hg: fake bookmark when there's none

Or at least no current bookmark. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Jeff King <peff@peff.net>

Felipe Contreras committed Nov 4, 2012 at 03:13 UTC 46cc3adb60f45273dcb0f9179d20bffe1f77f4ff
1 file changed +14 -5
contrib/remote-helpers/git-remote-hg
+14 -5
@@ -26,7 +26,7 @@ import urllib
26 # git:
27 # Sensible defaults for git.
28 # hg bookmarks are exported as git branches, hg branches are prefixed
29 -# with 'branches/'.
29 +# with 'branches/', HEAD is a special case.
30 #
31 # hg:
32 # Emulate hg-git.
@@ -430,12 +430,21 @@ def get_branch_tip(repo, branch):
430 return heads[0]
431
432 def list_head(repo, cur):
433 - global g_head
433 + global g_head, bmarks
434
435 head = bookmarks.readcurrent(repo)
436 - if not head:
437 - return
438 - node = repo[head]
436 + if head:
437 + node = repo[head]
438 + else:
439 + # fake bookmark from current branch
440 + head = cur
441 + node = repo['.']
442 + if not node:
443 + return
444 + if head == 'default':
445 + head = 'master'
446 + bmarks[head] = node
447 +
448 print "@refs/heads/%s HEAD" % head
449 g_head = (head, node)
450