def git_status(path, fname): r = emptystatdct() try: line = readlines(['git', 'status', '--porcelain', '--', fname], cwd=path).next() status = line[:2] if status[0] in 'RC': r['added'].append(fname) elif status[0] == 'D': r['removed'].append(fname) elif status[1] == 'D': r['deleted'].append(fname) elif status[0] == 'A': r['added'].append(fname) elif 'M' in status: r['modified'].append(fname) elif status == '??': r['unknown'].append(fname) except StopIteration: try: readlines([ 'git', 'ls-files', '--ignored', '--exclude-standard', '--others', '--', fname ], cwd=path).next() r['ignored'].append(fname) except StopIteration: try: readlines(['git', 'ls-files', '--', fname], cwd=path).next() r['clean'].append(fname) except StopIteration: pass return r
def git_status(path, fname): r = emptystatdct() try: line = readlines(["git", "status", "--porcelain", "--", fname], cwd=path).next() status = line[:2] if status[0] in "RC": r["added"].append(fname) elif status[0] == "D": r["removed"].append(fname) elif status[1] == "D": r["deleted"].append(fname) elif status[0] == "A": r["added"].append(fname) elif "M" in status: r["modified"].append(fname) elif status == "??": r["unknown"].append(fname) except StopIteration: try: readlines(["git", "ls-files", "--ignored", "--exclude-standard", "--others", "--", fname], cwd=path).next() r["ignored"].append(fname) except StopIteration: try: readlines(["git", "ls-files", "--", fname], cwd=path).next() r["clean"].append(fname) except StopIteration: pass return r
def hg_status(path, args, reverse=False): r = emptystatdct() for line in readlines(['hg', 'status'] + args, cwd=path): r[hgstatchars[line[0]]].append(line[2:]) if reverse: r['deleted'], r['unknown'] = r['unknown'], r['deleted'] r['added'], r['removed'] = r['removed'], r['added'] return r
def hg_status(path, args, reverse=False): r = emptystatdct() for line in readlines(["hg", "status"] + args, cwd=path): r[hgstatchars[line[0]]].append(line[2:]) if reverse: r["deleted"], r["unknown"] = r["unknown"], r["deleted"] r["added"], r["removed"] = r["removed"], r["added"] return r
def svn_status(path, fname): r = emptystatdct() try: line = readlines(['svn', 'status', '--', fname], cwd=path).next() status = line[:7] for schar, colschars in zip(status, svnstatchars): if schar in colschars: r[colschars[schar]].append(fname) break except StopIteration: r['clean'].append(fname) return r
def bzr_status(path, fname): r = emptystatdct() try: line = readlines(['bzr', 'status', '--', fname], cwd=path).next() if line[-1] != ':': raise ValueError('Expected colon at the end of first line') line = line[:-1] if line != 'nonexistent': r[bzrstatstats[line]].append(fname) except StopIteration: r['clean'].append(fname) return r
def svn_status(path, fname): r = emptystatdct() try: line = readlines(["svn", "status", "--", fname], cwd=path).next() status = line[:7] for schar, colschars in zip(status, svnstatchars): if schar in colschars: r[colschars[schar]].append(fname) break except StopIteration: r["clean"].append(fname) return r
def bzr_status(path, fname): r = emptystatdct() try: line = readlines(["bzr", "status", "--", fname], cwd=path).next() if line[-1] != ":": raise ValueError("Expected colon at the end of first line") line = line[:-1] if line != "nonexistent": r[bzrstatstats[line]].append(fname) except StopIteration: r["clean"].append(fname) return r
def git_branch(path): for line in readlines(['git', 'branch', '-l'], cwd=path): if line[0] == '*': return line[2:] return ''
def hg_branch(path): return readlines(['hg', 'branch'], cwd=path).next()
def bzr_branch(path): return "\n".join(readlines(['bzr', 'nick'], cwd=path))
def git_branch(path): for line in readlines(["git", "branch", "-l"], cwd=path): if line[0] == "*": return line[2:] return ""
def hg_branch(path): return readlines(["hg", "branch"], cwd=path).next()
def bzr_branch(path): return "\n".join(readlines(["bzr", "nick"], cwd=path))