]> thyrsus.com Git - src.git/commitdiff
Deal gracefully with absolute pathnames.
authorEric S. Raymond <esr@thyrsus.com>
Fri, 21 Nov 2014 11:03:19 +0000 (06:03 -0500)
committerEric S. Raymond <esr@thyrsus.com>
Fri, 21 Nov 2014 11:03:19 +0000 (06:03 -0500)
Regression tests pass.

src

diff --git a/src b/src
index 430e15e3603249a4c3fd6fd38c782376e5db4012..146b867896fa712a6bf68cc7952f640bcd8df8a1 100755 (executable)
--- a/src
+++ b/src
@@ -1601,9 +1601,13 @@ class RCS:
         "Temporarily lift a master to the working directory."
         def __init__(self, name):
             self.name = name
+            self.where = os.getcwd()
         def __enter__(self):
+            if os.path.dirname(self.name):
+                os.chdir(os.path.dirname(self.name))
             do_or_die("mv {0}/{1},v .".format(repodir, self.name))
         def __exit__(self, extype, value, traceback_unused):
+            os.chdir(self.where)
             if extype and debug > 0:
                 raise extype(value)
             do_or_die("mv {0},v {1}".format(self.name, repodir))
@@ -1611,12 +1615,9 @@ class RCS:
     def lifter(self, name):
         return RCS.RCSLifter(name)
     def history(self, arg):
-        if os.sep not in arg:
-            return os.path.join(repodir, arg + ",v")
-        else:
-            return os.path.join(os.path.dirname(arg),
-                                repodir,
-                                os.path.basename(arg) + ",v")
+        return os.path.join(os.path.dirname(arg),
+                            repodir,
+                            os.path.basename(arg) + ",v")
     def has_revisions(self, arg):
         "Does the master for this file have any revisions"
         # The magic number 105 is the size of an empty RCS file (no