예제 #1
0
    def status(self):
        """Return the status for the entry's path."""

        model = main.model()
        unmerged = utils.add_parents(model.unmerged)
        modified = utils.add_parents(model.modified)
        staged = utils.add_parents(model.staged)
        untracked = utils.add_parents(model.untracked)
        upstream_changed = utils.add_parents(model.upstream_changed)

        if self.path in unmerged:
            status = (icons.modified_name(), N_('Unmerged'))
        elif self.path in modified and self.path in staged:
            status = (icons.partial_name(), N_('Partially Staged'))
        elif self.path in modified:
            status = (icons.modified_name(), N_('Modified'))
        elif self.path in staged:
            status = (icons.staged_name(), N_('Staged'))
        elif self.path in upstream_changed:
            status = (icons.upstream_name(), N_('Changed Upstream'))
        elif self.path in untracked:
            status = (None, '?')
        else:
            status = (None, '')
        return status
예제 #2
0
파일: view.py 프로젝트: moreati/git-cola
    def sync_selection(self):
        """Push selection into the selection model."""
        staged = []
        unmerged = []
        modified = []
        untracked = []
        state = State(staged, unmerged, modified, untracked)

        paths = self.selected_paths()
        model = cola.model()
        model_staged = utils.add_parents(set(model.staged))
        model_modified = utils.add_parents(set(model.modified))
        model_unmerged = utils.add_parents(set(model.unmerged))
        model_untracked = utils.add_parents(set(model.untracked))

        for path in paths:
            if path in model_unmerged:
                unmerged.append(path)
            elif path in model_untracked:
                untracked.append(path)
            elif path in model_staged:
                staged.append(path)
            elif path in model_modified:
                modified.append(path)
            else:
                staged.append(path)
        # Push the new selection into the model.
        cola.selection_model().set_selection(state)
        return paths
예제 #3
0
    def status(self):
        """Return the status for the entry's path."""

        model = main.model()
        unmerged = utils.add_parents(model.unmerged)
        modified = utils.add_parents(model.modified)
        staged = utils.add_parents(model.staged)
        untracked = utils.add_parents(model.untracked)
        upstream_changed = utils.add_parents(model.upstream_changed)

        if self.path in unmerged:
            status = (icons.modified_name(), N_('Unmerged'))
        elif self.path in modified and self.path in staged:
            status = (icons.partial_name(), N_('Partially Staged'))
        elif self.path in modified:
            status = (icons.modified_name(), N_('Modified'))
        elif self.path in staged:
            status = (icons.staged_name(), N_('Staged'))
        elif self.path in upstream_changed:
            status = (icons.upstream_name(), N_('Changed Upstream'))
        elif self.path in untracked:
            status = (None, '?')
        else:
            status = (None, '')
        return status
예제 #4
0
파일: model.py 프로젝트: dannyfeng/gitGUI
    def status(self):
        """Return the status for the entry's path."""

        model = cola.model()
        unmerged = utils.add_parents(set(model.unmerged))
        modified = utils.add_parents(set(model.modified))
        staged = utils.add_parents(set(model.staged))
        untracked = utils.add_parents(set(model.untracked))
        upstream_changed = utils.add_parents(set(model.upstream_changed))

        if self.path in unmerged:
            return (resources.icon('sigil-unmerged.png'),
                    qtutils.tr('Unmerged'))
        if self.path in modified and self.path in staged:
            return (resources.icon('sigil-partial.png'),
                    qtutils.tr('Partially Staged'))
        if self.path in modified:
            return (resources.icon('sigil-modified.png'),
                    qtutils.tr('Modified'))
        if self.path in staged:
            return (resources.icon('sigil-staged.png'),
                    qtutils.tr('Staged'))
        if self.path in upstream_changed:
            return (resources.icon('sigil-upstream.png'),
                    qtutils.tr('Changed Upstream'))
        if self.path in untracked:
            return (None, '?')
        return (None, '')
