Esempio n. 1
0
 def _on_conf_clicked(self, button):
     dlg = ConfigDialog(self.root, False)
     dlg.show_all()
     dlg.focus_field('email.from')
     dlg.run()
     dlg.hide()
     self._refresh(False)
Esempio n. 2
0
    def _hg_commit(self, files):
        if not self.repo.ui.config('ui', 'username'):
            Prompt('Username not configured', 'Please enter a username', self).run()
            from thgconfig import ConfigDialog
            dlg = ConfigDialog(self.repo.root, False)
            dlg.show_all()
            dlg.focus_field('ui.username')
            dlg.run()
            dlg.hide()
            self.repo = hg.repository(ui.ui(), self.repo.root)
            self.ui = self.repo.ui

        # call the threaded CmdDialog to do the commit, so the the large commit
        # won't get locked up by potential large commit. CmdDialog will also
        # display the progress of the commit operation.
        cmdline  = ["hg", "commit", "--verbose", "--repository", self.repo.root]
        if self.opts['addremove']:
            cmdline += ['--addremove']
        cmdline += ['--message', fromutf(self.opts['message'])]
        cmdline += [self.repo.wjoin(x) for x in files]
        dialog = CmdDialog(cmdline, True)
        dialog.set_transient_for(self)
        dialog.run()
        dialog.hide()

        # refresh overlay icons and commit dialog
        if dialog.return_code() == 0:
            self.text.set_buffer(gtk.TextBuffer())
            self._update_recent_messages(self.opts['message'])
            shell_notify([self.cwd] + files)
            self._last_commit_id = self._get_tip_rev(True)
            self.reload_status()
Esempio n. 3
0
 def _on_conf_clicked(self, *args):
     from thgconfig import ConfigDialog
     dlg = ConfigDialog(self._root, True)
     dlg.show_all()
     dlg.focus_field('web.name')
     dlg.run()
     dlg.hide()
     self._get_config()
Esempio n. 4
0
    def _diff_file(self, stat, file):
        def dodiff():
            extdiff.dodiff(self.ui, self.repo, self.diffcmd, [self.diffopts], [self.repo.wjoin(file)], self.opts)

        if self.diffcmd == "diff":
            Prompt("No visual diff configured", "Please select a visual diff application.", self).run()
            dlg = ConfigDialog(self.repo.root, False)
            dlg.show_all()
            dlg.focus_field("tortoisehg.vdiff")
            dlg.run()
            dlg.hide()
            self.ui = ui.ui()
            self._parse_config()
            return
        thread = threading.Thread(target=dodiff, name="diff:" + file)
        thread.setDaemon(True)
        thread.start()
Esempio n. 5
0
 def _conf_clicked(self, toolbutton, data=None):
     newpath = self._pathtext.get_text()
     for name, path in self.paths:
         if path == newpath:
             newpath = None
             break
     from thgconfig import ConfigDialog
     dlg = ConfigDialog(self.root, True)
     dlg.show_all()
     if newpath:
         dlg.new_path(newpath)
     else:
         dlg.focus_field('paths.default')
     dlg.run()
     dlg.hide()
     self.paths = self._get_paths()
     self.pathlist.clear()
     for row, (name, path) in enumerate(self.paths):
         self.pathlist.append([path])
