Пример #1
0
    def update_diff_files(self, *rest):
        """Updates the list of files whenever the selection changes"""
        # Left and Right refer to the comparison pair (l,r)
        left_item, right_item = self.selection()
        if (not left_item or not right_item or left_item == right_item):
            self.set_diff_files([])
            return
        left_item = self.remote_ref(left_item)
        right_item = self.remote_ref(right_item)

        # If any of the selection includes sandbox then we
        # generate the same diff, regardless.  This means we don't
        # support reverse diffs against sandbox aka worktree.
        if self.SANDBOX in (left_item, right_item):
            self.use_sandbox = True
            if left_item == self.SANDBOX:
                self.diff_arg = (right_item, )
            else:
                self.diff_arg = (left_item, )
        else:
            self.diff_arg = (left_item, right_item)
            self.use_sandbox = False

        # start and end as in 'git diff start end'
        self.start = left_item
        self.end = right_item

        if len(self.diff_arg) == 1:
            files = gitcmds.diff_index_filenames(self.diff_arg[0])
        else:
            files = gitcmds.diff_filenames(*self.diff_arg)

        self.set_diff_files(files)
Пример #2
0
    def exec_(self):
        if self.expr:
            filenames = gitcmds.diff_filenames(*self.diff_arg)
        elif self.b is None:
            filenames = gitcmds.diff_index_filenames(self.a)
        else:
            filenames = gitcmds.diff_filenames(*self.diff_arg)

        if not filenames:
            details = ('"git diff --name-only %s" returned an empty list' %
                       ' '.join(self.diff_arg))
            self.hide()
            qtutils.information('git cola',
                                message='No changes to diff',
                                details=details)
            self.close()
            return self.Accepted

        icon = qtutils.file_icon()
        items = []
        for filename in filenames:
            item = QtGui.QTreeWidgetItem()
            item.setIcon(0, icon)
            item.setText(0, filename)
            item.setData(0, QtCore.Qt.UserRole, QtCore.QVariant(filename))
            items.append(item)
        self._tree.addTopLevelItems(items)

        return QtGui.QDialog.exec_(self)
Пример #3
0
    def update_diff_files(self, *rest):
        """Updates the list of files whenever the selection changes"""
        # Left and Right refer to the comparison pair (l,r)
        left_item, right_item = self.selection()
        if (not left_item or not right_item or
                left_item == right_item):
            self.set_diff_files([])
            return
        left_item = self.remote_ref(left_item)
        right_item = self.remote_ref(right_item)

        # If any of the selection includes sandbox then we
        # generate the same diff, regardless.  This means we don't
        # support reverse diffs against sandbox aka worktree.
        if self.SANDBOX in (left_item, right_item):
            self.use_sandbox = True
            if left_item == self.SANDBOX:
                self.diff_arg = (right_item,)
            else:
                self.diff_arg = (left_item,)
        else:
            self.diff_arg = (left_item, right_item)
            self.use_sandbox = False

        # start and end as in 'git diff start end'
        self.start = left_item
        self.end = right_item

        if len(self.diff_arg) == 1:
            files = gitcmds.diff_index_filenames(self.diff_arg[0])
        else:
            files = gitcmds.diff_filenames(*self.diff_arg)

        self.set_diff_files(files)
Пример #4
0
    def exec_(self):
        if self.expr:
            filenames = gitcmds.diff_filenames(*self.diff_arg)
        elif self.b is None:
            filenames = gitcmds.diff_index_filenames(self.a)
        else:
            filenames = gitcmds.diff_filenames(*self.diff_arg)

        if not filenames:
            details = ('"git diff --name-only %s" returned an empty list' %
                       ' '.join(self.diff_arg))
            self.hide()
            qtutils.information('git cola',
                                message='No changes to diff',
                                details=details)
            self.close()
            return self.Accepted

        icon = qtutils.file_icon()
        items = []
        for filename in filenames:
            item = QtGui.QTreeWidgetItem()
            item.setIcon(0, icon)
            item.setText(0, filename)
            item.setData(0, QtCore.Qt.UserRole, QtCore.QVariant(filename))
            items.append(item)
        self._tree.addTopLevelItems(items)

        return QtGui.QDialog.exec_(self)
Пример #5
0
    def update_diff_files(self, *rest):
        """Updates the list of files whenever the selection changes"""
        if (not self.model.has_param('left_list_item') or
                not self.model.has_param('right_list_item')):
            return
        # Left and Right refer to the comparison pair (l,r)
        left_item = self.model.left_list_item
        right_item = self.model.right_list_item
        if (not left_item or not right_item or
                left_item == right_item):
            self.model.set_diff_files([])
            return
        left_item = self.remote_ref(left_item)
        right_item = self.remote_ref(right_item)

        # If any of the selection includes sandbox then we
        # generate the same diff, regardless.  This means we don't
        # support reverse diffs against sandbox aka worktree.
        if (left_item == BranchCompareController.SANDBOX or
                right_item == BranchCompareController.SANDBOX):
            self.use_sandbox = True
            if left_item == BranchCompareController.SANDBOX:
                self.diff_arg = (right_item,)
            else:
                self.diff_arg = (left_item,)
        else:
            self.diff_arg = (left_item, right_item)
            self.use_sandbox = False

        # start and end as in 'git diff start end'
        self.start = left_item
        self.end = right_item

        # TODO leverage Qt's model/view architecture
        if len(self.diff_arg) == 1:
            files = gitcmds.diff_index_filenames(self.diff_arg[0])
        else:
            files = gitcmds.diff_filenames(*self.diff_arg)
        self.model.set_diff_files(files)

        icon = qtutils.icon('script.png')
        for idx in xrange(0, self.view.diff_files.topLevelItemCount()):
            item = self.view.diff_files.topLevelItem(idx)
            item.setIcon(0, icon)
Пример #6
0
    def refresh_filenames(self):
        self._tree.clear()

        if self.a and self.b is None:
            filenames = gitcmds.diff_index_filenames(self.a)
        else:
            filenames = gitcmds.diff(self.diff_arg)
        if not filenames:
            return

        icon = qtutils.file_icon()
        items = []
        for filename in filenames:
            item = QtGui.QTreeWidgetItem()
            item.setIcon(0, icon)
            item.setText(0, filename)
            item.setData(0, QtCore.Qt.UserRole, QtCore.QVariant(filename))
            items.append(item)
        self._tree.addTopLevelItems(items)
Пример #7
0
 def run(self):
     ref = 'HEAD~%d' % self.count
     filenames = gitcmds.diff_index_filenames(ref)
     self.emit(SIGNAL('filenames'), filenames)
Пример #8
0
 def run(self):
     ref = 'HEAD~%d' % self.count
     filenames = gitcmds.diff_index_filenames(ref)
     self.emit(SIGNAL('filenames'), filenames)
Пример #9
0
 def refresh_filenames(self):
     if self.a and self.b is None:
         filenames = gitcmds.diff_index_filenames(self.a)
     else:
         filenames = gitcmds.diff(self.diff_arg)
     self.tree.set_filenames(filenames, select=True)
Пример #10
0
 def refresh_filenames(self):
     if self.a and self.b is None:
         filenames = gitcmds.diff_index_filenames(self.a)
     else:
         filenames = gitcmds.diff(self.diff_arg)
     self.tree.set_filenames(filenames, select=True)