Ejemplo n.º 1
0
    def currentPage(self):
        super(MergePage, self).currentPage()
        if len(self.repo[None].parents()) > 1:
            self.mergecomplete = True
            self.completeChanged.emit()
            return

        discard = self.field('discard').toBool()
        rev = hglib.tounicode(self._otherrev)
        cfgs = []
        if discard:
            tool = ':local'
            # disable changed/deleted prompt because we'll revert changes
            cfgs.append('ui.interactive=False')
        else:
            tool = self.field('autoresolve').toBool() and ':merge' or ':fail'
        cmdlines = [hglib.buildcmdargs('merge', rev, verbose=True, tool=tool,
                                       force=self.field('force').toBool(),
                                       config=cfgs)]
        if discard:
            # revert files added/removed at other side
            cmdlines.append(hglib.buildcmdargs('revert', rev='.', all=True))

        self._cmdlog.clearLog()
        self._cmdsession = sess = self._repoagent.runCommandSequence(cmdlines,
                                                                     self)
        sess.commandFinished.connect(self.onCommandFinished)
        sess.outputReceived.connect(self._cmdlog.appendLog)
Ejemplo n.º 2
0
 def _markRevision(self, button):
     self._nextbuttons.setEnabled(False)
     state = str(button.objectName())
     cmds = []
     if self.discard_chk.isChecked():
         cmds.append(hglib.buildcmdargs('revert', all=True))
     cmds.append(hglib.buildcmdargs('bisect', '.', **{state: True}))
     self._setSession(self._repoagent.runCommandSequence(cmds, self))
Ejemplo n.º 3
0
 def _renameFrom(self, action):
     fds = self.fileDataListForAction('renameFileMenu')
     if not fds:
         # selection might be changed after menu is shown
         return
     deleted = hglib.escapepath(action.text())
     unknown = hglib.escapepath(fds[0].filePath())
     cmdlines = [hglib.buildcmdargs('copy', deleted, unknown, after=True),
                 hglib.buildcmdargs('forget', deleted)]  # !->R
     sess = self._runCommandSequence(cmdlines)
     sess.commandFinished.connect(self._notifyChangesOnCommandFinished)
Ejemplo n.º 4
0
 def refresh(self):
     """ update the bookmark lists """
     cmdline = hglib.buildcmdargs('outgoing', self._syncurl, bookmarks=True)
     self._outsess = sess = self._repoagent.runCommand(cmdline, self)
     sess.setCaptureOutput(True)
     sess.commandFinished.connect(self._onListLocalBookmarksFinished)
     cmdline = hglib.buildcmdargs('incoming', self._syncurl, bookmarks=True)
     self._insess = sess = self._repoagent.runCommand(cmdline, self)
     sess.setCaptureOutput(True)
     sess.commandFinished.connect(self._onListRemoteBookmarksFinished)
     self._updateActions()
Ejemplo n.º 5
0
 def _verifyBad(self):
     self.badrev = self._lookupRevision(self._ble.text().simplified())
     if self.badrev is None:
         return
     self._ble.setEnabled(False)
     self._bb.setEnabled(False)
     cmds = []
     if self.discard_chk.isChecked():
         cmds.append(hglib.buildcmdargs('revert', all=True))
     cmds.append(hglib.buildcmdargs('bisect', reset=True))
     cmds.append(hglib.buildcmdargs('bisect', self.goodrev, good=True))
     cmds.append(hglib.buildcmdargs('bisect', self.badrev, bad=True))
     self._setSession(self._repoagent.runCommandSequence(cmds, self))
Ejemplo n.º 6
0
 def copyPatch(self, fds):
     paths = [hglib.escapepath(fd.filePath()) for fd in fds]
     revs = map(hglib.escaperev, [fds[0].baseRev(), fds[0].rev()])
     cmdline = hglib.buildcmdargs('diff', *paths, r=revs)
     sess = self._runCommand(cmdline)
     sess.setCaptureOutput(True)
     sess.commandFinished.connect(self._copyPatchOutputToClipboard)
