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 __init__(self, repo, ignored, files, renamed): self.status = emptystatdct() self.renames = {} self.repo = repo self.ignored = ignored self.files = files self.renamed = renamed
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 get_status(repo, files=None, clean=None, ignored=None): r = emptystatdct() if files: statuses = ((fname, repo.status_file(fname)) for fname in files) else: status = repo.status() statuses = status.iteritems() if clean: r['clean'] = [ fname for fname in list_tree_files(g_cs(repo, 'HEAD').tree) if fname not in status ] while True: try: fname, status = statuses.next() except StopIteration: break except KeyError: # File is not known continue except ValueError: # File is a directory continue if status == git.GIT_STATUS_CURRENT: r['clean'].append(fname) elif status & git.GIT_STATUS_INDEX_DELETED: r['removed'].append(fname) elif status & git.GIT_STATUS_WT_DELETED: r['deleted'].append(fname) elif status & git.GIT_STATUS_INDEX_NEW: r['added'].append(fname) elif status & git.GIT_STATUS_WT_NEW: r['unknown'].append(fname) elif status & (git.GIT_STATUS_INDEX_MODIFIED | git.GIT_STATUS_WT_MODIFIED): r['modified'].append(fname) elif status & git.GIT_STATUS_IGNORED: r['ignored'].append(fname) for v in r.itervalues(): v.sort() return r
def get_status(repo, files=None, clean=None, ignored=None): r = emptystatdct() if files: statuses = ((fname, repo.status_file(fname)) for fname in files) else: status = repo.status() statuses = status.iteritems() if clean: r['clean'] = [fname for fname in list_tree_files(repo, g_cs(repo, 'HEAD').tree) if fname not in status] while True: try: fname, status = statuses.next() except StopIteration: break except KeyError: # File is not known continue except ValueError: # File is a directory continue if status == git.GIT_STATUS_CURRENT: r['clean'].append(fname) elif status & git.GIT_STATUS_INDEX_DELETED: r['removed'].append(fname) elif status & git.GIT_STATUS_WT_DELETED: r['deleted'].append(fname) elif status & git.GIT_STATUS_INDEX_NEW: r['added'].append(fname) elif status & git.GIT_STATUS_WT_NEW: r['unknown'].append(fname) elif status & (git.GIT_STATUS_INDEX_MODIFIED | git.GIT_STATUS_WT_MODIFIED): r['modified'].append(fname) elif status & git.GIT_STATUS_IGNORED: r['ignored'].append(fname) for v in r.itervalues(): v.sort() return r