From: Aaron Bentley Date: Wed, 4 May 2005 11:43:14 +0000 (+0000) Subject: Added pseudo-revlib functionality for bzr X-Git-Tag: 1.0.0~298^2 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=f92ced7d577142b16ef86ed6aff6bb6b5f526e2d;p=be.git Added pseudo-revlib functionality for bzr --- diff --git a/libbe/bzr.py b/libbe/bzr.py index 350e86b..b2e0d6b 100644 --- a/libbe/bzr.py +++ b/libbe/bzr.py @@ -35,11 +35,29 @@ def set_file_contents(path, contents): if add: add_id(path) +def lookup_revision(revno): + return invoke_client("lookup-revision", str(revno)).rstrip('\n') + +def export(revno, revision_dir): + invoke_client("export", str(revno), revision_dir) + +def find_or_make_export(revno): + revision_id = lookup_revision(revno) + home = os.path.expanduser("~") + revision_dir = os.path.join(home, ".bzrrevs", revision_id) + if not os.path.exists(revision_dir): + export(revno, revision_dir) + return revision_dir + +def bzr_root(path): + return invoke_client("root", path).rstrip('\r') def path_in_reference(bug_dir, spec): - if spec is not None: - return invoke_client("file-find", bug_dir, spec).rstrip('\n') - return invoke_client("file-find", bug_dir).rstrip('\n') + if spec is None: + spec = int(invoke_client("revno")) + rel_bug_dir = bug_dir[len(bzr_root(bug_dir)):] + export_root = find_or_make_export(spec) + return os.path.join(export_root, rel_bug_dir) def unlink(path):