예제 #5
0
파일: model.py 프로젝트: gdebure/git-cola
    def status(self):
        """Return the status for the entry's path."""

        model = cola.model()
        unmerged = utils.add_parents(set(model.unmerged))
        modified = utils.add_parents(set(model.modified))
        staged = utils.add_parents(set(model.staged))
        untracked = utils.add_parents(set(model.untracked))
        upstream_changed = utils.add_parents(set(model.upstream_changed))

        if self.path in unmerged:
            return (resources.icon('modified.png'), qtutils.tr('Unmerged'))
        if self.path in modified and self.path in staged:
            return (resources.icon('partial.png'),
                    qtutils.tr('Partially Staged'))
        if self.path in modified:
            return (resources.icon('modified.png'), qtutils.tr('Modified'))
        if self.path in staged:
            return (resources.icon('staged.png'), qtutils.tr('Staged'))
        if self.path in upstream_changed:
            return (resources.icon('upstream.png'),
                    qtutils.tr('Changed Upstream'))
        if self.path in untracked:
            return (None, '?')
        return (None, '')
예제 #6
0
파일: browse.py 프로젝트: jmdcal/git-cola
    def sync_selection(self):
        """Push selection into the selection model."""
        staged = []
        unmerged = []
        modified = []
        untracked = []
        state = State(staged, unmerged, modified, untracked)

        paths = self.selected_paths()
        model = main.model()
        model_staged = utils.add_parents(model.staged)
        model_modified = utils.add_parents(model.modified)
        model_unmerged = utils.add_parents(model.unmerged)
        model_untracked = utils.add_parents(model.untracked)

        for path in paths:
            if path in model_unmerged:
                unmerged.append(path)
            elif path in model_untracked:
                untracked.append(path)
            elif path in model_staged:
                staged.append(path)
            elif path in model_modified:
                modified.append(path)
            else:
                staged.append(path)
        # Push the new selection into the model.
        selection_model().set_selection(state)
        return paths
예제 #7
0
    def test_add_parents(self):
        """Test the utils.add_parents() function."""
        path_set = set(["foo///bar///baz"])
        utils.add_parents(path_set)

        self.assertTrue("foo/bar/baz" in path_set)
        self.assertTrue("foo/bar" in path_set)
        self.assertTrue("foo" in path_set)
예제 #8
0
    def test_add_parents(self):
        """Test the utils.add_parents() function."""
        path_set = set(['foo///bar///baz'])
        utils.add_parents(path_set)

        self.assertTrue('foo/bar/baz' in path_set)
        self.assertTrue('foo/bar' in path_set)
        self.assertTrue('foo' in path_set)
예제 #9
0
파일: view.py 프로젝트: moreati/git-cola
 def selected_unstaged_paths(self, selection=None):
     """Return selected unstaged paths."""
     if not selection:
         selection = self.selected_paths()
     model = cola.model()
     modified = utils.add_parents(set(model.modified))
     untracked = utils.add_parents(set(model.untracked))
     unstaged = modified.union(untracked)
     return [p for p in selection if p in unstaged]
예제 #10
0
파일: browse.py 프로젝트: jmdcal/git-cola
 def selected_unstaged_paths(self, selection=None):
     """Return selected unstaged paths."""
     if not selection:
         selection = self.selected_paths()
     model = main.model()
     modified = utils.add_parents(model.modified)
     untracked = utils.add_parents(model.untracked)
     unstaged = modified.union(untracked)
     return [p for p in selection if p in unstaged]
예제 #11
0
    def gather_matches(self, case_sensitive):
        (matched_refs, dummy_paths, dummy_dirs) =\
                GitRefCompletionModel.gather_matches(self, case_sensitive)

        file_list = self.main_model.everything()
        files = set(file_list)
        files_and_dirs = utils.add_parents(set(files))

        if case_sensitive:
            transform = lambda x: x
            keyfunc = self.completion_key
        else:
            transform = lambda x: x.lower()
            keyfunc = self.lower_completion_key

        dirs = files_and_dirs.difference(files)
        matched_text = self.matched_text
        if matched_text:
            matched_paths = [
                f for f in files_and_dirs
                if transform(matched_text) in transform(f)
            ]
        else:
            matched_paths = list(files_and_dirs)

        matched_paths.sort(key=keyfunc)

        return (matched_refs, matched_paths, dirs)