Ejemplo n.º 7
0
    def runCommand(self):
        opts = {'verbose': True}
        opts.update((n, w.isChecked()) for n, w in self._optchks.iteritems())

        wc = self.repo[None]
        wcparents = wc.parents()
        wcp1rev = wcparents[0].rev()
        wcp2rev = None
        if len(wcparents) > 1:
            wcp2rev = wcparents[1].rev()
        if not opts['force'] and not opts['keep'] and \
                (wcp1rev in self.cslist.curitems or
                         wcp2rev in self.cslist.curitems) and \
                (wc.modified() or wc.added() or wc.removed()):
            main = _("Detected uncommitted local changes.")
            text = _("Do you want to keep them or discard them?")
            choices = (_('&Keep (--keep)'),
                      _('&Discard (--force)'),
                      _('&Cancel'),
            )
            resp = qtlib.CustomPrompt(_('Confirm Strip'),
                '<b>%s</b><p>%s' % (main, text),
                self, choices, default=0, esc=2).run()
            if resp == 0:
                opts['keep'] = True
            elif resp == 1:
                opts['force'] = True
            else:
                return cmdcore.nullCmdSession()

        rev = self.rev_combo.currentText()
        cmdline = hglib.buildcmdargs('strip', rev, **opts)
        return self._repoagent.runCommand(cmdline, self)
Ejemplo n.º 8
0
    def validatePage(self):
        if not self._cmdsession.isFinished():
            return False

        if len(self.repo[None].parents()) == 1:
            # commit succeeded, repositoryChanged() called wizard().next()
            if self.field('skiplast').toBool():
                self.wizard().close()
            return True

        user = hglib.tounicode(qtlib.getCurrentUsername(self, self.repo,
                                                        self.opts))
        if not user:
            return False

        self.setTitle(_('Committing...'))
        self.setSubTitle(_('Please wait while committing merged files.'))

        opts = {'verbose': True,
                'message': self.msgEntry.text(),
                'user': user,
                'subrepos': bool(self.opts.get('recurseinsubrepos')),
                'date': hglib.tounicode(self.opts.get('date')),
                }
        commandlines = [hglib.buildcmdargs('commit', **opts)]
        pushafter = self.repo.ui.config('tortoisehg', 'cipushafter')
        if pushafter:
            cmd = ['push', hglib.tounicode(pushafter)]
            commandlines.append(cmd)
        self._cmdlog.show()
        sess = self._repoagent.runCommandSequence(commandlines, self)
        self._cmdsession = sess
        sess.commandFinished.connect(self.onCommandFinished)
        sess.outputReceived.connect(self._cmdlog.appendLog)
        return False
Ejemplo n.º 9
0
    def _composeCommand(self):
        opts = {
            'noupdate': self.noupdate_chk.isChecked(),
            'uncompressed': self.uncomp_chk.isChecked(),
            'pull': self.pproto_chk.isChecked(),
            'verbose': True,
            }
        if (self.ui.config('http_proxy', 'host')
            and not self.proxy_chk.isChecked()):
            opts['config'] = 'http_proxy.host='
        if self.remote_chk.isChecked():
            opts['remotecmd'] = unicode(self.remote_text.text()).strip() or None
        if self.rev_chk.isChecked():
            opts['rev'] = unicode(self.rev_text.text()).strip() or None
        if self.startrev_chk.isChecked():
            opts['startrev'] = (unicode(self.startrev_text.text()).strip()
                                or None)

        src = self.source()
        dest = self.destination()
        if src.startswith('https://'):
            opts['insecure'] = self.insecure_chk.isChecked()

        if self.qclone_chk.isChecked():
            name = 'qclone'
            opts['patches'] = unicode(self.qclone_txt.text()).strip() or None
        else:
            name = 'clone'

        cmdline = hglib.buildcmdargs(name, src, dest or None, **opts)
        self.hgcmd_txt.setText('hg ' + hglib.prettifycmdline(cmdline))
        self.commandChanged.emit()
        return cmdline
Ejemplo n.º 10
0
 def accept(self):
     cmdopts = {}
     if hasattr(self, 'chk'):
         if self.command == 'revert':
             cmdopts['no_backup'] = self.chk.isChecked()
         elif self.command == 'remove':
             cmdopts['force'] = self.chk.isChecked()
     files = self.stwidget.getChecked()
     if not files:
         qtlib.WarningMsgBox(_('No files selected'),
                             _('No operation to perform'),
                             parent=self)
         return
     self.repo.bfstatus = True
     self.repo.lfstatus = True
     repostate = self.repo.status()
     self.repo.bfstatus = False
     self.repo.lfstatus = False
     if self.command == 'remove':
         if not self.chk.isChecked():
             modified = repostate[0]
             selmodified = []
             for wfile in files:
                 if wfile in modified:
                     selmodified.append(wfile)
             if selmodified:
                 prompt = qtlib.CustomPrompt(
                     _('Confirm Remove'),
                     _('You have selected one or more files that have been '
                       'modified.  By default, these files will not be '
                       'removed.  What would you like to do?'),
                     self,
                     (_('Remove &Unmodified Files'),
                      _('Remove &All Selected Files'),
                      _('Cancel')),
                     0, 2, selmodified)
                 ret = prompt.run()
                 if ret == 1:
                     cmdopts['force'] = True
                 elif ret == 2:
                     return
         unknown, ignored = repostate[4:6]
         for wfile in files:
             if wfile in unknown or wfile in ignored:
                 try:
                     util.unlink(wfile)
                 except EnvironmentError:
                     pass
                 files.remove(wfile)
     elif self.command == 'add':
         if 'largefiles' in self.repo.extensions():
             self.addWithPrompt(files)
             return
     if files:
         cmdline = hglib.buildcmdargs(self.command, *files, **cmdopts)
         self.files = files
         self.cmd.run(cmdline)
     else:
         self.reject()
