Created
March 31, 2009 22:28
-
-
Save jpedrosa/88449 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from bzrlib import workingtree | |
from bzrlib import branch | |
from bzrlib import delta | |
import os, fnmatch | |
import inspect | |
import re | |
def branch_status(d): | |
wt = workingtree.WorkingTree.open(d) | |
changes = wt.changes_from(wt.basis_tree()) | |
st = [] | |
if (len(changes.added) > 0): | |
st.append("added(%d)" % len(changes.added)) | |
if (len(changes.renamed) > 0): | |
st.append("renamed(%d)" % len(changes.renamed)) | |
if (len(changes.modified) > 0): | |
st.append("modified(%d)" % len(changes.modified)) | |
if (len(changes.removed) > 0): | |
st.append("removed(%d)" % len(changes.removed)) | |
n = 0 | |
for i in wt.unknowns(): | |
n = n + 1 | |
if (n > 0): | |
st.append("unknown(%d)" % n) | |
return " ".join(st) | |
a = [] | |
this_file = inspect.currentframe().f_code.co_filename | |
root_d = os.path.realpath(this_file) | |
root_d = os.path.dirname(os.path.dirname(os.path.dirname(root_d))) + os.sep | |
for path, dirs, files in os.walk(os.path.abspath(root_d)): | |
for d in fnmatch.filter(dirs, '.bzr'): | |
a.append(path) | |
codes = [] | |
for d in a: | |
s = branch_status(d) | |
bran = branch.Branch.open(d) | |
revno = bran.revno() | |
sd = d.replace(root_d, "").replace("\\", "/") | |
codes.append("[\"%s\", %d, \"%s\"]" % (sd, revno, s)) | |
print "{\"codes\": [" | |
print ",\n".join(codes) | |
print "]}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment