Ejemplo n.º 1
0
    def __init__(self, path, rev, repos, pool=None, parent_root=None):
        self.fs_ptr = repos.fs_ptr
        self.scope = repos.scope
        self.pool = Pool(pool)
        pool = self.pool()
        self._scoped_path_utf8 = _to_svn(pool, self.scope, path)

        if parent_root:
            self.root = parent_root
        else:
            self.root = fs.revision_root(self.fs_ptr, rev, pool)
        node_type = fs.check_path(self.root, self._scoped_path_utf8, pool)
        if not node_type in _kindmap:
            raise NoSuchNode(path, rev)
        cp_utf8 = fs.node_created_path(self.root, self._scoped_path_utf8, pool)
        cp = _from_svn(cp_utf8)
        cr = fs.node_created_rev(self.root, self._scoped_path_utf8, pool)
        # Note: `cp` differs from `path` if the last change was a copy,
        #        In that case, `path` doesn't even exist at `cr`.
        #        The only guarantees are:
        #          * this node exists at (path,rev)
        #          * the node existed at (created_path,created_rev)
        # Also, `cp` might well be out of the scope of the repository,
        # in this case, we _don't_ use the ''create'' information.
        if _is_path_within_scope(self.scope, cp):
            self.created_rev = cr
            self.created_path = _path_within_scope(self.scope, cp)
        else:
            self.created_rev, self.created_path = rev, path
        # TODO: check node id
        Node.__init__(self, repos, path, rev, _kindmap[node_type])
Ejemplo n.º 2
0
    def __init__(self, path, rev, authz, scope, fs_ptr):
        self.authz = authz
        self.scope = scope
        if scope != b'/':
            self.scoped_path = scope + path
        else:
            self.scoped_path = path
        self.fs_ptr = fs_ptr
        self._requested_rev = rev

        self.root = fs.revision_root(fs_ptr, rev)
        node_type = fs.check_path(self.root, self.scoped_path)
        if not node_type in _kindmap:
            raise TracError("No node at %s in revision %s" %
                            (path.decode('UTF-8'), rev))
        self.created_rev = fs.node_created_rev(self.root, self.scoped_path)
        self.created_path = fs.node_created_path(self.root, self.scoped_path)
        # Note: 'created_path' differs from 'path' if the last change was a copy,
        #        and furthermore, 'path' might not exist at 'create_rev'.
        #        The only guarantees are:
        #          * this node exists at (path,rev)
        #          * the node existed at (created_path,created_rev)
        # TODO: check node id
        self.rev = self.created_rev

        Node.__init__(self, path, self.rev, _kindmap[node_type])
Ejemplo n.º 3
0
    def __init__(self, git, path, rev, tree_ls_info=None):
        self.git = git
        self.sha = rev
        self.perm = None
        self.data_len = None

        kind = Node.DIRECTORY
        p = path.strip('/')
        if p != "":
            if tree_ls_info == None or tree_ls_info == "":
                tree_ls_info = git.tree_ls(rev, p)
                if tree_ls_info != []:
                    [tree_ls_info] = tree_ls_info
                else:
                    tree_ls_info = None

            if tree_ls_info is None:
                raise NoSuchNode(path, rev)

            (self.perm, k, self.sha, fn) = tree_ls_info

            rev = self.git.last_change(rev, p)

            if k == 'tree':
                pass
            elif k == 'blob':
                kind = Node.FILE
            else:
                self.log.debug("kind is " + k)

        Node.__init__(self, path, rev, kind)

        self.created_path = path
        self.created_rev = rev
Ejemplo n.º 4
0
    def __init__(self, path, rev, authz, scope, fs_ptr):
        self.authz = authz
        self.scope = scope
        if scope != '/':
            self.scoped_path = scope + path
        else:
            self.scoped_path = path
        self.fs_ptr = fs_ptr
        self._requested_rev = rev

        self.root = fs.revision_root(fs_ptr, rev)
        node_type = fs.check_path(self.root, self.scoped_path)
        if not node_type in _kindmap:
            raise TracError, "No node at %s in revision %s" % (path, rev)
        self.created_rev = fs.node_created_rev(self.root, self.scoped_path)
        self.created_path = fs.node_created_path(self.root, self.scoped_path)
        # Note: 'created_path' differs from 'path' if the last change was a copy,
        #        and furthermore, 'path' might not exist at 'create_rev'.
        #        The only guarantees are:
        #          * this node exists at (path,rev)
        #          * the node existed at (created_path,created_rev)
        # TODO: check node id
        self.rev = self.created_rev

        Node.__init__(self, path, self.rev, _kindmap[node_type])
