Exemple #1
0
    def runAction(self):
        "run wrapper for all action methods"

        repo, action, parent = self.repo, self.sender(), self.parent()
        func = action._runfunc
        files = [wfile for t, wfile in self.selrows if t & action._filetypes]

        hu = htmlui.htmlui()
        name = hglib.tounicode(func.__name__.title())
        notify = False
        cwd = os.getcwd()
        try:
            os.chdir(repo.root)
            try:
                # All operations should quietly succeed.  Any error should
                # result in a message box
                notify = func(parent, hu, repo, files)
                o, e = hu.getdata()
                if e:
                    QMessageBox.warning(parent, name + _(" errors"), e)
                elif o:
                    QMessageBox.information(parent, name + _(" output"), o)
                elif notify:
                    wfiles = [repo.wjoin(x) for x in files]
                    shlib.shell_notify(wfiles)
            except (IOError, OSError), e:
                err = hglib.tounicode(str(e))
                QMessageBox.critical(parent, name + _(" Aborted"), err)
            except util.Abort, e:
                if e.hint:
                    err = _("%s (hint: %s)") % (hglib.tounicode(str(e)), hglib.tounicode(e.hint))
                else:
                    err = hglib.tounicode(str(e))
                QMessageBox.critical(parent, name + _(" Aborted"), err)
Exemple #2
0
 def showDiff(self, index):
     'User selected a row in the candidate tree'
     indexes = index.indexes()
     if not indexes:
         return
     index = indexes[0]
     ctx = self.repo['.']
     hu = htmlui.htmlui()
     row = self.matchtv.model().getRow(index)
     src, dest, percent = self.matchtv.model().getRow(index)
     aa = self.repo.wread(dest)
     rr = ctx.filectx(src).data()
     date = hglib.displaytime(ctx.date())
     difftext = mdiff.unidiff(rr, date, aa, date, src, dest, None)
     if not difftext:
         t = _('%s and %s have identical contents\n\n') % \
                 (hglib.tounicode(src), hglib.tounicode(dest))
         hu.write(t, label='ui.error')
     else:
         for t, l in patch.difflabel(difftext.splitlines, True):
             hu.write(t, label=l)
     self.difftb.setHtml(hu.getdata()[0])
Exemple #3
0
 def showDiff(self, index):
     'User selected a row in the candidate tree'
     indexes = index.indexes()
     if not indexes:
         return
     index = indexes[0]
     ctx = self.repo['.']
     hu = htmlui.htmlui()
     row = self.matchtv.model().getRow(index)
     src, dest, percent = self.matchtv.model().getRow(index)
     aa = self.repo.wread(dest)
     rr = ctx.filectx(src).data()
     date = hglib.displaytime(ctx.date())
     difftext = mdiff.unidiff(rr, date, aa, date, src, dest, None)
     if not difftext:
         t = _('%s and %s have identical contents\n\n') % \
                 (hglib.tounicode(src), hglib.tounicode(dest))
         hu.write(t, label='ui.error')
     else:
         for t, l in patch.difflabel(difftext.splitlines, True):
             hu.write(t, label=l)
     self.difftb.setHtml(hu.getdata()[0])
    def runAction(self):
        'run wrapper for all action methods'

        repo, action, parent = self.repo, self.sender(), self.parent()
        func = action._runfunc
        files = [wfile for t, wfile in self.selrows if t & action._filetypes]

        hu = htmlui.htmlui()
        name = hglib.tounicode(func.__name__.title())
        notify = False
        cwd = os.getcwd()
        try:
            os.chdir(repo.root)
            try:
                # All operations should quietly succeed.  Any error should
                # result in a message box
                notify = func(parent, hu, repo, files)
                o, e = hu.getdata()
                if e:
                    QMessageBox.warning(parent, name + _(' errors'),
                                        hglib.tounicode(e))
                elif o:
                    QMessageBox.information(parent, name + _(' output'),
                                            hglib.tounicode(o))
                elif notify:
                    wfiles = [repo.wjoin(x) for x in files]
                    shlib.shell_notify(wfiles)
            except (IOError, OSError), e:
                err = hglib.tounicode(str(e))
                QMessageBox.critical(parent, name + _(' Aborted'), err)
            except util.Abort, e:
                if e.hint:
                    err = _('%s (hint: %s)') % (hglib.tounicode(
                        str(e)), hglib.tounicode(e.hint))
                else:
                    err = hglib.tounicode(str(e))
                QMessageBox.critical(parent, name + _(' Aborted'), err)