Exemplo n.º 1
0
        def __init__(self, git, path, rev, log, ls_tree_info=None):
                self.log = log
                self.git = git
                self.fs_sha = None # points to either tree or blobs
                self.fs_perm = None
                self.fs_size = None
                rev = rev and str(rev) or 'HEAD'

                kind = Node.DIRECTORY
                p = path.strip('/')
                if p: # ie. not the root-tree
                        if not ls_tree_info:
                                ls_tree_info = git.ls_tree(rev, p) or None
                                if ls_tree_info:
                                        [ls_tree_info] = ls_tree_info

                        if not ls_tree_info:
                                raise NoSuchNode(path, rev)

                        (self.fs_perm, k, self.fs_sha, self.fs_size, fn) = ls_tree_info

                        # fix-up to the last commit-rev that touched this node
                        rev = self.git.last_change(rev, p)

                        if k=='tree':
                                pass
                        elif k=='blob':
                                kind = Node.FILE
                        else:
                                raise TracError("internal error (got unexpected object kind '%s')" % k)

                self.created_path = path
                self.created_rev = rev

                Node.__init__(self, path, rev, kind)
Exemplo n.º 2
0
    def __init__(self,
                 repos,
                 path,
                 rev,
                 log,
                 ls_tree_info=None,
                 historian=None):
        self.log = log
        self.repos = repos
        self.fs_sha = None  # points to either tree or blobs
        self.fs_perm = None
        self.fs_type = None
        self.fs_size = None
        if rev:
            rev = repos.normalize_rev(to_unicode(rev))
        else:
            rev = repos.youngest_rev
        created_rev = rev

        kind = Node.DIRECTORY
        p = path.strip('/')
        if p:  # ie. not the root-tree
            if not rev:
                raise NoSuchNode(path, rev)
            if ls_tree_info is None:
                ls_tree_info = repos.git.ls_tree(rev, p)
                if ls_tree_info:
                    ls_tree_info = ls_tree_info[0]
            if not ls_tree_info:
                raise NoSuchNode(path, rev)
            self.fs_perm, self.fs_type, self.fs_sha, self.fs_size, fname = \
                ls_tree_info

            # fix-up to the last commit-rev that touched this node
            created_rev = repos.git.last_change(rev, p, historian)

            if self.fs_type == 'tree':
                kind = Node.DIRECTORY
            elif self.fs_type == 'blob':
                kind = Node.FILE
            elif _is_submodule(self.fs_perm):
                # FIXME: this is a workaround for missing git submodule
                #        support in the plugin
                kind = Node.DIRECTORY
            else:
                self.log.warning('Got unexpected object %r', ls_tree_info)
                raise TracError(
                    _(
                        "Internal error (got unexpected object "
                        "kind '%(kind)s')",
                        kind=self.fs_type))

        self.created_path = path
        self.created_rev = created_rev

        Node.__init__(self, repos, path, rev, kind)
Exemplo n.º 3
0
Arquivo: git_fs.py Projeto: t2y/trac
    def __init__(self,
                 repos,
                 path,
                 rev,
                 log,
                 ls_tree_info=None,
                 historian=None):
        self.log = log
        self.repos = repos
        self.fs_sha = None  # points to either tree or blobs
        self.fs_perm = None
        self.fs_size = None
        if rev:
            rev = repos.normalize_rev(to_unicode(rev))
        else:
            rev = repos.youngest_rev

        kind = Node.DIRECTORY
        p = path.strip('/')
        if p:  # ie. not the root-tree
            if not rev:
                raise NoSuchNode(path, rev)
            if not ls_tree_info:
                ls_tree_info = repos.git.ls_tree(rev, p) or None
                if ls_tree_info:
                    [ls_tree_info] = ls_tree_info

            if not ls_tree_info:
                raise NoSuchNode(path, rev)

            self.fs_perm, k, self.fs_sha, self.fs_size, _ = ls_tree_info

            # fix-up to the last commit-rev that touched this node
            rev = repos.git.last_change(rev, p, historian)

            if k == 'tree':
                pass
            elif k == 'commit':
                # FIXME: this is a workaround for missing git submodule
                #        support in the plugin
                pass
            elif k == 'blob':
                kind = Node.FILE
            else:
                raise TracError("Internal error (got unexpected object " \
                                "kind '%s')" % k)

        self.created_path = path
        self.created_rev = rev

        Node.__init__(self, repos, path, rev, kind)
Exemplo n.º 4
0
    def __init__(self, repos, path, rev, log, ls_tree_info=None,
                 historian=None):
        self.log = log
        self.repos = repos
        self.fs_sha = None # points to either tree or blobs
        self.fs_perm = None
        self.fs_size = None
        if rev:
            rev = repos.normalize_rev(to_unicode(rev))
        else:
            rev = repos.youngest_rev

        kind = Node.DIRECTORY
        p = path.strip('/')
        if p:  # ie. not the root-tree
            if not rev:
                raise NoSuchNode(path, rev)
            if not ls_tree_info:
                ls_tree_info = repos.git.ls_tree(rev, p) or None
                if ls_tree_info:
                    [ls_tree_info] = ls_tree_info

            if not ls_tree_info:
                raise NoSuchNode(path, rev)

            self.fs_perm, k, self.fs_sha, self.fs_size, _ = ls_tree_info

            # fix-up to the last commit-rev that touched this node
            rev = repos.git.last_change(rev, p, historian)

            if k == 'tree':
                pass
            elif k == 'commit':
                # FIXME: this is a workaround for missing git submodule
                #        support in the plugin
                pass
            elif k == 'blob':
                kind = Node.FILE
            else:
                raise TracError(_("Internal error (got unexpected object "
                                  "kind '%(kind)s')", kind=k))

        self.created_path = path
        self.created_rev = rev

        Node.__init__(self, repos, path, rev, kind)
Exemplo n.º 5
0
 def _init_path(self, log, path):
     kind = None
     if path in self.manifest: # then it's a file
         kind = Node.FILE
         self.filectx = self.repos.repo.filectx(path, self.n)
         log_rev = self.filectx.linkrev()
         node = log.node(log_rev)
     else: # it will be a directory if there are matching entries
         dir = path and path+'/' or ''
         entries = {}
         for file in self.manifest.keys():
             if file.startswith(dir):
                 entry = file[len(dir):].split('/', 1)[0]
                 entries[entry] = 1
         if entries:
             kind = Node.DIRECTORY
             self.entries = entries.keys()
             if path: # small optimization: we skip this for root node
                 if self._dirnode:
                     # big optimization, the node was precomputed in parent
                     node = self._dirnode
                 else:
                     # we find the most recent change for a file below dir
                     dirnodes = self.findnode(log.rev(self.n), [dir,])
                     node = dirnodes.values()[0]
             else:
                 node = log.tip()
     if not kind:
         if log.tip() == nullid or not (self.manifest or path):
             # empty or emptied repository
             kind = Node.DIRECTORY
             self.entries = []
             node = log.tip()
         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, self.repos, path, rev, kind)
     self.created_path = path
     self.created_rev = rev
     self.node = node
     self.data = None
Exemplo n.º 6
0
 def __init__(self, path, rev, kind, repos):
     Node.__init__(self, path, rev, kind)
     self.repos = repos
Exemplo n.º 7
0
 def __init__(this, content, mode, *args, **kwds):
     this.__content = content
     this.__mode = mode
     Node.__init__(this, *args, **kwds)