def merge_base(self, rev1, rev2): # Note: find-merge-base just returns rev1 if rev2 is not found # we assume that rev2 is a legitamate revision. # the following raise a CalledProcessError if it's a bad revision shell_out(["bzr", "log", "-c", rev1], cwd=self.root) output = shell_out_ignore_exitcode(["bzr", "find-merge-base", rev1, rev2], cwd=self.root) # 'merge base is revision [email protected]' return output.rsplit(" ", 1)[1]
def merge_base(self, rev1, rev2): # Note: find-merge-base just returns rev1 if rev2 is not found # we assume that rev2 is a legitamate revision. # the following raise a CalledProcessError if it's a bad revision shell_out(['bzr', 'log', '-c', rev1], cwd=self.root) output = shell_out_ignore_exitcode( ['bzr', 'find-merge-base', rev1, rev2], cwd=self.root) # 'merge base is revision [email protected]' return output.rsplit(' ', 1)[1]
def using_bzr(cwd): """Test whether the directory cwd is contained in a bazaar repository.""" try: bzr_log = shell_out(["bzr", "log"], cwd=cwd) return True except (CalledProcessError, OSError): return False
def using_git(cwd): """Test whether the directory cwd is contained in a git repository.""" try: git_log = shell_out(["git", "log"], cwd=cwd) return True except (CalledProcessError, OSError): # pragma: no cover return False
def using_hg(cwd): """Test whether the directory cwd is contained in a mercurial repository.""" try: hg_log = shell_out(["hg", "log"], cwd=cwd) return True except (CalledProcessError, OSError): return False
def _shell_out(self, *args, **kwargs): return shell_out(*args, cwd=self.root, **kwargs)
def root_dir(cwd=None): return shell_out(['bzr', 'root'], cwd=cwd)
def root_dir(cwd=None): root = shell_out(['git', 'rev-parse', '--show-toplevel'], cwd=cwd) return os.path.normpath(root)
def root_dir(cwd=None): return shell_out(["bzr", "root"], cwd=cwd)
def root_dir(cwd=None): root = shell_out(["git", "rev-parse", "--show-toplevel"], cwd=cwd) return os.path.normpath(root)