Mercurial > hg
diff hgext/convert/git.py @ 25749:f2748cc43b2a
convert: support multiple specifed revs in git source
This allows specifying multiple revs/branches to convert from a git repo.
author | Durham Goode <durham@fb.com> |
---|---|
date | Wed, 08 Jul 2015 10:29:11 -0700 |
parents | baea47cafe75 |
children | d9133e89d39d |
line wrap: on
line diff
--- a/hgext/convert/git.py Wed Jul 08 10:27:43 2015 -0700 +++ b/hgext/convert/git.py Wed Jul 08 10:29:11 2015 -0700 @@ -89,10 +89,6 @@ def __init__(self, ui, path, revs=None): super(convert_git, self).__init__(ui, path, revs=revs) - if revs and len(revs) > 1: - raise util.Abort(_("git source does not support specifying " - "multiple revs")) - if os.path.isdir(path + "/.git"): path += "/.git" if not os.path.exists(path + "/objects"): @@ -126,12 +122,15 @@ if not self.revs: heads, ret = self.gitread('git rev-parse --branches --remotes') heads = heads.splitlines() + if ret: + raise util.Abort(_('cannot retrieve git heads')) else: - heads, ret = self.gitread("git rev-parse --verify %s" % - self.revs[0]) - heads = [heads[:-1]] - if ret: - raise util.Abort(_('cannot retrieve git heads')) + heads = [] + for rev in self.revs: + rawhead, ret = self.gitread("git rev-parse --verify %s" % rev) + heads.append(rawhead[:-1]) + if ret: + raise util.Abort(_('cannot retrieve git head "%s"') % rev) return heads def catfile(self, rev, type):