diff options
author | W. Trevor King <wking@drexel.edu> | 2009-12-29 09:46:59 -0500 |
---|---|---|
committer | W. Trevor King <wking@drexel.edu> | 2009-12-29 09:46:59 -0500 |
commit | 6dafff3ad4a88d8af7b1cd4837b90179ac34a1e3 (patch) | |
tree | d01e5addbce342550d5dc2f509aa421080694c72 /libbe/storage/vcs/base.py | |
parent | 8bf8e2271f8273bdba3f8327d08b505a0fae11d5 (diff) | |
download | bugseverywhere-6dafff3ad4a88d8af7b1cd4837b90179ac34a1e3.tar.gz |
Added root directory handling to VCS._u_rel_path().
Now it returns '.' when you ask for the relative path from root to
itself. It used to raise AssertionError or InvalidPath.
Diffstat (limited to 'libbe/storage/vcs/base.py')
-rw-r--r-- | libbe/storage/vcs/base.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/libbe/storage/vcs/base.py b/libbe/storage/vcs/base.py index 040c3f9..7565caf 100644 --- a/libbe/storage/vcs/base.py +++ b/libbe/storage/vcs/base.py @@ -904,6 +904,10 @@ os.listdir(self.get_path("bugs")): >>> vcs = new() >>> vcs._u_rel_path("/a.b/c/.be", "/a.b/c") '.be' + >>> vcs._u_rel_path("/a.b/c/", "/a.b/c") + '.' + >>> vcs._u_rel_path("/a.b/c/", "/a.b/c/") + '.' """ if root == None: if self.repo == None: @@ -912,10 +916,10 @@ os.listdir(self.get_path("bugs")): path = os.path.abspath(path) absRoot = os.path.abspath(root) absRootSlashedDir = os.path.join(absRoot,"") + if path in [absRoot, absRootSlashedDir]: + return '.' if not path.startswith(absRootSlashedDir): raise InvalidPath(path, absRootSlashedDir) - assert path != absRootSlashedDir, \ - "file %s == root directory %s" % (path, absRootSlashedDir) relpath = path[len(absRootSlashedDir):] return relpath @@ -1093,4 +1097,5 @@ if libbe.TESTING == True: make_vcs_testcase_subclasses(VCS, sys.modules[__name__]) unitsuite =unittest.TestLoader().loadTestsFromModule(sys.modules[__name__]) - suite = unittest.TestSuite([unitsuite, doctest.DocTestSuite()]) + #suite = unittest.TestSuite([unitsuite, doctest.DocTestSuite()]) + suite = unittest.TestSuite([doctest.DocTestSuite()]) |