Exemplo n.º 1
0
 def launchShelve(self):
     from tortoisehg.hgqt import shelve
     # TODO: pass self._filename
     dlg = shelve.ShelveDialog(self.repo, self)
     dlg.finished.connect(dlg.deleteLater)
     dlg.exec_()
     self.shelveToolExited.emit()
Exemplo n.º 2
0
 def linkActivated(self, link):
     link = hglib.fromunicode(link)
     if link.startswith('subrepo:'):
         from tortoisehg.hgqt.run import qtrun
         from tortoisehg.hgqt import commit
         qtrun(commit.run, self.stwidget.repo.ui, root=link[8:])
     if link.startswith('shelve:'):
         from tortoisehg.hgqt import shelve
         dlg = shelve.ShelveDialog(self.stwidget.repo, self)
         dlg.finished.connect(dlg.deleteLater)
         dlg.exec_()
         self.refresh()
Exemplo n.º 3
0
    def onLinkActivated(self, cmd):
        cmd = hglib.fromunicode(cmd)
        repo = self.repo
        if cmd == 'commit':
            from tortoisehg.hgqt import commit
            dlg = commit.CommitDialog(repo, [], {}, self)
            dlg.finished.connect(dlg.deleteLater)
            dlg.exec_()
            self.refresh()
        elif cmd == 'shelve':
            from tortoisehg.hgqt import shelve
            dlg = shelve.ShelveDialog(repo, self.wizard())
            dlg.finished.connect(dlg.deleteLater)
            dlg.exec_()
            self.refresh()
        elif cmd.startswith('discard'):
            if cmd != 'discard:noconfirm':
                labels = [(QMessageBox.Yes, _('&Discard')),
                          (QMessageBox.No, _('Cancel'))]
                if not qtlib.QuestionMsgBox(
                        _('Confirm Discard'),
                        _('Discard outstanding changes to working directory?'),
                        labels=labels,
                        parent=self):
                    return

            def finished(ret):
                repo.decrementBusyCount()
                self.refresh()

            cmdline = [
                'update', '--clean', '--repository', repo.root, '--rev', '.'
            ]
            self.runner = cmdui.Runner(True, self)
            self.runner.commandFinished.connect(finished)
            repo.incrementBusyCount()
            self.runner.run(cmdline)
        elif cmd == 'view':
            dlg = status.StatusDialog(repo, [], {}, self)
            dlg.exec_()
            self.refresh()
        elif cmd == 'skip':
            self.wizard().next()
        else:
            raise 'unknown command: %s' % cmd
