Esempio n. 1
0
    def do(self):
        if not self.filenames:
            return
        filename = self.filenames[0]
        if not core.exists(filename):
            return
        editor = prefs.editor()
        opts = []

        if self.line_number is None:
            opts = self.filenames
        else:
            # Single-file w/ line-numbers (likely from grep)
            editor_opts = {
                    '*vim*': ['+'+self.line_number, filename],
                    '*emacs*': ['+'+self.line_number, filename],
                    '*textpad*': ['%s(%s,0)' % (filename, self.line_number)],
                    '*notepad++*': ['-n'+self.line_number, filename],
            }

            opts = self.filenames
            for pattern, opt in editor_opts.items():
                if fnmatch(editor, pattern):
                    opts = opt
                    break

        try:
            core.fork(utils.shell_split(editor) + opts)
        except Exception as e:
            message = (N_('Cannot exec "%s": please configure your editor') %
                       editor)
            Interaction.critical(N_('Error Editing File'),
                                 message, str(e))
Esempio n. 2
0
    def do(self):
        if not self.filenames:
            return
        filename = self.filenames[0]
        if not core.exists(filename):
            return
        editor = prefs.editor()
        opts = []

        if self.line_number is None:
            opts = self.filenames
        else:
            # Single-file w/ line-numbers (likely from grep)
            editor_opts = {
                "*vim*": ["+" + self.line_number, filename],
                "*emacs*": ["+" + self.line_number, filename],
                "*textpad*": ["%s(%s,0)" % (filename, self.line_number)],
                "*notepad++*": ["-n" + self.line_number, filename],
            }

            opts = self.filenames
            for pattern, opt in editor_opts.items():
                if fnmatch(editor, pattern):
                    opts = opt
                    break

        try:
            core.fork(utils.shell_split(editor) + opts)
        except Exception as e:
            message = N_('Cannot exec "%s": please configure your editor') % editor
            details = core.decode(e.strerror)
            Interaction.critical(N_("Error Editing File"), message, details)
Esempio n. 3
0
    def do(self):
        if not self.filenames:
            return
        filename = self.filenames[0]
        if not core.exists(filename):
            return
        editor = prefs.editor()
        opts = []

        if self.line_number is None:
            opts = self.filenames
        else:
            # Single-file w/ line-numbers (likely from grep)
            editor_opts = {
                    '*vim*': ['+'+self.line_number, filename],
                    '*emacs*': ['+'+self.line_number, filename],
                    '*textpad*': ['%s(%s,0)' % (filename, self.line_number)],
                    '*notepad++*': ['-n'+self.line_number, filename],
            }

            opts = self.filenames
            for pattern, opt in editor_opts.items():
                if fnmatch(editor, pattern):
                    opts = opt
                    break

        try:
            core.fork(utils.shell_split(editor) + opts)
        except Exception as e:
            message = (N_('Cannot exec "%s": please configure your editor')
                       % editor)
            details = core.decode(e.strerror)
            Interaction.critical(N_('Error Editing File'), message, details)
Esempio n. 4
0
    def do(self):
        status = 1
        out = ''
        err = ''
        args, kwargs = self.prepare_arguments()
        upstream_title = self.upstream or '@{upstream}'
        with GitXBaseContext(
                GIT_EDITOR=prefs.editor(),
                GIT_XBASE_TITLE=N_('Rebase onto %s') % upstream_title,
                GIT_XBASE_ACTION=N_('Rebase')):
            status, out, err = self.model.git.rebase(*args, **kwargs)

        Interaction.log_status(status, out, err)
        self.model.update_status()
        return status, out, err
Esempio n. 5
0
    def do(self):
        status = 1
        out = ''
        err = ''
        args, kwargs = self.prepare_arguments()
        upstream_title = self.upstream or '@{upstream}'
        with GitXBaseContext(GIT_EDITOR=prefs.editor(),
                             GIT_XBASE_TITLE=N_('Rebase onto %s') %
                             upstream_title,
                             GIT_XBASE_ACTION=N_('Rebase')):
            status, out, err = self.model.git.rebase(*args, **kwargs)

        Interaction.log_status(status, out, err)
        self.model.update_status()
        return status, out, err
Esempio n. 6
0
 def do(self):
     branch = self.branch
     if not branch:
         return
     status = 1
     out = ''
     err = ''
     with GitXBaseContext(GIT_EDITOR=prefs.editor(),
                          GIT_XBASE_TITLE=N_('Rebase onto %s') % branch,
                          GIT_XBASE_ACTION=N_('Rebase')):
         status, out, err = self.model.git.rebase(branch,
                                                  interactive=True,
                                                  autosquash=True)
     Interaction.log_status(status, out, err)
     self.model.update_status()
     return status, out, err
Esempio n. 7
0
 def do(self):
     branch = self.branch
     if not branch:
         return
     status = 1
     out = ''
     err = ''
     with GitXBaseContext(
             GIT_EDITOR=prefs.editor(),
             GIT_XBASE_TITLE=N_('Rebase onto %s') % branch,
             GIT_XBASE_ACTION=N_('Rebase')):
         status, out, err = self.model.git.rebase(branch,
                                                  interactive=True,
                                                  autosquash=True)
     Interaction.log_status(status, out, err)
     self.model.update_status()
     return status, out, err
Esempio n. 8
0
 def do(self):
     branch = self.branch
     if not branch:
         return
     status = 1
     out = ''
     err = ''
     extra = {}
     if self.capture_output:
         extra['_stderr'] = None
         extra['_stdout'] = None
     with GitXBaseContext(GIT_EDITOR=prefs.editor(),
                          GIT_XBASE_TITLE=N_('Rebase onto %s') % branch,
                          GIT_XBASE_ACTION=N_('Rebase')):
         status, out, err = self.model.git.rebase(branch,
                                                  interactive=True,
                                                  autosquash=True,
                                                  **extra)
     Interaction.log_status(status, out, err)
     self.model.update_status()
     return status, out, err
Esempio n. 9
0
 def do(self):
     branch = self.branch
     if not branch:
         return
     status = 1
     out = ''
     err = ''
     extra = {}
     if self.capture_output:
         extra['_stderr'] = None
         extra['_stdout'] = None
     with GitXBaseContext(
             GIT_EDITOR=prefs.editor(),
             GIT_XBASE_TITLE=N_('Rebase onto %s') % branch,
             GIT_XBASE_ACTION=N_('Rebase')):
         status, out, err = self.model.git.rebase(branch,
                                                  interactive=True,
                                                  autosquash=True,
                                                  **extra)
     Interaction.log_status(status, out, err)
     self.model.update_status()
     return status, out, err
Esempio n. 10
0
 def __init__(self, **kwargs):
     self.env = {'GIT_EDITOR': prefs.editor()}
     self.env.update(kwargs)
Esempio n. 11
0
 def __init__(self, **kwargs):
     self.env = {'GIT_EDITOR': prefs.editor()}
     self.env.update(kwargs)