Return to the current directory after dealing with git revision calculation
authorMatthieu Patou <mat@matws.net>
Tue, 9 Nov 2010 22:58:37 +0000 (01:58 +0300)
committerMatthieu Patou <mat@matws.net>
Tue, 9 Nov 2010 22:58:37 +0000 (01:58 +0300)
buildfarm/history.py

index 51e35f4a61cddf2e677e3721d3d70911dc25280e..6ca1af86fa764ba92731bee24f9d240a32275047 100644 (file)
@@ -51,7 +51,6 @@ class History(object):
 
     def _git_diff(self, t, revision, tree):
         """show recent git entries"""
-        os.chdir(os.path.join(UNPACKED_DIR, tree))
 
         log = self._log(tree)
 
@@ -68,8 +67,16 @@ class History(object):
         title = "GIT Diff in %s:%s for revision %s" % (
             tree, t.branch, revision)
 
-        cmd = "git diff %s^ %s ./" % (revision, revision)
-        return (title, entry, tree, [(cmd, commands.getoutput("%s 2> /dev/null" % cmd))])
+        pwd = os.environ["PWD"]
+        ret = None
+        try:
+            os.chdir(os.path.join(UNPACKED_DIR, tree))
+            cmd = "git diff %s^ %s ./" % (revision, revision)
+            ret = (title, entry, tree, [(cmd, commands.getoutput("%s 2> /dev/null" % cmd))])
+
+        finally:
+            os.chdir(pwd)
+            return ret
 
     def authors(self, tree):
         log = self._log(tree)