From 16877141d526a5387a0f673b56c1cd6f3b900674 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Tue, 29 Dec 2009 21:37:14 -0500 Subject: [PATCH] Correct for possible directory changes in mercurial.dispatch.dispatch() I ran across this when the hg unittests broke the vcs.base unittests: $ python test.py libbe.storage.vcs.base libbe.storage.vcs.hg ... OK $ python test.py libbe.storage.vcs.hg libbe.storage.vcs.base ... File ".../libbe/storage/vcs/base.py", line 914, in libbe.storage.vcs.base.VCSTestCase.Class._u_rel_path Failed example: vcs._u_rel_path("./a", ".") Exception raised: Traceback (most recent call last): File "/usr/lib/python2.5/doctest.py", line 1228, in __run compileflags, 1) in test.globs File "", line 1, in vcs._u_rel_path("./a", ".") File ".../libbe/storage/vcs/base.py", line 921, in _u_rel_path path = os.path.abspath(path) File "/usr/lib/python2.5/posixpath.py", line 403, in abspath path = join(os.getcwd(), path) OSError: [Errno 2] No such file or directory ... FAILED (failures=1) --- libbe/storage/vcs/hg.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libbe/storage/vcs/hg.py b/libbe/storage/vcs/hg.py index b280ff2..11494a9 100644 --- a/libbe/storage/vcs/hg.py +++ b/libbe/storage/vcs/hg.py @@ -70,7 +70,9 @@ class Hg(base.VCS): stdout = sys.stdout tmp_stdout = StringIO.StringIO() sys.stdout = tmp_stdout + cwd = os.getcwd() mercurial.dispatch.dispatch(fullargs) + os.chdir(cwd) sys.stdout = stdout return tmp_stdout.getvalue().rstrip('\n') -- 2.26.2