def getRepoStatus(fn): """Yield file, status tuples for all files in the repo of fn""" repo = getRepo(fn) if not repo: return cmd = 'hg -R "%s" status -A' % repo for st in toolkit.execute(cmd, outonly=True).split("\n"): if not st.strip(): continue yield st[2:], st[0]
def getStatus(fn): """Get the hg status of fn""" repo = getRepo(fn) if not repo or not os.path.exists(fn): return cmd = 'hg -R "%s" status -A "%s"' % (repo, fn) st = toolkit.execute(cmd, outonly=True).strip() if not st: return return st[0]
def getLastEditUser(fn): """Get the username who made the last commit to this file""" repo = getRepo(fn) if not repo or not os.path.exists(fn): return cmd = 'hg -R "%s" log %s/%s | head -3 | tail -1' % (repo, repo, fn) for line in toolkit.execute(cmd, outonly=True).split("\n"): if line.startswith("user:"******"?"
def dot2img(dot, format="jpg", layout="dot"): cmd = 'dot -T%s -K%s' % (format, layout) img = toolkit.execute(cmd, dot, outonly=True) return img
def update(self, revision=None): cmd = 'hg update -R {self.repo}' if revision: cmd += ' -r {revision}' out = toolkit.execute(cmd.format(**locals()), outonly=True)
def listbranches(self): cmd = 'hg branches -R {repo}'.format(**self.__dict__) for line in toolkit.execute(cmd, outonly=True).split('\n'): if not line.strip(): continue yield line.split(' ',1)[0]
def clone(repo, dest): """Clone the repository to destination""" cmd = 'hg clone {repo} {dest}'.format(**locals()) print(cmd) toolkit.execute(cmd, outonly=True) return Repository(dest)