aboutsummaryrefslogtreecommitdiffstats
path: root/libbe/bzr.py
diff options
context:
space:
mode:
authorAaron Bentley <aaron.bentley@utoronto.ca>2005-05-04 11:43:14 +0000
committerAaron Bentley <aaron.bentley@utoronto.ca>2005-05-04 11:43:14 +0000
commitf92ced7d577142b16ef86ed6aff6bb6b5f526e2d (patch)
tree66d1b36efdad25c508a53e8244b88df1e443dab7 /libbe/bzr.py
parent27e854cd1cb243b08ac435d259a057138db320f6 (diff)
downloadbugseverywhere-f92ced7d577142b16ef86ed6aff6bb6b5f526e2d.tar.gz
Added pseudo-revlib functionality for bzr
Diffstat (limited to 'libbe/bzr.py')
-rw-r--r--libbe/bzr.py24
1 files changed, 21 insertions, 3 deletions
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):