summaryrefslogtreecommitdiff
path: root/setupbzr.py
diff options
context:
space:
mode:
authorBarry Warsaw2007-07-20 16:04:28 -0400
committerBarry Warsaw2007-07-20 16:04:28 -0400
commitd3191e2e814369ee81a4bdb5ef4cf90fdc12b7ef (patch)
tree9fad13b63380bd50721c6fe8f41eb36691ca00b9 /setupbzr.py
parent6b9a4a8a6549558127dd7b8bbb1fd4362716732c (diff)
downloadmailman-d3191e2e814369ee81a4bdb5ef4cf90fdc12b7ef.tar.gz
mailman-d3191e2e814369ee81a4bdb5ef4cf90fdc12b7ef.tar.zst
mailman-d3191e2e814369ee81a4bdb5ef4cf90fdc12b7ef.zip
Diffstat (limited to 'setupbzr.py')
-rw-r--r--setupbzr.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/setupbzr.py b/setupbzr.py
new file mode 100644
index 000000000..517464b42
--- /dev/null
+++ b/setupbzr.py
@@ -0,0 +1,32 @@
+# setuptools plugin for bzr
+# Barry Warsaw <barry@python.org>
+
+# Use by adding this to your setuptools.file_finders entry point:
+# 'bzr = bzrplug:find_files_for_bzr'
+
+# http://peak.telecommunity.com/DevCenter/setuptools#adding-support-for-other-revision-control-systems
+
+import os
+import bzrlib.branch
+
+
+def get_children(path):
+ # Open an existing branch which contains the url.
+ branch, inpath = bzrlib.branch.Branch.open_containing(path)
+ # Get the inventory of the branch's last revision.
+ inv = branch.repository.get_revision_inventory(branch.last_revision())
+ # Get the inventory entry for the path.
+ entry = inv[inv.path2id(path)]
+ # Return the names of the children.
+ return [os.path.join(path, child) for child in entry.children.keys()]
+
+
+def find_files_for_bzr(dirname):
+ bzrfiles = []
+ search = [dirname]
+ while search:
+ current = search.pop(0)
+ children = get_children(current)
+ bzrfiles.extend(children)
+ search.extend([child for child in children if os.path.isdir(child)])
+ return bzrfiles