From 22dd202ff4c0a1893f6e9f4d2b6aa1d4da3bf728 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Mon, 6 Dec 2010 08:54:25 -0500 Subject: Adjust `be show --xml` since changes to version_info after Bzr->Git migration. --- libbe/command/show.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'libbe') diff --git a/libbe/command/show.py b/libbe/command/show.py index 27be07c..33c898f 100644 --- a/libbe/command/show.py +++ b/libbe/command/show.py @@ -156,8 +156,7 @@ def _xml_header(encoding): '', ' ', ' %s' % libbe.version.version()] - for tag in ['branch-nick', 'revno', 'revision-id']: - value = libbe.version.version_info[tag.replace('-', '_')] + for tag,value in sorted(libbe.version.version_info.items()): lines.append(' <%s>%s' % (tag, value, tag)) lines.append(' ') return lines -- cgit From ef0a5537747a2e5a0b2248018e981f80ae0b0f9f Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Mon, 6 Dec 2010 10:12:57 -0500 Subject: Run cmd.cleanup_now() after executing bzr commands. Otherwise be remove ... blocks if it needs to remove multiple files, since bzrlib.builtins.cmd_remove needs write locks, and the second remove will try to aquire the lock that the first aquire hadn't released. If we force the release, the lock will be available for the second (and later) removal. It's not a problem to call cleanup_now() too often, because calling it clears the cleanup command stack, so I just added explicit cleanups after every bzr .run() call. --- libbe/storage/vcs/bzr.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'libbe') diff --git a/libbe/storage/vcs/bzr.py b/libbe/storage/vcs/bzr.py index 616a486..583a8f6 100644 --- a/libbe/storage/vcs/bzr.py +++ b/libbe/storage/vcs/bzr.py @@ -136,12 +136,14 @@ class Bzr(base.VCS): cmd = bzrlib.builtins.cmd_root() cmd.outf = StringIO.StringIO() cmd.run(filename=path) + cmd.cleanup_now() return cmd.outf.getvalue().rstrip('\n') def _vcs_init(self, path): cmd = bzrlib.builtins.cmd_init() cmd.outf = StringIO.StringIO() cmd.run(location=path) + cmd.cleanup_now() def _vcs_destroy(self): vcs_dir = os.path.join(self.repo, '.bzr') @@ -153,6 +155,7 @@ class Bzr(base.VCS): cmd = bzrlib.builtins.cmd_add() cmd.outf = StringIO.StringIO() cmd.run(file_list=[path], file_ids_from=self.repo) + cmd.cleanup_now() def _vcs_exists(self, path, revision=None): manifest = self._vcs_listdir( @@ -167,6 +170,7 @@ class Bzr(base.VCS): cmd = bzrlib.builtins.cmd_remove() cmd.outf = StringIO.StringIO() cmd.run(file_list=[path], file_deletion_strategy='force') + cmd.cleanup_now() def _vcs_update(self, path): pass @@ -202,6 +206,7 @@ class Bzr(base.VCS): if self.version_cmp(2,0,0) < 0: cmd.outf = sys.stdout sys.stdout = stdout + cmd.cleanup_now() return cmd.outf.getvalue() def _vcs_path(self, id, revision): @@ -236,6 +241,8 @@ class Bzr(base.VCS): if 'not present in revision' in str(e): raise base.InvalidPath(path, root=self.repo, revision=revision) raise + finally: + cmd.cleanup_now() 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: @@ -257,12 +264,14 @@ class Bzr(base.VCS): raise finally: os.chdir(cwd) + cmd.cleanup_now() return self._vcs_revision_id(-1) def _vcs_revision_id(self, index): cmd = bzrlib.builtins.cmd_revno() cmd.outf = StringIO.StringIO() cmd.run(location=self.repo) + cmd.cleanup_now() current_revision = int(cmd.outf.getvalue()) if index > current_revision or index < -current_revision: return None @@ -281,6 +290,7 @@ class Bzr(base.VCS): status = cmd.run(revision=revision, file_list=[self.repo]) finally: sys.stdout = stdout + cmd.cleanup_now() assert status in [0,1], "Invalid status %d" % status return cmd.outf.getvalue() -- cgit From ab090d8929f7019aa68876fd825766f472fd9138 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Mon, 6 Dec 2010 10:43:49 -0500 Subject: Make libbe.storage.vcs.darcs.Darcs._vcs_listdir() more robust. The old version returned [] (for Darcs 2.5) on darcs show files --no-files --patch 'Initial commit' .be (called in `be diff` for `test_usage.sh darcs`), because darcs returned the paths prefixed with './' (e.g. `./.be`, not `.be`). By calculating relative paths and using the relative paths to determine which files belong to the directory, we can handle both prefixed and plain paths. --- libbe/storage/vcs/darcs.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'libbe') diff --git a/libbe/storage/vcs/darcs.py b/libbe/storage/vcs/darcs.py index 7ff4554..29b25eb 100644 --- a/libbe/storage/vcs/darcs.py +++ b/libbe/storage/vcs/darcs.py @@ -229,8 +229,9 @@ class Darcs(base.VCS): descendents = [self._u_rel_path(f, path) for f in files if f != '.'] else: - descendents = [self._u_rel_path(f, path) for f in files - if f.startswith(path)] + rel_files = [self._u_rel_path(f, path) for f in files] + descendents = [f for f in rel_files + if f != '.' and not f.startswith('..')] return [f for f in descendents if f.count(os.path.sep) == 0] # Darcs versions <= 2.3.1 lack the --patch option for 'show files' raise NotImplementedError -- cgit From 49896ffd2bf821150cfdfcc2a0e8c26c1fb2defe Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Mon, 6 Dec 2010 10:54:07 -0500 Subject: Fix unittest for `be show` after 22dd202ff4c0a1893f6e9f4d2b6aa1d4da3bf728. --- libbe/command/show.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'libbe') diff --git a/libbe/command/show.py b/libbe/command/show.py index 33c898f..b24aa94 100644 --- a/libbe/command/show.py +++ b/libbe/command/show.py @@ -58,9 +58,9 @@ class Show (libbe.command.Command): ... - ... - ... - ... + ... + ... + ... a -- cgit