5 excludes = [r'.*?/\.obj.*?',
14 excludes_compiled = map(re.compile, excludes)
16 def filter_excludes(str):
17 for e in excludes_compiled:
22 def split_perforce_parts(s):
23 spaces = ((s.count(" ") + 1) / 3) * 2
26 pos = s.find(" ", pos) + 1
33 class PerforceError(Exception):
34 def __init__(self,value):
37 return repr(self.value)
40 def run(command, regex, filt):
42 m = regex_compiled.match(s)
48 if filt_compiled.match(s):
53 fd = os.popen(command);
54 lines = fd.readlines()
57 raise PerforceError("error calling " + command)
59 regex_compiled = re.compile(regex)
60 filt_compiled = re.compile(filt)
63 lines = filter(filterit, lines)
65 return map(matchit, lines)
69 if len(sys.argv) == 1:
71 elif len(sys.argv) == 2 and sys.argv[1] == "-a":
74 print "usage: checktree [-a]"
75 print " -a don't filter common crud in the tree"
78 have = run("p4 have ...", r'[^#]+#[0-9]+ - (.*)', r'.*')
81 files = run("find . -not -type d", r'.(.*)', r'.*')
82 files = map(lambda s: cwd+s, files)
84 added_depot_path = run("p4 opened ...", r'([^#]+)#.*', r'.*?#[0-9]+ - add .*');
87 added_depot_path = map(quotate, added_depot_path)
89 where = "p4 where " + " ".join(added_depot_path)
90 added = run(where, r'(.*)', r'.*')
91 added = map(split_perforce_parts, added)
95 # Python 2.3 -- still default on Mac OS X -- does not have set()
96 # Make dict's here to support the "in" operations below
97 have = dict().fromkeys(have, 1)
98 added = dict().fromkeys(added, 1)
102 if not file in added:
106 extras = filter(filter_excludes, extras)
109 print s.replace(" ", "\\ ")
111 except PerforceError, e: