def diff(self, uri, branch=None, revs=None, files=None): # TODO pass def blame(self, uri, rev=None, files=None): # TODO pass def get_modules(self): #Not supported by Bzr return [] def get_last_revision(self, uri): self._check_uri(uri) cmd = ['bzr', 'revno'] command = Command(cmd, uri) try: out = command.run_sync() except: return None if out == "": return None return out.strip('\n\t ') register_backend('bzr', BzrRepository)
retval = [] modules = list_files(self.uri) for module in modules: uri = os.path.join(self.uri, module, 'trunk') try: info = get_info(uri, self.user, self.passwd) if info is None or info['node kind'] != 'directory': continue except CommandError: continue retval.append(module.strip('/')) return retval def get_last_revision(self, uri): repo_uri = get_auth_info(uri)['uri'] self._check_uri(repo_uri) try: info = get_info(repo_uri, self.user, self.passwd) if info is not None: return info['last changed rev'] except: pass return None register_backend('svn', SVNRepository)
if out == "": return None return out.strip('\n\t ') 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 register_backend('git', GitRepository)
def get_previous_commit (self, uri, rev, file_name): self._check_uri (uri) cmd = ['git', 'log', '--follow', '--format=%H', rev, '--', file_name] command = Command (cmd, uri, env = {'PAGER' : ''}) try: out = command.run_sync () return out.splitlines()[1].strip ('\n\t ') except: return None def get_last_revision (self, uri): self._check_uri (uri) cmd = ['git', 'rev-list', 'HEAD^..HEAD'] command = Command (cmd, uri, env = {'PAGER' : ''}) try: out = command.run_sync () except: return None if out == "": return None return out.strip ('\n\t ') register_backend ('git', GitRepository)
command = Command(cmd, directory) self._run_command(command, LS) def get_modules(self): #Not supported by CVS return [] def get_last_revision(self, uri): self._check_srcdir(uri) if not os.path.isfile(uri): return None filename = os.path.basename(uri) path = os.path.dirname(uri) cmd = ['cvs', 'status', filename] command = Command(cmd, path) out = command.run_sync() retval = None for line in out.splitlines(): if "Working revision:" in line: retval = line.split(":", 1)[1].strip().split()[0] return retval register_backend('cvs', CVSRepository)
def checkout(self, module, rootdir, newdir=None, branch=None, rev=None): if newdir is not None: srcdir = os.path.join(rootdir, newdir) else: srcdir = rootdir if not os.path.exists(srcdir): os.makedirs(srcdir) if os.path.exists(module): tarball_path = module else: # Download module to rootdir filename = os.path.basename(module).split('?')[0] tarball_path = os.path.join(srcdir, filename) cmd = get_download_command(module, tarball_path, '/dev/stdout') if cmd is None: return command = Command(cmd, srcdir) self._run_command(command, CHECKOUT) if not os.path.exists(tarball_path): return # Unpack the tarball fe = create_file_extractor(tarball_path) fe.extract(srcdir) register_backend('tarball', TarballRepository)
retval = [] modules = list_files(self.uri) for module in modules: uri = os.path.join(self.uri, module, 'trunk') try: info = get_info(uri) if info is None or info['node kind'] != 'directory': continue except CommandError: continue retval.append(module.strip('/')) return retval def get_last_revision(self, uri): self._check_uri(uri) try: info = get_info(uri) if info is not None: return info['last changed rev'] except: pass return None register_backend('svn', SVNRepository)
command = Command(cmd, uri, env={"PAGER": ""}) try: output = command.run_sync() except: return None revisions = output.splitlines() if len(revisions) > 1: return (revisions[1], prev_file_name) else: return None def get_last_revision(self, uri): self._check_uri(uri) cmd = ["git", "rev-list", "HEAD^..HEAD"] command = Command(cmd, uri, env={"PAGER": ""}) try: out = command.run_sync() except: return None if out == "": return None return out.strip("\n\t ") register_backend("git", GitRepository)
command = Command (cmd, directory) self._run_command (command, LS) def get_modules (self): #Not supported by CVS return [] def get_last_revision (self, uri): self._check_srcdir (uri) if not os.path.isfile (uri): return None filename = os.path.basename (uri) path = os.path.dirname (uri) cmd = ['cvs', 'status', filename] command = Command (cmd, path) out = command.run_sync () retval = None for line in out.splitlines (): if "Working revision:" in line: retval = line.split (":", 1)[1].strip ().split ()[0] return retval register_backend ('cvs', CVSRepository)