[PATCH] convert: return remote branches in git source

Edouard Gomez ed.gomez at free.fr
Sat Oct 18 17:33:13 CDT 2008


# HG changeset patch
# User Edouard Gomez <ed.gomez at free.fr>
# Date 1224369143 -7200
# Node ID 2803ec650f9e26de1f6041fc0bd974c37376d12a
# Parent  8104950cf054f87a6c42c7a2ded7c301094507d1
convert: return remote branches in git source

When converting git repos, all stuff happening on branches
seems to be ignored.

This is caused by the fact a "git clone" of a remote git
repo has all its branches prefixed with "origin/". By
chance, the "origin/master" branch is always linked to a
local "master" branch. So getheads() returns only the
master head, and it ignores all the other heads.

Make sure getheads() returns all heads, forcing remote
branches to be return by git-rev-parse.

diff --git a/hgext/convert/git.py b/hgext/convert/git.py
--- a/hgext/convert/git.py
+++ b/hgext/convert/git.py
@@ -38,7 +38,7 @@
 
     def getheads(self):
         if not self.rev:
-            return self.gitcmd('git rev-parse --branches').read().splitlines()
+            return self.gitcmd('git rev-parse --branches --remotes').read().splitlines()
         else:
             fh = self.gitcmd("git rev-parse --verify %s" % self.rev)
             return [fh.read()[:-1]]


More information about the Mercurial-devel mailing list