def branch_item_changed(self, *rest): """This callback is called when the branch selection changes""" # When the branch selection changes then we should update # the "Revision Expression" accordingly. qlist = self.branch_list remote_branch = qtutils.selected_item(qlist, self.branch_sources()) if not remote_branch: return # Update the model with the selection self.revision.setText(remote_branch) # Set the branch field if we're branching from a remote branch. if not self.remote_radio.isChecked(): return branch = gitcmds.strip_remote(self.model.remotes, remote_branch) if branch == 'HEAD': return # Signal that we've clicked on a remote branch self.branch_name.setText(branch)
def matches(self): model = self.main_model remotes = model.remotes remote_branches = model.remote_branches ambiguous = set() allnames = set(model.local_branches) potential = [] for remote_branch in remote_branches: branch = gitcmds.strip_remote(remotes, remote_branch) if branch in allnames or branch == remote_branch: ambiguous.add(branch) continue potential.append(branch) allnames.add(branch) potential_branches = [p for p in potential if p not in ambiguous] return (model.local_branches + potential_branches + model.remote_branches + model.tags)