git-p4: chdir now properly sets PWD environment variable in msysGit
P4 on Windows expects the PWD environment variable to be set to the current working dir, but os.chdir in python doesn't do so. Signed-off-by: Robert Blum <rob.blum@gmail.com> Acked-by: Simon Hausmann <simon@lst.de> Acked-by: Han-Wen Nienhuys <hanwen@xs4all.nl> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Robert Blum committed
Aug 1, 2008 at 12:50 UTC
053fd0c1c3da20474c4ff175c56ea4c1d6eeda11
1 file changed
+9
-4
contrib/fast-import/git-p4
+9
-4
@@ -16,6 +16,11 @@ from sets import Set;
16
17
verbose = False
18
19
+def chdir(dir):
20
+ if os.name == 'nt':
21
+ os.environ['PWD']=dir
22
+ os.chdir(dir)
23
+
24
def die(msg):
25
if verbose:
26
raise Exception(msg)
@@ -712,7 +717,7 @@ class P4Submit(Command):
717
print "Perforce checkout for depot path %s located at %s" % (self.depotPath, self.clientPath)
718
self.oldWorkingDirectory = os.getcwd()
719
715
- os.chdir(self.clientPath)
720
+ chdir(self.clientPath)
721
print "Syncronizing p4 checkout..."
722
system("p4 sync ...")
723
@@ -732,7 +737,7 @@ class P4Submit(Command):
737
738
if len(commits) == 0:
739
print "All changes applied!"
735
- os.chdir(self.oldWorkingDirectory)
740
+ chdir(self.oldWorkingDirectory)
741
742
sync = P4Sync()
743
sync.run([])
@@ -1670,7 +1675,7 @@ class P4Clone(P4Sync):
1675
print "Importing from %s into %s" % (', '.join(depotPaths), self.cloneDestination)
1676
if not os.path.exists(self.cloneDestination):
1677
os.makedirs(self.cloneDestination)
1673
- os.chdir(self.cloneDestination)
1678
+ chdir(self.cloneDestination)
1679
system("git init")
1680
self.gitdir = os.getcwd() + "/.git"
1681
if not P4Sync.run(self, depotPaths):
@@ -1782,7 +1787,7 @@ def main():
1787
if os.path.exists(cmd.gitdir):
1788
cdup = read_pipe("git rev-parse --show-cdup").strip()
1789
if len(cdup) > 0:
1785
- os.chdir(cdup);
1790
+ chdir(cdup);
1791
1792
if not isValidGitDir(cmd.gitdir):
1793
if isValidGitDir(cmd.gitdir + "/.git"):