Ejemplo n.º 5
0
Archivo: svn_fs.py Proyecto: t2y/trac
    def __init__(self, path, rev, repos, pool=None, parent_root=None):
        self.fs_ptr = repos.fs_ptr
        self.scope = repos.scope
        self.pool = Pool(pool)
        pool = self.pool()
        self._scoped_path_utf8 = _to_svn(pool, self.scope, path)

        if parent_root:
            self.root = parent_root
        else:
            self.root = fs.revision_root(self.fs_ptr, rev, pool)
        node_type = fs.check_path(self.root, self._scoped_path_utf8, pool)
        if not node_type in _kindmap:
            raise NoSuchNode(path, rev)
        cp_utf8 = fs.node_created_path(self.root, self._scoped_path_utf8, pool)
        cp = _from_svn(cp_utf8)
        cr = fs.node_created_rev(self.root, self._scoped_path_utf8, pool)
        # Note: `cp` differs from `path` if the last change was a copy,
        #        In that case, `path` doesn't even exist at `cr`.
        #        The only guarantees are:
        #          * this node exists at (path,rev)
        #          * the node existed at (created_path,created_rev)
        # Also, `cp` might well be out of the scope of the repository,
        # in this case, we _don't_ use the ''create'' information.
        if _is_path_within_scope(self.scope, cp):
            self.created_rev = cr
            self.created_path = _path_within_scope(self.scope, cp)
        else:
            self.created_rev, self.created_path = rev, path
        # TODO: check node id
        Node.__init__(self, repos, path, rev, _kindmap[node_type])
Ejemplo n.º 6
0
    def __init__(self, git, path, rev, tree_ls_info=None):
        self.git = git
        self.sha = rev
        self.perm = None
        self.data_len = None

        kind = Node.DIRECTORY
        p = path.strip("/")
        if p != "":
            if tree_ls_info == None or tree_ls_info == "":
                tree_ls_info = git.tree_ls(rev, p)
                if tree_ls_info != []:
                    [tree_ls_info] = tree_ls_info
                else:
                    tree_ls_info = None

            if tree_ls_info is None:
                raise NoSuchNode(path, rev)

            (self.perm, k, self.sha, fn) = tree_ls_info

            rev = self.git.last_change(rev, p)

            if k == "tree":
                pass
            elif k == "blob":
                kind = Node.FILE
            else:
                self.log.debug("kind is " + k)

        Node.__init__(self, path, rev, kind)

        self.created_path = path
        self.created_rev = rev
Ejemplo n.º 7
0
    def __init__(self, path, rev, p4c, log, kind):
        self.p4c = p4c
        self.log = log

        Node.__init__(self, path, rev, kind)

        if self.isfile:
            self.content = None
            self.info = self.p4c.run("files", path)[0]
Ejemplo n.º 8
0
    def __init__(self, path, rev, p4c, log, kind):
        self.p4c = p4c
        self.log = log

        Node.__init__(self, path, rev, kind)

        if self.isfile:
            self.content = None
            self.info = self.p4c.run("files", path)[0]
Ejemplo n.º 9
0
 def __init__(self, nodePath, repos, log):
     log.debug('Created PerforceNode for %s' % nodePath.path)
     self._log = log
     self._repos = repos
     self._nodePath = nodePath
     self._node = self._repos.getNode(nodePath)
     node_type = self._get_kind()
     self.created_rev = self._node.change
     self.created_path = normalisePath(self._nodePath.path)
     self.rev = self.created_rev
     Node.__init__(self, self.created_path, self.rev, node_type)
Ejemplo n.º 10
0
 def __init__(self, nodePath, repos, log):
     log.debug('Created PerforceNode for %s' % nodePath.path)
     self._log = log
     self._repos = repos
     self._nodePath = nodePath
     self._node = self._repos.getNode(nodePath)
     node_type = self._get_kind()
     self.created_rev = self._node.change
     self.created_path = normalisePath(self._nodePath.path)
     self.rev = self.created_rev
     Node.__init__(self, self.created_path, self.rev, node_type)
Ejemplo n.º 11
0
    def __init__(self, path, rev, p4c, log, kind):
        self.p4c = p4c
        self.log = log

        Node.__init__(self, path, rev, kind)

        if self.isfile:
            _my_path = _add_rev_to_path(_normalize_path(path), rev)
            self.stat = self.p4c.run("fstat", _my_path)
            if self.stat[0]["headAction"] == "delete":
                raise TracError, "No node at %s in revision %s" % (path, rev)
            self.content = None
            self.info = self.p4c.run("files", path)[0]
