def cvs_diff(file, rev): """@return: the C{(delta,diff)} on the given L{File} during a commit""" p = re.compile(r"\.(?:pdf|gif|jpg|mpg)$", re.I) if p.search(file.name): return "+0 -0", "===================================================================\n<<Binary file>>\n" if file.action == "removed": return "+0 -0", "===================================================================\n" diff, lines = "", [] if rev == "1.1": lines = execute('cvs -Qnf update -p -r1.1 "%s"' % file.name) diff = "Index: %s\n===================================================================\n" % file.name added, removed = 0, 0 else: lines = execute('cvs -Qnf diff -u -r%s -r %s "%s"' % (cvs_previous_rev(rev), rev, file.name)) added, removed = -1, -1 for line in lines: if rev == "1.1": added = added + 1 elif len(line) > 0: if line[0] == "+": added = added + 1 elif line[0] == "-": removed = removed + 1 diff = diff + line if rev == "1.1": diff = diff + "\n" return "+%s -%s" % (added, removed), diff
def cvs_status(file): """@return: the rev and delta for C{file} during a commit""" rev, delta = "", "" p = re.compile(r"^[ \t]*Repository revision") q = re.compile(r"^date:") for line in execute('cvs -Qnf status "%s"' % file): if p.search(line): rev = line.strip().split("\t")[1] break if rev != "": for line in execute('cvs -Qnf log -r%s "%s"' % (rev, file)): if q.search(line): line = line.strip() line = re.sub(re.compile(r"^.*;"), "", line) line = re.sub(re.compile(r"^[\s]+lines:"), "", line) delta = line.strip() return rev, delta
def _svnlook(self, command, opt_command=''): """@return: the lines ouput by the C{svnlook} command against the current repo and rev""" return execute('svnlook %s %s -r %s %s' % (command, self.repoPath, self.rev, opt_command))