예제 #12
0
    def gather_matches(self, case_sensitive):
        (matched_refs, dummy_paths, dummy_dirs) =\
                GitRefCompletionModel.gather_matches(self, case_sensitive)

        file_list = self.cola_model.everything()
        files = set(file_list)
        files_and_dirs = utils.add_parents(set(files))

        dirs = files_and_dirs.difference(files)
        matched_text = self.matched_text
        if matched_text:
            if case_sensitive:
                matched_paths = [f for f in files_and_dirs
                                        if matched_text in f]
            else:
                matched_paths = [f for f in files_and_dirs
                                    if matched_text.lower() in f.lower()]
        else:
            matched_paths = list(files_and_dirs)

        if self.case_sensitive:
            matched_paths.sort(cmp=self.completion_cmp)
        else:
            matched_paths.sort(cmp=self.lower_completion_cmp)
        return (matched_refs, matched_paths, dirs)
예제 #13
0
    def gather_matches(self, case_sensitive):
        (matched_refs, dummy_paths, dummy_dirs) =\
                GitRefCompletionModel.gather_matches(self, case_sensitive)

        file_list = self.main_model.everything()
        files = set(file_list)
        files_and_dirs = utils.add_parents(set(files))

        if case_sensitive:
            transform = lambda x: x
            keyfunc = self.completion_key
        else:
            transform = lambda x: x.lower()
            keyfunc = self.lower_completion_key

        dirs = files_and_dirs.difference(files)
        matched_text = self.matched_text
        if matched_text:
            matched_paths = [f for f in files_and_dirs
                             if transform(matched_text) in transform(f)]
        else:
            matched_paths = list(files_and_dirs)

        matched_paths.sort(key=keyfunc)

        return (matched_refs, matched_paths, dirs)
예제 #14
0
파일: qt.py 프로젝트: mwh/git-cola
    def gather_matches(self, case_sensitive):
        file_list = self.cmodel.everything()
        files = set(file_list)
        files_and_dirs = utils.add_parents(set(files))

        dirs = files_and_dirs.difference(files)

        model = self.cmodel
        refs = model.local_branches + model.remote_branches + model.tags
        matched_text = self.matched_text

        if matched_text:
            if case_sensitive:
                matched_refs = [r for r in refs if matched_text in r]
            else:
                matched_refs = [r for r in refs
                                    if matched_text.lower() in r.lower()]
        else:
            matched_refs = refs

        matched_refs.sort(cmp=self.lower_cmp)

        if matched_text:
            if case_sensitive:
                matched_paths = [f for f in files_and_dirs
                                        if matched_text in f]
            else:
                matched_paths = [f for f in files_and_dirs
                                    if matched_text.lower() in f.lower()]
        else:
            matched_paths = list(files_and_dirs)

        matched_paths.sort(cmp=self.lower_cmp)

        return (matched_refs, matched_paths, dirs)
예제 #15
0
파일: view.py 프로젝트: moreati/git-cola
 def selected_modified_paths(self, selection=None):
     """Return selected modified paths."""
     if not selection:
         selection = self.selected_paths()
     model = cola.model()
     modified = utils.add_parents(set(model.modified))
     return [p for p in selection if p in modified]
예제 #16
0
 def selected_modified_paths(self, selection=None):
     """Return selected modified paths."""
     if selection is None:
         selection = self.selected_paths()
     model = main.model()
     modified = utils.add_parents(model.modified)
     return [p for p in selection if p in modified]
예제 #17
0
파일: browse.py 프로젝트: jmdcal/git-cola
 def selected_modified_paths(self, selection=None):
     """Return selected modified paths."""
     if not selection:
         selection = self.selected_paths()
     model = main.model()
     modified = utils.add_parents(model.modified)
     return [p for p in selection if p in modified]
예제 #18
0
def filter_path_matches(match_text, file_list, case_sensitive):
    """Return matching completions from a list of candidate files"""

    files = set(file_list)
    files_and_dirs = utils.add_parents(files)
    dirs = files_and_dirs.difference(files)

    paths = filter_matches(match_text, files_and_dirs, case_sensitive)
    return (paths, dirs)
예제 #19
0
def filter_path_matches(match_text, file_list, case_sensitive):
    """Return matching completions from a list of candidate files"""

    files = set(file_list)
    files_and_dirs = utils.add_parents(files)
    dirs = files_and_dirs.difference(files)

    paths = filter_matches(match_text, files_and_dirs, case_sensitive)
    return (paths, dirs)