Ejemplo n.º 11
0
 def _sync(self, cmdname, selected, finishmsg):
     if not selected:
         return
     self._finishmsg = finishmsg % ', '.join(selected)
     cmdline = hglib.buildcmdargs(cmdname, self._syncurl, bookmark=selected)
     self._cmdsession = sess = self._repoagent.runCommand(cmdline, self)
     sess.commandFinished.connect(self._onBoomarkHandlingFinished)
     self._updateActions()
Ejemplo n.º 12
0
 def _updateRevset(self):
     self._querysess.abort()
     self._querylater.stop()
     cmdline = hglib.buildcmdargs('log', rev=self.revset(), T='{rev}\n')
     self._querysess = sess = self._repoagent.runCommand(cmdline, self)
     sess.setCaptureOutput(True)
     sess.commandFinished.connect(self._onQueryFinished)
     self.commandChanged.emit()
Ejemplo n.º 13
0
 def _buildCommand(self):
     cfgs = []
     if self._add_files_chk.isChecked():
         cfgs.append('hooks.post-init.thgskel='
                     'python:tortoisehg.util.hgcommands.postinitskel')
     if self._make_pre_1_7_chk.isChecked():
         cfgs.append('format.dotencode=False')
     return hglib.buildcmdargs('init', self.destination(), config=cfgs)
Ejemplo n.º 14
0
 def abort(self):
     self.abortbtn.setDisabled(True)
     if os.path.exists(self._graftstatefile):
         # Remove the existing graftstate file!
         os.remove(self._graftstatefile)
     cmdline = hglib.buildcmdargs('update', clean=True, rev='p1()')
     sess = self._runCommand(cmdline)
     sess.commandFinished.connect(self._abortFinished)
Ejemplo n.º 15
0
 def _runWorkingFileCommand(self, cmdname, fds, opts=None):
     if not opts:
         opts = {}
     paths = [hglib.escapepath(fd.filePath()) for fd in fds]
     cmdline = hglib.buildcmdargs(cmdname, *paths, **opts)
     sess = self._runCommand(cmdline)
     sess.commandFinished.connect(self._notifyChangesOnCommandFinished)
     return sess
Ejemplo n.º 16
0
 def _runCommand(self, name, args, opts, finishslot=None):
     assert self._repoagent
     if not self._cmdsession.isFinished():
         return cmdcore.nullCmdSession()
     cmdline = hglib.buildcmdargs(name, *args, **opts)
     self._cmdsession = sess = self._repoagent.runCommand(cmdline, self)
     sess.commandFinished.connect(finishslot or self._onCommandFinished)
     return sess
Ejemplo n.º 17
0
 def accept(self):
     rev = self.revcombo.itemData(self.revcombo.currentIndex()).toString()
     if self.allchk.isChecked():
         if not qtlib.QuestionMsgBox(_('Confirm Revert'),
                  _('Reverting all files will discard changes and '
                    'leave affected files in a modified state.<br>'
                    '<br>Are you sure you want to use revert?<br><br>'
                    '(use update to checkout another revision)'),
                    parent=self):
             return
         cmdline = hglib.buildcmdargs('revert', all=True, rev=rev)
     else:
         files = map(hglib.tounicode, self.wfiles)
         cmdline = hglib.buildcmdargs('revert', rev=rev, *files)
     self.bbox.button(QDialogButtonBox.Ok).setEnabled(False)
     self._cmdsession = sess = self._repoagent.runCommand(cmdline, self)
     sess.commandFinished.connect(self._onCommandFinished)
