Example #1
0
    def __init__(self, path):
        if not os.path.exists(path) or not os.path.isdir(path):
            raise RepositoryPathInvalid(
                "Path doesn't exists or isn't a directory (%s)\n" % path)

        try:
            scm = (set(self.scm_dirs) & set(os.listdir(path))).pop()
        except KeyError:
            raise RepositoryAdapterNotFound("Can't define repository type")
        else:
            self.path = path
            if scm == ".git":
                self.adapter = Git(path)
            if scm == ".svn":
                self.adapter = Svn(path)
            if scm == ".bzr":
                self.adapter = Bzr(path)
            if scm == ".hg":
                self.adapter = Hg(path)
Example #2
0
class Repository:
    path = None
    adapter = None

    scm_dirs = [".git", ".svn", ".bzr", ".hg"]

    def __init__(self, path):
        if not os.path.exists(path) or not os.path.isdir(path):
            raise RepositoryPathInvalid(
                "Path doesn't exists or isn't a directory (%s)\n" % path)

        try:
            scm = (set(self.scm_dirs) & set(os.listdir(path))).pop()
        except KeyError:
            raise RepositoryAdapterNotFound("Can't define repository type")
        else:
            self.path = path
            if scm == ".git":
                self.adapter = Git(path)
            if scm == ".svn":
                self.adapter = Svn(path)
            if scm == ".bzr":
                self.adapter = Bzr(path)
            if scm == ".hg":
                self.adapter = Hg(path)

    def get_scm(self):
        """Get scm used as string."""
        if self.adapter is None:
            return None
        return self.adapter.__class__.__name__

    def status(self):
        return self.adapter.status()

    def update(self):
        return self.adapter.update()