From 7e120421446f88f9bde0674f57fb1667c5f70ebd Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Thu, 28 Jan 2010 13:06:06 -0500 Subject: Work around "bzr ls --non-recursive PATH : no list" bug in old bzrlib. See: https://bugs.launchpad.net/bzr/+bug/158690 Bug affected versions: 0.90.0 (reported) 1.3.1 (my test suite hit it) Doesn't affect versions: 2.0+ (non_recursive -> recursive) But I haven't isolated the source more specifically. Working around it for everything < 2.0 should be safe, but the cutoff could be fine-tuned if someone wants to dig through the bzr.dev history... --- libbe/storage/vcs/bzr.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'libbe/storage/vcs') diff --git a/libbe/storage/vcs/bzr.py b/libbe/storage/vcs/bzr.py index 03a64f8..ce140bc 100644 --- a/libbe/storage/vcs/bzr.py +++ b/libbe/storage/vcs/bzr.py @@ -172,7 +172,7 @@ class Bzr(base.VCS): revision = self._parse_revision_string(revision) cmd = bzrlib.builtins.cmd_cat() cmd.outf = StringIO.StringIO() - if self.version_cmp(1,6,0) == -1: + if self.version_cmp(1,6,0) < 0: # old bzrlib cmd_cat uses sys.stdout not self.outf for output. stdout = sys.stdout sys.stdout = cmd.outf @@ -183,7 +183,7 @@ class Bzr(base.VCS): raise base.InvalidPath(path, root=self.repo, revision=revision) raise finally: - if self.version_cmp(2,0,0) == -1: + if self.version_cmp(2,0,0) < 0: cmd.outf = sys.stdout sys.stdout = stdout return cmd.outf.getvalue() @@ -210,15 +210,20 @@ class Bzr(base.VCS): try: if self.version_cmp(2,0,0) >= 0: cmd.run(revision=revision, path=path, recursive=recursive) - else: # Pre-2.0 Bazaar + else: + # Pre-2.0 Bazaar (non_recursive) + # + working around broken non_recursive+path implementation + # (https://bugs.launchpad.net/bzr/+bug/158690) cmd.run(revision=revision, path=path, - non_recursive=not recursive) + non_recursive=False) except bzrlib.errors.BzrCommandError, e: if 'not present in revision' in str(e): raise base.InvalidPath(path, root=self.repo, revision=revision) raise children = cmd.outf.getvalue().rstrip('\n').splitlines() children = [self._u_rel_path(c, path) for c in children] + if self.version_cmp(2,0,0) < 0 and recursive == False: + children = [c for c in children if os.path.sep not in c] return children def _vcs_commit(self, commitfile, allow_empty=False): -- cgit