Mercurial > hg
comparison 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 |
comparison
equal
deleted
inserted
replaced
25748:baea47cafe75 | 25749:f2748cc43b2a |
---|---|
87 return data, fh.close() | 87 return data, fh.close() |
88 | 88 |
89 def __init__(self, ui, path, revs=None): | 89 def __init__(self, ui, path, revs=None): |
90 super(convert_git, self).__init__(ui, path, revs=revs) | 90 super(convert_git, self).__init__(ui, path, revs=revs) |
91 | 91 |
92 if revs and len(revs) > 1: | |
93 raise util.Abort(_("git source does not support specifying " | |
94 "multiple revs")) | |
95 | |
96 if os.path.isdir(path + "/.git"): | 92 if os.path.isdir(path + "/.git"): |
97 path += "/.git" | 93 path += "/.git" |
98 if not os.path.exists(path + "/objects"): | 94 if not os.path.exists(path + "/objects"): |
99 raise NoRepo(_("%s does not look like a Git repository") % path) | 95 raise NoRepo(_("%s does not look like a Git repository") % path) |
100 | 96 |
124 | 120 |
125 def getheads(self): | 121 def getheads(self): |
126 if not self.revs: | 122 if not self.revs: |
127 heads, ret = self.gitread('git rev-parse --branches --remotes') | 123 heads, ret = self.gitread('git rev-parse --branches --remotes') |
128 heads = heads.splitlines() | 124 heads = heads.splitlines() |
125 if ret: | |
126 raise util.Abort(_('cannot retrieve git heads')) | |
129 else: | 127 else: |
130 heads, ret = self.gitread("git rev-parse --verify %s" % | 128 heads = [] |
131 self.revs[0]) | 129 for rev in self.revs: |
132 heads = [heads[:-1]] | 130 rawhead, ret = self.gitread("git rev-parse --verify %s" % rev) |
133 if ret: | 131 heads.append(rawhead[:-1]) |
134 raise util.Abort(_('cannot retrieve git heads')) | 132 if ret: |
133 raise util.Abort(_('cannot retrieve git head "%s"') % rev) | |
135 return heads | 134 return heads |
136 | 135 |
137 def catfile(self, rev, type): | 136 def catfile(self, rev, type): |
138 if rev == hex(nullid): | 137 if rev == hex(nullid): |
139 raise IOError | 138 raise IOError |