Ejemplo n.º 12
0
    def __init__(self, path, rev, p4c, log, kind):
        self.p4c = p4c
        self.log = log

        Node.__init__(self, path, rev, kind)

        if self.isfile:
            _my_path = _add_rev_to_path(_normalize_path(path), rev)
            self.stat = self.p4c.run("fstat", _my_path)
            if self.stat[0]['headAction'] == 'delete':
                raise TracError, "No node at %s in revision %s" % (path, rev)
            self.content = None
            self.info = self.p4c.run("files", path)[0]
Ejemplo n.º 13
0
    def __init__(self, path, rev, p4c, log, kind):
        self.p4c = p4c
        self.log = log
        self.created_rev = rev
        self.created_path = path

        Node.__init__(self, path, rev, kind)

        if self.isfile:
            _my_path = _add_rev_to_path(_normalize_path(path), rev)
            _deb = time.time()
            self.stat = self.p4c.run("fstat", _my_path)
            self.log.debug("*** PerforceNode __init__ (%f)  %s" % (time.time() - _deb, _my_path))
            if self.stat[0]['headAction'] == 'delete':
                raise TracError, "No node at %s in revision %s" % (path, rev)
            self.content = None
            self.info = self.p4c.run("files", path)[0]
Ejemplo n.º 14
0
    def __init__(self, path, rev, p4c, log, kind):
        self.p4c = p4c
        self.log = log
        self.created_rev = rev
        self.created_path = path

        Node.__init__(self, path, rev, kind)

        if self.isfile:
            _my_path = _add_rev_to_path(_normalize_path(path), rev)
            _deb = time.time()
            self.stat = self.p4c.run("fstat", _my_path)
            self.log.debug("*** PerforceNode __init__ (%f)  %s" %
                           (time.time() - _deb, _my_path))
            if self.stat[0]['headAction'] == 'delete':
                raise TracError, "No node at %s in revision %s" % (path, rev)
            self.content = None
            self.info = self.p4c.run("files", path)[0]
Ejemplo n.º 15
0
 def _init_path(self, log, path):
     kind = None
     if path in self.manifest:  # then it's a file
         kind = Node.FILE
         file_n = self.manifest[path]
         log_rev = self.repos.repo.file(path).linkrev(file_n)
         node = log.node(log_rev)
     else:  # it will be a directory if there are matching entries
         dir = path and path + '/' or ''
         entries = {}
         newest = -1
         for file in self.manifest.keys():
             if file.startswith(dir):
                 entry = file[len(dir):].split('/', 1)[0]
                 entries[entry] = 1
                 if path:  # small optimization: we skip this for root node
                     file_n = self.manifest[file]
                     log_rev = self.repos.repo.file(file).linkrev(file_n)
                     newest = max(log_rev, newest)
         if entries:
             kind = Node.DIRECTORY
             self.entries = entries.keys()
             if newest >= 0:
                 node = log.node(newest)
             else:  # ... as it's the youngest anyway
                 node = log.tip()
     if not kind:
         if log.tip() == nullid:  # empty repository
             kind = Node.DIRECTORY
             self.entries = []
             node = nullid
         else:
             raise NoSuchNode(path, self.repos.hg_display(self.n))
     self.time = self.repos.hg_time(log.read(node)[2])
     rev = self.repos.hg_display(node)
     Node.__init__(self, path, rev, kind)
     self.created_path = path
     self.created_rev = rev
     self.data = None
Ejemplo n.º 16
0
    def __init__(self, path, rev, authz, scope, fs_ptr, pool=None):
        self.authz = authz
        self.scope = scope
        if scope != '/':
            self.scoped_path = scope + path
        else:
            self.scoped_path = path
        self.fs_ptr = fs_ptr
        self.pool = Pool(pool)
        self._requested_rev = rev

        self.root = fs.revision_root(fs_ptr, rev, self.pool())
        node_type = fs.check_path(self.root, self.scoped_path, self.pool())
        if not node_type in _kindmap:
            raise TracError, "No node at %s in revision %s" % (path, rev)
        self.created_rev = fs.node_created_rev(self.root, self.scoped_path,
                                               self.pool())
        self.created_path = fs.node_created_path(self.root, self.scoped_path,
                                                 self.pool())
        # 'created_path' differs from 'path' if the last operation is a copy,
        # and furthermore, 'path' might not exist at 'create_rev'
        self.rev = self.created_rev

        Node.__init__(self, path, self.rev, _kindmap[node_type])