Esempio n. 1
0
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
Esempio n. 2
0
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
Esempio n. 3
0
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
Esempio n. 4
0
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
Esempio n. 5
0
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
Esempio n. 6
0
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
Esempio n. 7
0
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
Esempio n. 8
0
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
Esempio n. 9
0
def git_branch(path):
    for line in readlines(['git', 'branch', '-l'], cwd=path):
        if line[0] == '*':
            return line[2:]
    return ''
Esempio n. 10
0
def hg_branch(path):
    return readlines(['hg', 'branch'], cwd=path).next()
Esempio n. 11
0
def bzr_branch(path):
    return "\n".join(readlines(['bzr', 'nick'], cwd=path))
Esempio n. 12
0
def git_branch(path):
    for line in readlines(["git", "branch", "-l"], cwd=path):
        if line[0] == "*":
            return line[2:]
    return ""
Esempio n. 13
0
def hg_branch(path):
    return readlines(["hg", "branch"], cwd=path).next()
Esempio n. 14
0
def bzr_branch(path):
    return "\n".join(readlines(["bzr", "nick"], cwd=path))