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
def single_selection(self): """Scan across staged, modified, etc. and return a single item.""" st = None um = None m = None ut = None s = self.selection() if s.staged: st = s.staged[0] elif s.modified: m = s.modified[0] elif s.unmerged: um = s.unmerged[0] elif s.untracked: ut = s.untracked[0] return State(st, um, m, ut)
def contents(self): return State(self.m.staged, self.m.unmerged, self.m.modified, self.m.untracked)
def selection(self): """Return the current selection in the repo status tree.""" return State(self.staged(), self.unmerged(), self.modified(), self.untracked())