예제 #1
0
파일: browse.py 프로젝트: moreati/git-cola
    def _initialize(self):
        """Iterate over git-ls-tree and create GitTreeItems."""
        status, output = git.ls_tree('--full-tree',
                                     '-r',
                                     '-t',
                                     '-z',
                                     self.ref,
                                     with_status=True,
                                     with_stderr=True)
        if status != 0:
            cola.notifier().broadcast(signals.log_cmd, status, output)
            return

        if not output:
            return

        for line in core.decode(output[:-1]).split('\0'):
            # .....6 ...4 ......................................40
            # 040000 tree c127cde9a0c644a3a8fef449a244f47d5272dfa6	relative
            # 100644 blob 139e42bf4acaa4927ec9be1ec55a252b97d3f1e2	relative/path
            objtype = line[7]
            relpath = line[6 + 1 + 4 + 1 + 40 + 1:]
            if objtype == 't':
                parent = self.dir_entries[utils.dirname(relpath)]
                self.add_directory(parent, relpath)
            elif objtype == 'b':
                self.add_file(relpath)
예제 #2
0
 def add_file(self, path, insert=False):
     """Add a file to the model."""
     dirname = utils.dirname(path)
     if dirname in self._dir_entries:
         parent = self._dir_entries[dirname]
     else:
         parent = self._create_dir_entry(dirname, self._dir_entries)
         self._dir_entries[dirname] = parent
     self._add_file(parent, path, insert=insert)
예제 #3
0
 def add_file(self, path, insert=False):
     """Add a file to the model."""
     dirname = utils.dirname(path)
     if dirname in self._direntries:
         parent = self._direntries[dirname]
     else:
         parent = self._create_dir_entry(dirname, self._direntries)
         self._direntries[dirname] = parent
     self._add_file(parent, path, insert=insert)
예제 #4
0
    def add_file(self, path):
        """Add a file to the model."""
        dirname = utils.dirname(path)
        dir_entries = self.dir_entries
        try:
            parent = dir_entries[dirname]
        except KeyError:
            parent = dir_entries[dirname] = self.create_dir_entry(dirname)

        row_items = self.create_row(path, False)
        parent.appendRow(row_items)
예제 #5
0
파일: browse.py 프로젝트: jmdcal/git-cola
    def add_file(self, path):
        """Add a file to the model."""
        dirname = utils.dirname(path)
        dir_entries = self.dir_entries
        try:
            parent = dir_entries[dirname]
        except KeyError:
            parent = dir_entries[dirname] = self.create_dir_entry(dirname)

        row_items = self.create_row(path, False)
        parent.appendRow(row_items)
예제 #6
0
    def _initialize(self):
        """Iterate over git-ls-tree and create GitTreeItems."""
        status, output = git.ls_tree('--full-tree', '-r', '-t', '-z', self.ref,
                                     with_status=True, with_stderr=True)
        if status != 0:
            cola.notifier().broadcast(signals.log_cmd, status, output)
            return

        for line in output.rstrip('\0').split('\0'):
            # .....6 ...4 ......................................40
            # 040000 tree c127cde9a0c644a3a8fef449a244f47d5272dfa6	relative
            # 100644 blob 139e42bf4acaa4927ec9be1ec55a252b97d3f1e2	relative/path
            objtype = line[7]
            relpath = line[6 + 1 + 4 + 1 + 40 + 1:]
            if objtype == 't':
                parent = self.dir_entries[utils.dirname(relpath)]
                self.add_directory(parent, relpath)
            elif objtype == 'b':
                self.add_file(relpath)
예제 #7
0
파일: browse.py 프로젝트: jeasu/git-cola
    def _initialize(self):
        """Iterate over git-ls-tree and create GitTreeItems."""
        status, out, err = git.ls_tree("--full-tree", "-r", "-t", "-z", self.ref)
        if status != 0:
            Interaction.log_status(status, out, err)
            return

        if not out:
            return

        for line in out[:-1].split("\0"):
            # .....6 ...4 ......................................40
            # 040000 tree c127cde9a0c644a3a8fef449a244f47d5272dfa6	relative
            # 100644 blob 139e42bf4acaa4927ec9be1ec55a252b97d3f1e2	relative/path
            objtype = line[7]
            relpath = line[6 + 1 + 4 + 1 + 40 + 1 :]
            if objtype == "t":
                parent = self.dir_entries[utils.dirname(relpath)]
                self.add_directory(parent, relpath)
            elif objtype == "b":
                self.add_file(relpath)
