3 import os |
3 import os |
4 |
4 |
5 from common import NoRepo, commit, converter_source |
5 from common import NoRepo, commit, converter_source |
6 |
6 |
7 class convert_git(converter_source): |
7 class convert_git(converter_source): |
8 def gitcmd(self, s): |
8 # Windows does not support GIT_DIR= construct while other systems |
9 return os.popen('GIT_DIR=%s %s' % (self.path, s)) |
9 # cannot remove environment variable. Just assume none have |
|
10 # both issues. |
|
11 if hasattr(os, 'unsetenv'): |
|
12 def gitcmd(self, s): |
|
13 prevgitdir = os.environ.get('GIT_DIR') |
|
14 os.environ['GIT_DIR'] = self.path |
|
15 try: |
|
16 return os.popen(s) |
|
17 finally: |
|
18 if prevgitdir is None: |
|
19 del os.environ['GIT_DIR'] |
|
20 else: |
|
21 os.environ['GIT_DIR'] = prevgitdir |
|
22 else: |
|
23 def gitcmd(self, s): |
|
24 return os.popen('GIT_DIR=%s %s' % (self.path, s)) |
10 |
25 |
11 def __init__(self, ui, path, rev=None): |
26 def __init__(self, ui, path, rev=None): |
12 super(convert_git, self).__init__(ui, path, rev=rev) |
27 super(convert_git, self).__init__(ui, path, rev=rev) |
13 |
28 |
14 if os.path.isdir(path + "/.git"): |
29 if os.path.isdir(path + "/.git"): |