Esempio n. 6
0
    def _view_file(self, stat, file, force_left=False):
        import atexit

        def cleanup():
            shutil.rmtree(self.tmproot)

        if not self.tmproot:
            self.tmproot = tempfile.mkdtemp(prefix="gtools.")
            atexit.register(cleanup)

        def snapshot_node(ui, repo, files, node, tmproot):
            """
            snapshot files as of some revision
            (adapted from Extdiff extension)
            """
            mf = repo.changectx(node).manifest()
            dirname = os.path.basename(repo.root)
            if dirname == "":
                dirname = "root"
            dirname = "%s.%s" % (dirname, short(node))
            base = os.path.join(tmproot, dirname)
            try:
                os.mkdir(base)
            except:
                pass
            ui.note(_("making snapshot of %d files from rev %s\n") % (len(files), short(node)))
            for fn in files:
                if not fn in mf:
                    # skipping new file after a merge ?
                    continue
                wfn = util.pconvert(fn)
                ui.note("  %s\n" % wfn)
                dest = os.path.join(base, wfn)
                destdir = os.path.dirname(dest)
                if not os.path.isdir(destdir):
                    os.makedirs(destdir)
                data = repo.wwritedata(wfn, repo.file(wfn).read(mf[wfn]))
                open(dest, "wb").write(data)
            return dirname

        def doedit():
            pathroot = self.repo.root
            copynode = None
            # if we aren't looking at the wc, copy the node...
            if stat in "R!" or force_left:
                copynode = self._node1
            elif self._node2:
                copynode = self._node2

            if copynode:
                copydir = snapshot_node(self.ui, self.repo, [util.pconvert(file)], copynode, self.tmproot)
                pathroot = os.path.join(self.tmproot, copydir)

            file_path = os.path.join(pathroot, file)
            util.system(
                '%s "%s"' % (editor, file_path),
                environ={"HGUSER": self.ui.username()},
                onerr=util.Abort,
                errprefix=_("edit failed"),
            )

        editor = (
            self.ui.config("tortoisehg", "editor")
            or self.ui.config("gtools", "editor")
            or os.environ.get("HGEDITOR")
            or self.ui.config("ui", "editor")
            or os.environ.get("EDITOR", "vi")
        )
        if os.path.basename(editor) in ("vi", "vim", "hgeditor"):
            Prompt("No visual editor configured", "Please configure a visual editor.", self).run()
            dlg = ConfigDialog(self.repo.root, False)
            dlg.show_all()
            dlg.focus_field("tortoisehg.editor")
            dlg.run()
            dlg.hide()
            self.ui = ui.ui()
            self._parse_config()
            return

        file = util.localpath(file)
        thread = threading.Thread(target=doedit, name="edit:" + file)
        thread.setDaemon(True)
        thread.start()
Esempio n. 7
0
    def _on_send_clicked(self, button):
        def record_new_value(cpath, history, newvalue):
            if not newvalue: return
            if cpath not in history.get_keys():
                history.set_value(cpath, [])
            elif newvalue in history.get_value(cpath):
                history.get_value(cpath).remove(newvalue)
            history.get_value(cpath).insert(0, newvalue)

        totext = self._tobox.child.get_text()
        cctext = self._ccbox.child.get_text()
        fromtext = self._frombox.child.get_text()
        subjtext = self._subjbox.child.get_text()

        if not totext:
            info_dialog(self, 'Info required', 'You must specify a recipient')
            self._tobox.grab_focus()
            return
        if not fromtext:
            info_dialog(self, 'Info required', 'You must specify a sender address')
            self._frombox.grab_focus()
            return
        if not self.repo:
            return

        if self.repo.ui.config('email', 'method', 'smtp') == 'smtp':
            if not self.repo.ui.config('smtp', 'host'):
                info_dialog(self, 'Info required', 'You must configure SMTP')
                dlg = ConfigDialog(self.root, False)
                dlg.show_all()
                dlg.focus_field('smtp.host')
                dlg.run()
                dlg.hide()
                self._refresh(False)
                return

        history = shlib.Settings('config_history')
        record_new_value('email.to', history, totext)
        record_new_value('email.cc', history, cctext)
        record_new_value('email.from', history, fromtext)
        record_new_value('email.subject', history, subjtext)
        history.write()

        cmdline = ['hg', 'email', '-f', fromtext, '-t', totext, '-c', cctext]
        cmdline += ['--repository', self.repo.root]
        if subjtext:
            cmdline += ['--subject', subjtext]
        if self._bundle.get_active():
            cmdline += ['--bundle']
            if '--outgoing' in self.revargs:
                self.revargs.remove('--outgoing')
        elif self._plain.get_active():  cmdline += ['--plain']
        elif self._git.get_active():    cmdline += ['--git']
        start = self.descbuffer.get_start_iter()
        end = self.descbuffer.get_end_iter()
        desc = self.descbuffer.get_text(start, end)
        try:
            fd, tmpfile = mkstemp(prefix="thg_emaildesc_")
            os.write(fd, desc)
            os.close(fd)
            cmdline += ['--desc', tmpfile]
            cmdline.extend(self.revargs)

            dlg = CmdDialog(cmdline)
            dlg.show_all()
            dlg.run()
            dlg.hide()
        finally:
            os.unlink(tmpfile)