Ejemplo n.º 18
0
    def _runCommand(self, files, lfiles, opts):
        cmdlines = []
        if files:
            cmdlines.append(hglib.buildcmdargs(self.command, *files, **opts))
        if lfiles:
            assert self.command == 'add'
            lopts = opts.copy()
            lopts['large'] = True
            cmdlines.append(hglib.buildcmdargs(self.command, *lfiles, **lopts))
        self.files = files + lfiles

        ucmdlines = [map(hglib.tounicode, xs) for xs in cmdlines]
        self._cmdsession = sess = self._repoagent.runCommandSequence(ucmdlines,
                                                                     self)
        sess.commandFinished.connect(self.commandFinished)
        sess.progressReceived.connect(self.statusbar.setProgress)
        self._cmddialog.setSession(sess)
        self.bb.button(QDialogButtonBox.Ok).setEnabled(False)
Ejemplo n.º 19
0
    def _runTag(self, tagname, **opts):
        if not self._cmdsession.isFinished():
            self.set_status(_('Repository command still running'), False)
            return

        self._finishmsg = opts.pop('finishmsg')
        cmdline = hglib.buildcmdargs('tag', tagname, **opts)
        self._cmdsession = sess = self._repoagent.runCommand(cmdline, self)
        sess.commandFinished.connect(self._onTagFinished)
Ejemplo n.º 20
0
 def accept(self):
     opts = self._patchbombopts()
     cmdline = hglib.buildcmdargs('email', **opts)
     cmd = cmdui.CmdSessionDialog(self)
     cmd.setWindowTitle(_('Sending Email'))
     cmd.setLogVisible(False)
     uih = cmdui.PasswordUiHandler(cmd)  # skip "intro" and "diffstat" prompt
     cmd.setSession(self._repoagent.runCommand(cmdline, uih))
     if cmd.exec_() == 0:
         self._writehistory()
Ejemplo n.º 21
0
    def remove_outgoing(self):
        selected = self.selectedOutgoingBookmarks()
        if not selected:
            return

        self._finishmsg = _('Removed local bookmark: %s') % ', '.join(selected)

        cmdline = hglib.buildcmdargs('bookmark', *selected, delete=True)
        self._cmdsession = sess = self._repoagent.runCommand(cmdline, self)
        sess.commandFinished.connect(self._onBoomarkHandlingFinished)
        self._updateActions()
Ejemplo n.º 22
0
    def _refreshpreviewtab(self, index):
        """Generate preview text if current tab is preview"""
        if self._previewtabindex() != index:
            return

        self._qui.preview_edit.clear()
        opts = self._patchbombopts(test=True)
        cmdline = hglib.buildcmdargs('email', **opts)
        self._cmdsession = sess = self._repoagent.runCommand(cmdline)
        sess.setCaptureOutput(True)
        sess.commandFinished.connect(self._updatepreview)
Ejemplo n.º 23
0
 def currentPage(self):
     if self._parentbackout:
         self.wizard().next()
         return
     tool = self.field('autoresolve').toBool() and ':merge' or ':fail'
     cmdline = hglib.buildcmdargs('backout', self._backoutrev, tool=tool,
                                  no_commit=True)
     self._cmdlog.clearLog()
     sess = self._repoagent.runCommand(cmdline, self)
     sess.commandFinished.connect(self.onCommandFinished)
     sess.outputReceived.connect(self._cmdlog.appendLog)
Ejemplo n.º 24
0
    def _commitQueue(self):
        assert self._repoagent
        repo = self._repoagent.rawRepo()
        if os.path.isdir(repo.mq.join('.hg')):
            self._launchCommitDialog()
            return
        if not self._cmdsession.isFinished():
            return

        cmdline = hglib.buildcmdargs('init', mq=True)
        self._cmdsession = sess = self._repoagent.runCommand(cmdline, self)
        sess.commandFinished.connect(self._onQueueRepoInitialized)
        self._updateActions()
Ejemplo n.º 25
0
    def validatePage(self):
        if self.commitComplete:
            # commit succeeded, repositoryChanged() called wizard().next()
            if self.field('skiplast').toBool():
                self.wizard().close()
            return True
        if not self._cmdsession.isFinished():
            return False

        user = hglib.tounicode(qtlib.getCurrentUsername(self, self.repo))
        if not user:
            return False

        if self._parentbackout:
            self.setTitle(_('Backing out and committing...'))
            self.setSubTitle(_('Please wait while making backout.'))
            message = unicode(self.msgEntry.text())
            cmdline = hglib.buildcmdargs('backout', self._backoutrev,
                                         verbose=True,
                                         message=message, user=user)
        else:
            self.setTitle(_('Committing...'))
            self.setSubTitle(_('Please wait while committing merged files.'))
            message = unicode(self.msgEntry.text())
            cmdline = hglib.buildcmdargs('commit', verbose=True,
                                         message=message, user=user)
        commandlines = [cmdline]
        pushafter = self.repo.ui.config('tortoisehg', 'cipushafter')
        if pushafter:
            cmd = ['push', hglib.tounicode(pushafter)]
            commandlines.append(cmd)

        self._cmdlog.show()
        sess = self._repoagent.runCommandSequence(commandlines, self)
        self._cmdsession = sess
        sess.commandFinished.connect(self.onCommandFinished)
        sess.outputReceived.connect(self._cmdlog.appendLog)
        return False
