[PATCH] convert: fetch all heads of a git repository

Brendan Cully brendan at kublai.com
Sun Jul 1 16:09:14 CDT 2007


On Sunday, 01 July 2007 at 16:03, Matt Mackall wrote:
> On Sun, Jul 01, 2007 at 01:41:29PM -0700, Brendan Cully wrote:
> > # HG changeset patch
> > # User Brendan Cully <brendan at kublai.com>
> > # Date 1183322471 25200
> > # Node ID e6f7abdd86521b5a149a78b7d25b7d23653c20d5
> > # Parent  20ec5cc02f1878e6dbb52d2c49b7ad39029a7a3b
> > convert: fetch all heads of a git repository
> > 
> > diff --git a/hgext/convert/git.py b/hgext/convert/git.py
> > --- a/hgext/convert/git.py
> > +++ b/hgext/convert/git.py
> > @@ -16,8 +16,9 @@ class convert_git(converter_source):
> >          self.encoding = 'utf-8'
> >  
> >      def getheads(self):
> > -        fh = os.popen("GIT_DIR=%s git-rev-parse --verify HEAD" % self.path)
> > -        return [fh.read()[:-1]]
> > +        fh = os.popen("GIT_DIR=%s git-rev-parse --branches" % self.path)
> > +        heads = fh.read().splitlines()
> > +        return heads
> 
> Looks good.

There may be a couple of issues:
1. I don't know when git-rev-parse got --branches. It might need a
   fallback.
2. it would maybe be nice if the different branches each got their own
   clone. Named branches don't really fit very well since lots of revs
   are going to be on several branches at once...


More information about the Mercurial-devel mailing list