예제 #20
0
파일: view.py 프로젝트: moreati/git-cola
 def selected_tracked_paths(self, selection=None):
     """Return selected tracked paths."""
     if not selection:
         selection = self.selected_paths()
     model = cola.model()
     staged = set(self.selected_staged_paths())
     modified = set(self.selected_modified_paths())
     untracked = utils.add_parents(set(model.untracked))
     tracked = staged.union(modified)
     return [p for p in selection if p not in untracked or p in tracked]
예제 #21
0
파일: browse.py 프로젝트: jeasu/git-cola
 def selected_tracked_paths(self, selection=None):
     """Return selected tracked paths."""
     if not selection:
         selection = self.selected_paths()
     model = main.model()
     staged = set(self.selected_staged_paths())
     modified = set(self.selected_modified_paths())
     untracked = utils.add_parents(set(model.untracked))
     tracked = staged.union(modified)
     return [p for p in selection if p not in untracked or p in tracked]
예제 #22
0
    def test_add_parents(self):
        """Test the utils.add_parents() function."""
        paths = set(['foo///bar///baz'])
        path_set = utils.add_parents(paths)

        self.assertTrue('foo/bar/baz' in path_set)
        self.assertTrue('foo/bar' in path_set)
        self.assertTrue('foo' in path_set)

        # Ensure that the original set is unchanged
        expect = set(['foo///bar///baz'])
        self.assertEqual(expect, paths)
예제 #23
0
    def test_add_parents(self):
        """Test the utils.add_parents() function."""
        paths = set(['foo///bar///baz'])
        path_set = utils.add_parents(paths)

        self.assertTrue('foo/bar/baz' in path_set)
        self.assertTrue('foo/bar' in path_set)
        self.assertTrue('foo' in path_set)

        # Ensure that the original set is unchanged
        expect = set(['foo///bar///baz'])
        self.assertEqual(expect, paths)
예제 #24
0
def test_add_parents():
    """Test the utils.add_parents() function."""
    paths = set(['foo///bar///baz'])
    path_set = utils.add_parents(paths)

    assert 'foo/bar/baz' in path_set
    assert 'foo/bar' in path_set
    assert 'foo' in path_set
    assert 'foo///bar///baz' not in path_set

    # Ensure that the original set is unchanged
    expect = set(['foo///bar///baz'])
    assert expect == paths
예제 #25
0
    def status(self):
        """Return the status for the entry's path."""

        model = cola.model()
        unmerged = utils.add_parents(set(model.unmerged))
        modified = utils.add_parents(set(model.modified))
        staged = utils.add_parents(set(model.staged))
        untracked = utils.add_parents(set(model.untracked))
        upstream_changed = utils.add_parents(set(model.upstream_changed))

        if self.path in unmerged:
            return qtutils.tr('Unmerged')
        if self.path in modified and self.path in staged:
            return qtutils.tr('Partially Staged')
        if self.path in modified:
            return qtutils.tr('Modified')
        if self.path in staged:
            return qtutils.tr('Staged')
        if self.path in untracked:
            return qtutils.tr('Untracked')
        if self.path in upstream_changed:
            return qtutils.tr('Changed Upstream')
        return '-'
예제 #26
0
파일: model.py 프로젝트: suside/git-cola
    def status(self):
        """Return the status for the entry's path."""

        model = cola.model()
        unmerged = utils.add_parents(set(model.unmerged))
        modified = utils.add_parents(set(model.modified))
        staged = utils.add_parents(set(model.staged))
        untracked = utils.add_parents(set(model.untracked))
        upstream_changed = utils.add_parents(set(model.upstream_changed))

        if self.path in unmerged:
            return (resources.icon("modified.png"), N_("Unmerged"))
        if self.path in modified and self.path in staged:
            return (resources.icon("partial.png"), N_("Partially Staged"))
        if self.path in modified:
            return (resources.icon("modified.png"), N_("Modified"))
        if self.path in staged:
            return (resources.icon("staged.png"), N_("Staged"))
        if self.path in upstream_changed:
            return (resources.icon("upstream.png"), N_("Changed Upstream"))
        if self.path in untracked:
            return (None, "?")
        return (None, "")
