def _checkout_branch (self, path, branch): self._check_uri (path) current, branches = self._get_branches (path) if branch in branches: if branches.index (branch) == current: return cmd = ['git', 'checkout', branch] else: cmd = ['git', 'checkout', '-b', branch, 'origin/%s' % (branch)] command = Command (cmd, path) command.run ()
def _checkout_branch(self, path, branch): self._check_uri(path) current, branches = self._get_branches(path) if branch in branches: if branches.index(branch) == current: return cmd = ['git', 'checkout', branch] else: cmd = ['git', 'checkout', '-b', branch, 'origin/%s' % (branch)] command = Command(cmd, path) command.run()
def _checkout_branch(self, path, branch): self._check_uri(path) current, branches = self._get_branches(path) if branch in branches: if branches.index(branch) == current: return cmd = ["git", "checkout", branch] else: cmd = ["git", "checkout", "-b", branch, "origin/%s" % (branch)] command = Command(cmd, path) command.run()
def is_ancestor(self, uri, rev1, rev2): self._check_uri(uri) version = self._get_git_version() if version[0] >= 1 and version[1] >= 8: # 'git merge-base --is-ancestor' is only supported after 1.8 cmd = ['git', 'merge-base', '--is-ancestor', rev1, rev2] command = Command(cmd, uri, env={'PAGER': ''}) try: command.run() return True except CommandError as e: if e.returncode == 1: return False else: raise e else: # Should we implement an workaround for git under 1.8 or # just have git 1.8 or later in prerequisites? # An workaround can be found at # http://stackoverflow.com/a/3006203/1305362 raise NotImplementedError
def is_ancestor(self, uri, rev1, rev2): self._check_uri(uri) version = self._get_git_version() if version[0] == 0 or (version[0] == 1 and version[1] < 8): # Should we implement an workaround for git under 1.8 or # just have git 1.8 or later in prerequisites? # An workaround can be found at # http://stackoverflow.com/a/3006203/1305362 raise NotImplementedError # 'git merge-base --is-ancestor' is only supported after 1.8 cmd = ['git', 'merge-base', '--is-ancestor', rev1, rev2] command = Command(cmd, uri, env={'PAGER': ''}) try: command.run() return True except CommandError as e: if e.returncode == 1: return False else: raise e