Skip to content
Snippets Groups Projects
Commit f2748cc43b2a authored by Durham Goode's avatar Durham Goode
Browse files

convert: support multiple specifed revs in git source

This allows specifying multiple revs/branches to convert from a git repo.
parent baea47cafe75
No related branches found
No related tags found
No related merge requests found
...@@ -89,10 +89,6 @@ ...@@ -89,10 +89,6 @@
def __init__(self, ui, path, revs=None): def __init__(self, ui, path, revs=None):
super(convert_git, self).__init__(ui, path, revs=revs) 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"): if os.path.isdir(path + "/.git"):
path += "/.git" path += "/.git"
if not os.path.exists(path + "/objects"): if not os.path.exists(path + "/objects"):
...@@ -126,4 +122,6 @@ ...@@ -126,4 +122,6 @@
if not self.revs: if not self.revs:
heads, ret = self.gitread('git rev-parse --branches --remotes') heads, ret = self.gitread('git rev-parse --branches --remotes')
heads = heads.splitlines() heads = heads.splitlines()
if ret:
raise util.Abort(_('cannot retrieve git heads'))
else: else:
...@@ -129,9 +127,10 @@ ...@@ -129,9 +127,10 @@
else: else:
heads, ret = self.gitread("git rev-parse --verify %s" % heads = []
self.revs[0]) for rev in self.revs:
heads = [heads[:-1]] rawhead, ret = self.gitread("git rev-parse --verify %s" % rev)
if ret: heads.append(rawhead[:-1])
raise util.Abort(_('cannot retrieve git heads')) if ret:
raise util.Abort(_('cannot retrieve git head "%s"') % rev)
return heads return heads
def catfile(self, rev, type): def catfile(self, rev, type):
......
...@@ -442,6 +442,40 @@ ...@@ -442,6 +442,40 @@
abort: --sourcesort is not supported by this data source abort: --sourcesort is not supported by this data source
[255] [255]
test converting certain branches
$ mkdir git-testrevs
$ cd git-testrevs
$ git init
Initialized empty Git repository in $TESTTMP/git-testrevs/.git/
$ echo a >> a ; git add a > /dev/null; git commit -m 'first' > /dev/null
$ echo a >> a ; git add a > /dev/null; git commit -m 'master commit' > /dev/null
$ git checkout -b goodbranch 'HEAD^'
Switched to a new branch 'goodbranch'
$ echo a >> b ; git add b > /dev/null; git commit -m 'good branch commit' > /dev/null
$ git checkout -b badbranch 'HEAD^'
Switched to a new branch 'badbranch'
$ echo a >> c ; git add c > /dev/null; git commit -m 'bad branch commit' > /dev/null
$ cd ..
$ hg convert git-testrevs hg-testrevs --rev master --rev goodbranch
initializing destination hg-testrevs repository
scanning source...
sorting...
converting...
2 first
1 good branch commit
0 master commit
updating bookmarks
$ cd hg-testrevs
$ hg log -G -T '{rev} {bookmarks}'
o 2 master
|
| o 1 goodbranch
|/
o 0
$ cd ..
test sub modules test sub modules
$ mkdir git-repo5 $ mkdir git-repo5
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment