Пример #1
0
def get_repository_from_path(path):
    if os.path.isfile(path):
        path = os.path.dirname(path)

    pattern = re.compile("^[ \t]*(checkout of)?(parent)? branch:(.*)$")
    uri = None

    try:
        cmd = ['bzr', 'info']

        command = Command(cmd, path, env={'LC_ALL': 'C'})
        out = command.run_sync()

        for line in out.splitlines():
            match = pattern.match(line)
            if not match:
                continue

            uri = match.group(3).strip()
            break
    except CommandError:
        raise RepositoryInvalidWorkingCopy(
            '"%s" does not appear to be a Bzr working copy' % path)

    if uri is None:
        raise RepositoryInvalidWorkingCopy(
            '"%s" does not appear to be a Bzr working copy' % path)

    return 'bzr', uri
Пример #2
0
def get_repository_from_path(path):
    # Just in case path is a file
    if os.path.isfile(path):
        path = os.path.dirname(path)

    try:
        info = get_info(path)
    except CommandError:
        raise RepositoryInvalidWorkingCopy(
            '"%s" does not appear to be a SVN working copy' % path)

    if info is None:
        raise RepositoryInvalidWorkingCopy(
            '"%s" does not appear to be a SVN working copy' % path)

    return 'svn', info['repository root']
Пример #3
0
 def _check_uri(self, uri):
     type, repo_uri = get_repository_from_path(uri)
     if not repo_uri.startswith(self.uri):
         raise RepositoryInvalidWorkingCopy('"%s" does not appear to be a '
                                            'Git working copy (expected %s'
                                            ' but got %s)' %
                                            (uri, self.uri, repo_uri))
Пример #4
0
    def _check_uri(self, uri):
        def is_local(uri):
            import re
            return re.compile("^.*://.*$").match(uri) is None

        if is_local(uri):
            type, repo_uri = get_repository_from_path(uri)
            if repo_uri != self.uri:
                raise RepositoryInvalidWorkingCopy(
                    '"%s" does not appear to be a SVN working copy '
                    '(expected %s but got %s)' % (uri, self.uri, repo_uri))
        else:
            if not uri.startswith(self.uri):
                raise RepositoryInvalidWorkingCopy(
                    '"%s" does not appear to be a SVN working copy '
                    'for repository %s' % (uri, self.uri))
Пример #5
0
def get_repository_from_path(path):
    if os.path.isfile(path):
        path = os.path.dirname(path)

    dir = path
    while dir and not os.path.isdir(os.path.join(dir, ".git")) and dir != "/":
        dir = os.path.dirname(dir)

    if not dir or dir == "/":
        raise RepositoryInvalidWorkingCopy('"%s" does not appear to be a Git '
                                           'working copy' % path)
    try:
        uri = get_config(dir, 'remote.origin.url')
    except CommandError:
        uri = dir

    if uri is None or not uri:
        raise RepositoryInvalidWorkingCopy('"%s" does not appear to be a Git '
                                           'working copy' % path)

    return 'git', uri
Пример #6
0
    def _check_srcdir(self, srcuri):
        # srcuri can be a module, directory or file
        if os.path.isfile(srcuri):
            srcdir = os.path.dirname(srcuri)
        else:
            srcdir = srcuri

        type, uri = get_repository_from_path(srcdir)

        if uri != self.uri:
            raise RepositoryInvalidWorkingCopy(
                '"%s" does not appear to be a CVS working copy '
                '(expected %s but got %s)' % (srcdir, self.uri, uri))
Пример #7
0
def get_repository_from_path(path):
    # Just in case path is a file
    if not os.path.isdir(path):
        path = os.path.dirname(path)

    cvsroot = os.path.join(path, 'CVS', 'Root')

    try:
        uri = open(cvsroot, 'r').read().strip()
    except IOError:
        raise RepositoryInvalidWorkingCopy('"%s" does not appear to be a CVS'
                                           ' working copy' % path)

    return 'cvs', uri
Пример #8
0
    def __get_repository_for_path(self, path):
        if not os.path.isdir(path):
            basename = os.path.basename(path)
            path = os.path.dirname(path)
        else:
            basename = None

        repository = os.path.join(path, 'CVS', 'Repository')

        try:
            rpath = open(repository, 'r').read().strip()
        except IOError:
            raise RepositoryInvalidWorkingCopy('"%s" does not appear to be a '
                                               'CVS working copy' % path)

        if basename is not None:
            return os.path.join(rpath, basename)
        else:
            return rpath