Ejemplo n.º 1
0
    def _populate_from_branch(self):
        """Populate the in-tree state from the branch."""
        if self.branch.head is None:
            self._parent_ids = []
        else:
            self._parent_ids = [self.last_revision()]
        self._file_transport = MemoryTransport()
        if self.branch.head is None:
            tree = Tree()
            self._basis_fileid_map = GitFileIdMap({}, self.mapping)
        else:
            tree_id = self.store[self.branch.head].tree
            self._basis_fileid_map = self.mapping.get_fileid_map(
                self.store.__getitem__, tree_id)
            tree = self.store[tree_id]
        self._fileid_map = self._basis_fileid_map.copy()

        trees = [("", tree)]
        while trees:
            (path, tree) = trees.pop()
            for name, mode, sha in tree.iteritems():
                subpath = posixpath.join(path, name.decode('utf-8'))
                if stat.S_ISDIR(mode):
                    self._file_transport.mkdir(subpath)
                    trees.append((subpath, self.store[sha]))
                elif stat.S_ISREG(mode):
                    self._file_transport.put_bytes(subpath,
                                                   self.store[sha].data)
                    self._index_add_entry(subpath, 'file')
                else:
                    raise NotImplementedError(self._populate_from_branch)
Ejemplo n.º 2
0
    def _populate_from_branch(self):
        """Populate the in-tree state from the branch."""
        if self.branch.head is None:
            self._parent_ids = []
        else:
            self._parent_ids = [self.last_revision()]
        self._file_transport = MemoryTransport()
        if self.branch.head is None:
            tree = Tree()
        else:
            tree_id = self.store[self.branch.head].tree
            tree = self.store[tree_id]

        trees = [("", tree)]
        while trees:
            (path, tree) = trees.pop()
            for name, mode, sha in tree.iteritems():
                subpath = posixpath.join(path, decode_git_path(name))
                if stat.S_ISDIR(mode):
                    self._file_transport.mkdir(subpath)
                    trees.append((subpath, self.store[sha]))
                elif stat.S_ISREG(mode):
                    self._file_transport.put_bytes(subpath,
                                                   self.store[sha].data)
                    self._index_add_entry(subpath, 'file')
                else:
                    raise NotImplementedError(self._populate_from_branch)
Ejemplo n.º 3
0
 def test_tree_dir_sort(self):
     x = Tree()
     x["a.c"] = (0100755, "d80c186a03f423a81b39df39dc87fd269736ca86")
     x["a"] = (stat.S_IFDIR, "d80c186a03f423a81b39df39dc87fd269736ca86")
     x["a/c"] = (stat.S_IFDIR, "d80c186a03f423a81b39df39dc87fd269736ca86")
     self.assertEquals(["a.c", "a", "a/c"], [p[0] for p in x.iteritems()])
Ejemplo n.º 4
0
 def test_tree_iteritems_dir_sort(self):
     x = Tree()
     for name, item in _TREE_ITEMS.iteritems():
         x[name] = item
     self.assertEquals(_SORTED_TREE_ITEMS, list(x.iteritems()))
Ejemplo n.º 5
0
 def test_tree_iteritems_dir_sort(self):
     x = Tree()
     for name, item in _TREE_ITEMS.iteritems():
         x[name] = item
     self.assertEqual(_SORTED_TREE_ITEMS, list(x.iteritems()))
Ejemplo n.º 6
0
 def test_tree_dir_sort(self):
     x = Tree()
     x["a.c"] = (0100755, "d80c186a03f423a81b39df39dc87fd269736ca86")
     x["a"] = (stat.S_IFDIR, "d80c186a03f423a81b39df39dc87fd269736ca86")
     x["a/c"] = (stat.S_IFDIR, "d80c186a03f423a81b39df39dc87fd269736ca86")
     self.assertEquals(["a.c", "a", "a/c"], [p[0] for p in x.iteritems()])