예제 #8
0
    def _initialize(self):
        """Iterate over git-ls-tree and create GitTreeItems."""
        status, out, err = git.ls_tree('--full-tree', '-r', '-t', '-z',
                                       self.ref)
        if status != 0:
            Interaction.log_status(status, out, err)
            return

        if not out:
            return

        for line in out[:-1].split('\0'):
            # .....6 ...4 ......................................40
            # 040000 tree c127cde9a0c644a3a8fef449a244f47d5272dfa6	relative
            # 100644 blob 139e42bf4acaa4927ec9be1ec55a252b97d3f1e2	relative/path
            objtype = line[7]
            relpath = line[6 + 1 + 4 + 1 + 40 + 1:]
            if objtype == 't':
                parent = self.dir_entries[utils.dirname(relpath)]
                self.add_directory(parent, relpath)
            elif objtype == 'b':
                self.add_file(relpath)
예제 #9
0
 def test_dirname(self):
     """Test the utils.dirname function."""
     self.assertEqual(utils.dirname('bar'), '')
     self.assertEqual(utils.dirname('/bar'), '')
     self.assertEqual(utils.dirname('//bar'), '')
     self.assertEqual(utils.dirname('///bar'), '')
     self.assertEqual(utils.dirname('foo/bar'), 'foo')
     self.assertEqual(utils.dirname('foo//bar'), 'foo')
     self.assertEqual(utils.dirname('foo /bar'), 'foo ')
     self.assertEqual(utils.dirname('/foo//bar'), '/foo')
     self.assertEqual(utils.dirname('/foo /bar'), '/foo ')
     self.assertEqual(utils.dirname('//foo//bar'), '/foo')
     self.assertEqual(utils.dirname('///foo///bar'), '/foo')
예제 #10
0
 def test_dirname(self):
     """Test the utils.dirname function."""
     self.assertEqual(utils.dirname('bar'), '')
     self.assertEqual(utils.dirname('/bar'), '')
     self.assertEqual(utils.dirname('//bar'), '')
     self.assertEqual(utils.dirname('///bar'), '')
     self.assertEqual(utils.dirname('foo/bar'), 'foo')
     self.assertEqual(utils.dirname('foo//bar'), 'foo')
     self.assertEqual(utils.dirname('foo /bar'), 'foo ')
     self.assertEqual(utils.dirname('/foo//bar'), '/foo')
     self.assertEqual(utils.dirname('/foo /bar'), '/foo ')
     self.assertEqual(utils.dirname('//foo//bar'), '/foo')
     self.assertEqual(utils.dirname('///foo///bar'), '/foo')
예제 #11
0
 def test_dirname(self):
     """Test the utils.dirname function."""
     self.assertEqual(utils.dirname("bar"), "")
     self.assertEqual(utils.dirname("/bar"), "")
     self.assertEqual(utils.dirname("//bar"), "")
     self.assertEqual(utils.dirname("///bar"), "")
     self.assertEqual(utils.dirname("foo/bar"), "foo")
     self.assertEqual(utils.dirname("foo//bar"), "foo")
     self.assertEqual(utils.dirname("foo /bar"), "foo ")
     self.assertEqual(utils.dirname("/foo//bar"), "/foo")
     self.assertEqual(utils.dirname("/foo /bar"), "/foo ")
     self.assertEqual(utils.dirname("//foo//bar"), "/foo")
     self.assertEqual(utils.dirname("///foo///bar"), "/foo")
예제 #12
0
def test_dirname():
    """Test the utils.dirname function."""
    assert utils.dirname('bar') == ''
    assert utils.dirname('/bar') == ''
    assert utils.dirname('//bar') == ''
    assert utils.dirname('///bar') == ''
    assert utils.dirname('foo/bar') == 'foo'
    assert utils.dirname('foo//bar') == 'foo'
    assert utils.dirname('foo /bar') == 'foo '
    assert utils.dirname('/foo//bar') == '/foo'
    assert utils.dirname('/foo /bar') == '/foo '
    assert utils.dirname('//foo//bar') == '/foo'
    assert utils.dirname('///foo///bar') == '/foo'