예제 #27
0
    def status(self):
        """Return the status for the entry's path."""

        model = main.model()
        unmerged = utils.add_parents(model.unmerged)
        modified = utils.add_parents(model.modified)
        staged = utils.add_parents(model.staged)
        untracked = utils.add_parents(model.untracked)
        upstream_changed = utils.add_parents(model.upstream_changed)

        if self.path in unmerged:
            return (resources.icon('modified.png'), N_('Unmerged'))
        if self.path in modified and self.path in staged:
            return (resources.icon('partial.png'), N_('Partially Staged'))
        if self.path in modified:
            return (resources.icon('modified.png'), N_('Modified'))
        if self.path in staged:
            return (resources.icon('staged.png'), N_('Staged'))
        if self.path in upstream_changed:
            return (resources.icon('upstream.png'), N_('Changed Upstream'))
        if self.path in untracked:
            return (None, '?')
        return (None, '')
예제 #28
0
 def get_paths(self, files=None):
     """Return paths of interest; e.g. paths with a status."""
     if files is None:
         files = self.get_files()
     return utils.add_parents(files)
예제 #29
0
 def selected_staged_paths(self, selection=None):
     """Return selected staged paths."""
     if selection is None:
         selection = self.selected_paths()
     staged = utils.add_parents(main.model().staged)
     return [p for p in selection if p in staged]
예제 #30
0
 def get_paths(self, files=None):
     """Return paths of interest; e.g. paths with a status."""
     if files is None:
         files = self.get_files()
     return utils.add_parents(files)
예제 #31
0
파일: browse.py 프로젝트: jmdcal/git-cola
 def selected_staged_paths(self, selection=None):
     """Return selected staged paths."""
     if not selection:
         selection = self.selected_paths()
     staged = utils.add_parents(main.model().staged)
     return [p for p in selection if p in staged]
예제 #32
0
파일: qt.py 프로젝트: dcfrancisco/git-cola
    def update_matches(self, case_sensitive):
        QStandardItem = QtGui.QStandardItem
        file_list = self.cmodel.everything()
        files = set(file_list)
        files_and_dirs = utils.add_parents(set(files))
        dirs = files_and_dirs.difference(files)

        file_icon = qtutils.file_icon()
        dir_icon = qtutils.dir_icon()
        git_icon = qtutils.git_icon()

        model = self.cmodel
        refs = model.local_branches + model.remote_branches + model.tags
        matched_text = self.matched_text

        if matched_text:
            if case_sensitive:
                matched_refs = [r for r in refs if matched_text in r]
            else:
                matched_refs = [r for r in refs
                                    if matched_text.lower() in r.lower()]
        else:
            matched_refs = refs

        matched_refs.sort(cmp=self.lower_cmp)

        if matched_text:
            if case_sensitive:
                matched_paths = [f for f in files_and_dirs
                                        if matched_text in f]
            else:
                matched_paths = [f for f in files_and_dirs
                                    if matched_text.lower() in f.lower()]
        else:
            matched_paths = list(files_and_dirs)

        matched_paths.sort(cmp=self.lower_cmp)

        items = []

        for ref in matched_refs:
            item = QStandardItem()
            item.setText(ref)
            item.setIcon(git_icon)
            items.append(item)

        if matched_paths and (not matched_text or matched_text in '--'):
            item = QStandardItem()
            item.setText('--')
            item.setIcon(file_icon)
            items.append(item)

        for match in matched_paths:
            item = QStandardItem()
            item.setText(match)
            if match in dirs:
                item.setIcon(dir_icon)
            else:
                item.setIcon(file_icon)
            items.append(item)

        self.clear()
        for item in items:
            self.appendRow(item)
예제 #33
0
 def _get_paths(self):
     """Return paths of interest; e.g. paths with a status."""
     model = main.model()
     paths = set(model.staged + model.unstaged)
     return utils.add_parents(paths)
예제 #34
0
 def _get_paths(self):
     """Return paths of interest; e.g. paths with a status."""
     model = main.model()
     paths = model.staged + model.unstaged
     return utils.add_parents(paths)
예제 #35
0
파일: view.py 프로젝트: moreati/git-cola
 def selected_staged_paths(self, selection=None):
     """Return selected staged paths."""
     if not selection:
         selection = self.selected_paths()
     staged = utils.add_parents(set(cola.model().staged))
     return [p for p in selection if p in staged]