Show More
@@ -46,6 +46,18 b' class convert_git(converter_source):' | |||||
46 | del os.environ['GIT_DIR'] |
|
46 | del os.environ['GIT_DIR'] | |
47 | else: |
|
47 | else: | |
48 | os.environ['GIT_DIR'] = prevgitdir |
|
48 | os.environ['GIT_DIR'] = prevgitdir | |
|
49 | ||||
|
50 | def gitpipe(self, s): | |||
|
51 | prevgitdir = os.environ.get('GIT_DIR') | |||
|
52 | os.environ['GIT_DIR'] = self.path | |||
|
53 | try: | |||
|
54 | return util.popen3(s) | |||
|
55 | finally: | |||
|
56 | if prevgitdir is None: | |||
|
57 | del os.environ['GIT_DIR'] | |||
|
58 | else: | |||
|
59 | os.environ['GIT_DIR'] = prevgitdir | |||
|
60 | ||||
49 | else: |
|
61 | else: | |
50 | def gitopen(self, s, err=None): |
|
62 | def gitopen(self, s, err=None): | |
51 | if err == subprocess.PIPE: |
|
63 | if err == subprocess.PIPE: | |
@@ -56,6 +68,9 b' class convert_git(converter_source):' | |||||
56 | else: |
|
68 | else: | |
57 | return util.popen('GIT_DIR=%s %s' % (self.path, s), 'rb') |
|
69 | return util.popen('GIT_DIR=%s %s' % (self.path, s), 'rb') | |
58 |
|
70 | |||
|
71 | def gitpipe(self, s): | |||
|
72 | return util.popen3('GIT_DIR=%s %s' % (self.path, s)) | |||
|
73 | ||||
59 | def popen_with_stderr(self, s): |
|
74 | def popen_with_stderr(self, s): | |
60 | p = subprocess.Popen(s, shell=True, bufsize=-1, |
|
75 | p = subprocess.Popen(s, shell=True, bufsize=-1, | |
61 | close_fds=util.closefds, |
|
76 | close_fds=util.closefds, | |
@@ -84,6 +99,12 b' class convert_git(converter_source):' | |||||
84 | self.path = path |
|
99 | self.path = path | |
85 | self.submodules = [] |
|
100 | self.submodules = [] | |
86 |
|
101 | |||
|
102 | self.catfilepipe = self.gitpipe('git cat-file --batch') | |||
|
103 | ||||
|
104 | def after(self): | |||
|
105 | for f in self.catfilepipe: | |||
|
106 | f.close() | |||
|
107 | ||||
87 | def getheads(self): |
|
108 | def getheads(self): | |
88 | if not self.rev: |
|
109 | if not self.rev: | |
89 | heads, ret = self.gitread('git rev-parse --branches --remotes') |
|
110 | heads, ret = self.gitread('git rev-parse --branches --remotes') | |
@@ -98,9 +119,17 b' class convert_git(converter_source):' | |||||
98 | def catfile(self, rev, type): |
|
119 | def catfile(self, rev, type): | |
99 | if rev == hex(nullid): |
|
120 | if rev == hex(nullid): | |
100 | raise IOError |
|
121 | raise IOError | |
101 | data, ret = self.gitread("git cat-file %s %s" % (type, rev)) |
|
122 | self.catfilepipe[0].write(rev+'\n') | |
102 | if ret: |
|
123 | self.catfilepipe[0].flush() | |
|
124 | info = self.catfilepipe[1].readline().split() | |||
|
125 | if info[1] != type: | |||
103 | raise util.Abort(_('cannot read %r object at %s') % (type, rev)) |
|
126 | raise util.Abort(_('cannot read %r object at %s') % (type, rev)) | |
|
127 | size = int(info[2]) | |||
|
128 | data = self.catfilepipe[1].read(size) | |||
|
129 | if len(data) < size: | |||
|
130 | raise util.Abort(_('cannot read %r object at %s: %s') % (type, rev)) | |||
|
131 | # read the trailing newline | |||
|
132 | self.catfilepipe[1].read(1) | |||
104 | return data |
|
133 | return data | |
105 |
|
134 | |||
106 | def getfile(self, name, rev): |
|
135 | def getfile(self, name, rev): |
General Comments 0
You need to be logged in to leave comments.
Login now