equal
deleted
inserted
replaced
1 # git support for the convert extension |
1 # git support for the convert extension |
2 |
2 |
3 import os |
3 import os |
|
4 from mercurial import util |
4 |
5 |
5 from common import NoRepo, commit, converter_source |
6 from common import NoRepo, commit, converter_source |
6 |
7 |
7 class convert_git(converter_source): |
8 class convert_git(converter_source): |
8 # Windows does not support GIT_DIR= construct while other systems |
9 # Windows does not support GIT_DIR= construct while other systems |
39 fh = self.gitcmd("git-rev-parse --verify %s" % self.rev) |
40 fh = self.gitcmd("git-rev-parse --verify %s" % self.rev) |
40 return [fh.read()[:-1]] |
41 return [fh.read()[:-1]] |
41 |
42 |
42 def catfile(self, rev, type): |
43 def catfile(self, rev, type): |
43 if rev == "0" * 40: raise IOError() |
44 if rev == "0" * 40: raise IOError() |
44 fh = self.gitcmd("git-cat-file %s %s 2>/dev/null" % (type, rev)) |
45 fh = self.gitcmd("git-cat-file %s %s 2>%s" % (type, rev, |
|
46 util.nulldev)) |
45 return fh.read() |
47 return fh.read() |
46 |
48 |
47 def getfile(self, name, rev): |
49 def getfile(self, name, rev): |
48 return self.catfile(rev, "blob") |
50 return self.catfile(rev, "blob") |
49 |
51 |
99 rev=version) |
101 rev=version) |
100 return c |
102 return c |
101 |
103 |
102 def gettags(self): |
104 def gettags(self): |
103 tags = {} |
105 tags = {} |
104 fh = self.gitcmd('git-ls-remote --tags "%s" 2>/dev/null' % self.path) |
106 fh = self.gitcmd('git-ls-remote --tags "%s" 2>%s' % (self.path, |
|
107 util.nulldev)) |
105 prefix = 'refs/tags/' |
108 prefix = 'refs/tags/' |
106 for line in fh: |
109 for line in fh: |
107 line = line.strip() |
110 line = line.strip() |
108 if not line.endswith("^{}"): |
111 if not line.endswith("^{}"): |
109 continue |
112 continue |