Ejemplo n.º 26
0
    def accept(self):
        hglib.loadextension(self._ui, "patchbomb")

        opts = self._patchbombopts()
        try:
            cmd = cmdui.Dialog(hglib.buildcmdargs("email", **opts), parent=self)
            cmd.setWindowTitle(_("Sending Email"))
            cmd.setShowOutput(False)
            cmd.finished.connect(cmd.deleteLater)
            if cmd.exec_():
                self._writehistory()
        finally:
            if "desc" in opts:
                os.unlink(opts["desc"])  # TODO: don't use tempfile
Ejemplo n.º 27
0
 def graft(self):
     self.graftbtn.setEnabled(False)
     self.cancelbtn.setVisible(False)
     opts = dict((n, w.isChecked()) for n, w in self._optchks.iteritems())
     itool = opts.pop('autoresolve') and 'merge' or 'fail'
     opts['config'] = 'ui.merge=internal:%s' % itool
     if os.path.exists(self._graftstatefile):
         opts['continue'] = True
         args = []
     else:
         args = [hglib.tounicode(str(s)) for s in self.sourcelist]
     cmdline = hglib.buildcmdargs('graft', *args, **opts)
     sess = self._runCommand(cmdline)
     sess.commandFinished.connect(self._graftFinished)
Ejemplo n.º 28
0
    def _runQqueueInactive(self, op, name):
        """Execute qqueue operation after inactivating the specified queue"""
        assert self._repoagent
        if not self._cmdsession.isFinished():
            return cmdcore.nullCmdSession()

        if name != self._activeName():
            return self._runQqueue(op, name)

        sacrifices = [n for n in self._existingNames() if n != name]
        if not sacrifices:
            return self._runQqueue(op, name)  # will exit with error

        opts = {}
        if op:
            opts[op] = True
        cmdlines = [hglib.buildcmdargs('qqueue', sacrifices[0]),
                    hglib.buildcmdargs('qqueue', name, **opts)]
        self._cmdsession = sess = self._repoagent.runCommandSequence(cmdlines,
                                                                     self)
        sess.commandFinished.connect(self._onCommandFinished)
        self._updateActions()
        return sess
Ejemplo n.º 29
0
 def _addFileWithPrompt(self, fds):
     repo = self._repoAgentFor(fds[0]).rawRepo()
     result = lfprompt.promptForLfiles(self.parent(), repo.ui, repo,
                                       _lcanonpaths(fds))
     if not result:
         return
     cmdlines = []
     for opt, paths in zip(('normal', 'large'), result):
         if not paths:
             continue
         paths = [hglib.escapepath(hglib.tounicode(e)) for e in paths]
         cmdlines.append(hglib.buildcmdargs('add', *paths, **{opt: True}))
     sess = self._runCommandSequence(cmdlines)
     sess.commandFinished.connect(self._notifyChangesOnCommandFinished)
Ejemplo n.º 30
0
    def _runQqueue(self, op, name):
        """Execute qqueue operation against the specified queue"""
        assert self._repoagent
        if not self._cmdsession.isFinished():
            return cmdcore.nullCmdSession()

        opts = {}
        if op:
            opts[op] = True
        cmdline = hglib.buildcmdargs('qqueue', name, **opts)
        self._cmdsession = sess = self._repoagent.runCommand(cmdline, self)
        sess.commandFinished.connect(self._onCommandFinished)
        self._updateActions()
        return sess
Ejemplo n.º 31
0
    def accept(self):
        hglib.loadextension(self._ui, 'patchbomb')

        opts = self._patchbombopts()
        try:
            cmd = cmdui.Dialog(hglib.buildcmdargs('email', **opts),
                               parent=self)
            cmd.setWindowTitle(_('Sending Email'))
            cmd.setShowOutput(False)
            cmd.finished.connect(cmd.deleteLater)
            if cmd.exec_():
                self._writehistory()
        finally:
            if 'desc' in opts:
                os.unlink(opts['desc'])  # TODO: don't use tempfile
Ejemplo n.º 32
0
 def _bisectcmd(self, *args, **opts):
     opts['repository'] = self.repo.root
     return hglib.buildcmdargs('bisect', *args, **opts)