Exemplo n.º 4
0
    def update(self):
        self.saveSettings()
        cmdline = ['update', '--repository', self.repo.root]
        if self.verbose_chk.isChecked():
            cmdline += ['--verbose']
        cmdline += [
            '--config', 'ui.merge=internal:' +
            (self.autoresolve_chk.isChecked() and 'merge' or 'fail')
        ]
        rev = hglib.fromunicode(self.rev_combo.currentText())

        activatebookmarkmode = self.repo.ui.config('tortoisehg',
                                                   'activatebookmarks',
                                                   'prompt')
        if activatebookmarkmode != 'never':
            bookmarks = self.repo[rev].bookmarks()
            if bookmarks and rev not in bookmarks:
                # The revision that we are updating into has bookmarks,
                # but the user did not refer to the revision by one of them
                # (probably used a revision number or hash)
                # Ask the user if it wants to update to one of these bookmarks
                # instead
                selectedbookmark = None
                if len(bookmarks) == 1:
                    if activatebookmarkmode == 'auto':
                        activatebookmark = True
                    else:
                        activatebookmark = qtlib.QuestionMsgBox(
                            _('Activate bookmark?'),
                            _('The selected revision (%s) has a bookmark on it '
                            'called "<i>%s</i>".<p>Do you want to activate it?'
                            '<br></b><i>You can disable this prompt by configuring '
                            'Settings/Workbench/Activate Bookmarks</i>') \
                            % (hglib.tounicode(rev), bookmarks[0]))
                    if activatebookmark:
                        selectedbookmark = bookmarks[0]
                else:
                    # Even in auto mode, when there is more than one bookmark
                    # we must ask the user which one must be activated
                    selectedbookmark = qtlib.ChoicePrompt(
                        _('Activate bookmark?'),
                        _('The selected revision (<i>%s</i>) has <i>%d</i> '
                        'bookmarks on it.<p>Select the bookmark that you want '
                        'to activate and click <i>OK</i>.<p>Click <i>Cancel</i> '
                        'if you don\'t want to activate any of them.<p>'
                        '<p><i>You can disable this prompt by configuring '
                        'Settings/Workbench/Activate Bookmarks</i><p>') \
                        % (hglib.tounicode(rev), len(bookmarks)),
                        self, bookmarks, self.repo._bookmarkcurrent).run()
                if selectedbookmark:
                    rev = selectedbookmark
                elif self.repo[rev] == self.repo[self.repo._bookmarkcurrent]:
                    deactivatebookmark = qtlib.QuestionMsgBox(
                        _('Deactivate current bookmark?'),
                        _('Do you really want to deactivate the <i>%s</i> '
                          'bookmark?') % self.repo._bookmarkcurrent)
                    if deactivatebookmark:
                        cmdline = ['bookmark', '--repository', self.repo.root]
                        if self.verbose_chk.isChecked():
                            cmdline += ['--verbose']
                        cmdline += ['-i', self.repo._bookmarkcurrent]
                        self.repo.incrementBusyCount()
                        self.cmd.run(cmdline)
                    return

        cmdline.append('--rev')
        cmdline.append(rev)

        if self.discard_chk.isChecked():
            cmdline.append('--clean')
        else:
            cur = self.repo['.']
            try:
                node = self.repo[rev]
            except (error.LookupError, error.RepoLookupError, error.RepoError):
                return

            def isclean():
                '''whether WD is changed'''
                try:
                    wc = self.repo[None]
                    if wc.modified() or wc.added() or wc.removed():
                        return False
                    for s in wc.substate:
                        if wc.sub(s).dirty():
                            return False
                except EnvironmentError:
                    return False
                return True

            def ismergedchange():
                '''whether the local changes are merged (have 2 parents)'''
                wc = self.repo[None]
                return len(wc.parents()) == 2

            def iscrossbranch(p1, p2):
                '''whether p1 -> p2 crosses branch'''
                pa = p1.ancestor(p2)
                return p1.branch() != p2.branch() or (p1 != pa and p2 != pa)

            def islocalmerge(p1, p2, clean=None):
                if clean is None:
                    clean = isclean()
                pa = p1.ancestor(p2)
                return not clean and (p1 == pa or p2 == pa)

            def confirmupdate(clean=None):
                if clean is None:
                    clean = isclean()

                msg = _('Detected uncommitted local changes in working tree.\n'
                        'Please select to continue:\n')
                data = {
                    'discard':
                    (_('&Discard'),
                     _('Discard - discard local changes, no backup')),
                    'shelve': (_('&Shelve'),
                               _('Shelve - move local changes to a patch')),
                    'merge': (_('&Merge'),
                              _('Merge - allow to merge with local changes')),
                }

                opts = ['discard']
                if not ismergedchange():
                    opts.append('shelve')
                if islocalmerge(cur, node, clean):
                    opts.append('merge')

                dlg = QMessageBox(QMessageBox.Question, _('Confirm Update'),
                                  '', QMessageBox.Cancel, self)
                buttonnames = {}
                for name in opts:
                    label, desc = data[name]
                    msg += '\n'
                    msg += desc
                    btn = dlg.addButton(label, QMessageBox.ActionRole)
                    buttonnames[btn] = name
                dlg.setDefaultButton(QMessageBox.Cancel)
                dlg.setText(msg)
                dlg.exec_()
                clicked = buttonnames.get(dlg.clickedButton())
                return clicked

            # If merge-by-default, we want to merge whenever possible,
            # without prompting user (similar to command-line behavior)
            defaultmerge = self.merge_chk.isChecked()
            clean = isclean()
            if clean:
                cmdline.append('--check')
            elif not (defaultmerge and islocalmerge(cur, node, clean)):
                clicked = confirmupdate(clean)
                if clicked == 'discard':
                    cmdline.append('--clean')
                elif clicked == 'shelve':
                    from tortoisehg.hgqt import shelve
                    dlg = shelve.ShelveDialog(self._repoagent, self)
                    dlg.finished.connect(dlg.deleteLater)
                    dlg.exec_()
                    return
                elif clicked == 'merge':
                    pass  # no args
                else:
                    return

        # start updating
        self.repo.incrementBusyCount()
        self.cmd.run(cmdline)
Exemplo n.º 5
0
 def launchShelveDialog(self):
     from tortoisehg.hgqt import shelve
     dlg = shelve.ShelveDialog(self._repoagent, self.parent())
     dlg.finished.connect(dlg.deleteLater)
     dlg.exec_()
     self.check()
Exemplo n.º 6
0
def shelve(ui, repoagent, *pats, **opts):
    """Move changes between working directory and patches"""
    from tortoisehg.hgqt import shelve as shelvemod
    return shelvemod.ShelveDialog(repoagent)