def __init__(self, paths): Command.__init__(self) browser = utils.shell_split(prefs.history_browser()) if paths: self.argv = browser + paths else: self.argv = browser
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))
def apply_filter(self): text = self.text.value() if text == self._filter: return self._filter = text paths = utils.shell_split(text) self.main_model.update_path_filter(paths)
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)
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)
def __init__(self, paths): Command.__init__(self) browser = utils.shell_split(prefs.history_browser()) if paths: self.argv = browser + list(paths) else: self.argv = browser
def next(self): if self._cached: try: self._idx += 1 return self._topo_list[self._idx] except IndexError: self._idx = -1 raise StopIteration if self._proc is None: ref_args = utils.shell_split(self.dag.ref) cmd = self._cmd + ['-%d' % self.dag.count] + ref_args self._proc = utils.start_command(cmd) self._topo_list = [] log_entry = self._proc.stdout.readline().rstrip() if not log_entry: del self._proc self._cached = True self._proc = None raise StopIteration sha1 = log_entry[:40] try: return self._objects[sha1] except KeyError: c = CommitFactory.new(log_entry=log_entry) self._objects[c.sha1] = c self._topo_list.append(c) return c
def do(self): filename = self.filenames[0] if not os.path.exists(filename): return editor = self.model.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 utils.fork(utils.shell_split(editor) + opts)
def paths(self): all_refs = utils.shell_split(self.ref) if '--' in all_refs: all_refs = all_refs[all_refs.index('--'):] return [p for p in all_refs if p and os.path.exists(core.encode(p))]
def next(self): if self._cached: try: self._idx += 1 return self._topo_list[self._idx] except IndexError: self._idx = -1 raise StopIteration if self._proc is None: ref_args = utils.shell_split(self.dag.ref) cmd = self._cmd + ['-%d' % self.dag.count] + ref_args self._proc = utils.start_command(cmd) self._topo_list = [] log_entry = core.readline(self._proc.stdout).rstrip() if not log_entry: del self._proc self._cached = True self._proc = None raise StopIteration sha1 = log_entry[:40] try: return self._objects[sha1] except KeyError: c = CommitFactory.new(log_entry=log_entry) self._objects[c.sha1] = c self._topo_list.append(c) return c
def do(self): if not self.filenames: return filename = self.filenames[0] if not os.path.exists(filename): return editor = self.model.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 utils.fork(utils.shell_split(editor) + opts)
def __init__(self, paths): Command.__init__(self) browser = utils.shell_split(self.model.history_browser()) if paths: self.argv = browser + paths else: self.argv = browser
def refresh(self): if self.expr is not None: self.diff_arg = utils.shell_split(self.expr) elif self.b is None: self.diff_arg = [self.a] else: self.diff_arg = [self.a, self.b] self.refresh_filenames()
def do(self): argv = utils.shell_split(self.model.history_browser()) if self.revision: argv.append(self.revision) if self.paths: argv.append('--') argv.extend(self.paths) utils.fork(argv)
def do(self): argv = utils.shell_split(prefs.history_browser()) if self.revision: argv.append(self.revision) if self.paths: argv.append('--') argv.extend(self.paths) launch_history_browser(argv)
def __init__(self, parent, a=None, b=None, expr=None): super(FileDiffDialog, self).__init__(parent) self.setAttribute(Qt.WA_MacMetalStyle) self.a = a self.b = b self.expr = expr self.setWindowTitle('Select File(s)') self.setWindowModality(QtCore.Qt.WindowModal) self._tree = standard.TreeWidget(self) self._tree.setRootIsDecorated(False) self._tree.setSelectionMode(self._tree.ExtendedSelection) self._tree.setHeaderHidden(True) self._diff_btn = QtGui.QPushButton('Compare') self._diff_btn.setIcon(qtutils.ok_icon()) self._diff_btn.setEnabled(False) self._close_btn = QtGui.QPushButton('Close') self._close_btn.setIcon(qtutils.close_icon()) self._button_layt = QtGui.QHBoxLayout() self._button_layt.setMargin(0) self._button_layt.addStretch() self._button_layt.addWidget(self._diff_btn) self._button_layt.addWidget(self._close_btn) self._layt = QtGui.QVBoxLayout() self._layt.setMargin(defs.margin) self._layt.setSpacing(defs.spacing) self._layt.addWidget(self._tree) self._layt.addLayout(self._button_layt) self.setLayout(self._layt) qtutils.add_close_action(self) self.connect(self._tree, SIGNAL('itemSelectionChanged()'), self._tree_selection_changed) self.connect(self._tree, SIGNAL('itemDoubleClicked(QTreeWidgetItem*,int)'), self._tree_double_clicked) self.connect(self._diff_btn, SIGNAL('clicked()'), self.diff) self.connect(self._close_btn, SIGNAL('clicked()'), self.close) if self.expr: self.diff_arg = tuple(utils.shell_split(self.expr)) elif self.b is None: self.diff_arg = (self.a,) else: self.diff_arg = (self.a, self.b) self.resize(720, 420)
def __init__(self, parent, a=None, b=None, expr=None): QtGui.QDialog.__init__(self, parent) self.setAttribute(Qt.WA_MacMetalStyle) self.a = a self.b = b self.expr = expr self.setWindowTitle('Select File(s)') self.setWindowModality(QtCore.Qt.WindowModal) self._tree = standard.TreeWidget(self) self._tree.setRootIsDecorated(False) self._tree.setSelectionMode(self._tree.ExtendedSelection) self._tree.setHeaderHidden(True) self._diff_btn = QtGui.QPushButton('Compare') self._diff_btn.setIcon(qtutils.ok_icon()) self._diff_btn.setEnabled(False) self._close_btn = QtGui.QPushButton('Close') self._close_btn.setIcon(qtutils.close_icon()) self._button_layt = QtGui.QHBoxLayout() self._button_layt.setMargin(0) self._button_layt.addStretch() self._button_layt.addWidget(self._diff_btn) self._button_layt.addWidget(self._close_btn) self._layt = QtGui.QVBoxLayout() self._layt.setMargin(defs.margin) self._layt.setSpacing(defs.spacing) self._layt.addWidget(self._tree) self._layt.addLayout(self._button_layt) self.setLayout(self._layt) self.connect(self._tree, SIGNAL('itemSelectionChanged()'), self._tree_selection_changed) self.connect(self._tree, SIGNAL('itemDoubleClicked(QTreeWidgetItem*,int)'), self._tree_double_clicked) qtutils.connect_button(self._diff_btn, self.diff) qtutils.connect_button(self._close_btn, self.close) qtutils.add_close_action(self) if self.expr: self.diff_arg = tuple(utils.shell_split(self.expr)) elif self.b is None: self.diff_arg = (self.a,) else: self.diff_arg = (self.a, self.b) self.resize(720, 420)
def run(self): query = self.query if query is None: args = [] else: args = [add_wildcards(arg) for arg in utils.shell_split(query)] filenames = gitcmds.tracked_files(*args) if query == self.query: self.emit(SIGNAL('result(PyQt_PyObject)'), filenames) else: self.run()
def diff_helper(commit=None, ref=None, endref=None, filename=None, cached=True, head=None, amending=False, with_diff_header=False, suppress_header=True, reverse=False, git=git): "Invokes git diff on a filepath." encode = core.encode if commit: ref, endref = commit + '^', commit argv = [] if ref and endref: argv.append('%s..%s' % (ref, endref)) elif ref: for r in utils.shell_split(ref.strip()): argv.append(r) elif head and amending and cached: argv.append(head) encoding = None if filename: argv.append('--') if type(filename) is list: argv.extend(filename) else: argv.append(filename) encoding = config.file_encoding(filename) if filename is not None: deleted = cached and not os.path.exists(encode(filename)) else: deleted = False status, diffoutput = git.diff(R=reverse, M=True, cached=cached, with_status=True, *argv, **_common_diff_opts()) if status != 0: # git init if with_diff_header: return ('', '') else: return '' return extract_diff_header(status, deleted, encoding, with_diff_header, suppress_header, diffoutput)
def run(self): if self.query is None: return query = self.query if self.shell: args = utils.shell_split(query) else: args = [query] status, out, err = git.grep(self.regexp_mode, n=True, *args) if query == self.query: self.emit(SIGNAL('result'), status, out, err) else: self.run()
def diff_helper(commit=None, ref=None, endref=None, filename=None, cached=True, head=None, amending=False, with_diff_header=False, suppress_header=True, reverse=False, git=git): "Invokes git diff on a filepath." encode = core.encode if commit: ref, endref = commit+'^', commit argv = [] if ref and endref: argv.append('%s..%s' % (ref, endref)) elif ref: for r in utils.shell_split(ref.strip()): argv.append(r) elif head and amending and cached: argv.append(head) encoding = None if filename: argv.append('--') if type(filename) is list: argv.extend(filename) else: argv.append(filename) encoding = config.file_encoding(filename) if filename is not None: deleted = cached and not os.path.exists(encode(filename)) else: deleted = False status, diffoutput = git.diff(R=reverse, M=True, cached=cached, with_status=True, *argv, **_common_diff_opts()) if status != 0: # git init if with_diff_header: return ('', '') else: return '' return extract_diff_header(status, deleted, encoding, with_diff_header, suppress_header, diffoutput)
def do(self): s = selection.selection() if s.unmerged: paths = s.unmerged if utils.is_win32(): core.fork(['git', 'mergetool', '--no-prompt', '--'] + paths) else: cmd = _config.terminal() argv = utils.shell_split(cmd) argv.extend(['git', 'mergetool', '--no-prompt', '--']) argv.extend(paths) core.fork(argv) else: difftool.run()
def run(self): if self.query is None: return query = self.query if self.shell: args = utils.shell_split(query) else: args = [query] status, out, err = git.grep(self.regexp_mode, n=True, *args) if query == self.query: worker_signal = 'result(PyQt_PyObject,PyQt_PyObject,PyQt_PyObject)' self.emit(SIGNAL(worker_signal), status, out, err) else: self.run()
def run(self): if self.txt is None: return query = self.txt if self.shell: args = utils.shell_split(query) else: args = [query] status, out = git.grep(with_status=True, with_stderr=True, n=True, *args) if query == self.txt: self.emit(SIGNAL("result"), status, core.decode(out)) else: self.run()
def diff_helper(commit=None, ref=None, endref=None, filename=None, cached=True, deleted=False, head=None, amending=False, with_diff_header=False, suppress_header=True, reverse=False, git=git): "Invokes git diff on a filepath." if commit: ref, endref = commit + '^', commit argv = [] if ref and endref: argv.append('%s..%s' % (ref, endref)) elif ref: for r in utils.shell_split(ref.strip()): argv.append(r) elif head and amending and cached: argv.append(head) encoding = None if filename: argv.append('--') if type(filename) is list: argv.extend(filename) else: argv.append(filename) cfg = gitcfg.current() encoding = cfg.file_encoding(filename) status, out, err = git.diff(R=reverse, M=True, cached=cached, _encoding=encoding, *argv, **common_diff_opts()) if status != 0: # git init if with_diff_header: return ('', '') else: return '' return extract_diff_header(status, deleted, with_diff_header, suppress_header, out)
def run(self): if self.txt is None: return query = self.txt if self.shell: args = utils.shell_split(query) else: args = [query] status, out = git.grep(with_status=True, with_stderr=True, n=True, *args) if query == self.txt: self.emit(SIGNAL('result'), status, core.decode(out)) else: self.run()
def do(self): s = selection.selection() if s.unmerged: paths = s.unmerged if utils.is_win32(): core.fork(["git", "mergetool", "--no-prompt", "--"] + paths) else: cfg = gitcfg.current() cmd = cfg.terminal() argv = utils.shell_split(cmd) argv.extend(["git", "mergetool", "--no-prompt", "--"]) argv.extend(paths) core.fork(argv) else: difftool.run()
def diff_helper( commit=None, ref=None, endref=None, filename=None, cached=True, head=None, amending=False, with_diff_header=False, suppress_header=True, reverse=False, git=git, ): "Invokes git diff on a filepath." if commit: ref, endref = commit + "^", commit argv = [] if ref and endref: argv.append("%s..%s" % (ref, endref)) elif ref: for r in utils.shell_split(ref.strip()): argv.append(r) elif head and amending and cached: argv.append(head) encoding = None if filename: argv.append("--") if type(filename) is list: argv.extend(filename) else: argv.append(filename) encoding = config.file_encoding(filename) if filename is not None: deleted = cached and not core.exists(filename) else: deleted = False status, out, err = git.diff(R=reverse, M=True, cached=cached, _encoding=encoding, *argv, **common_diff_opts()) if status != 0: # git init if with_diff_header: return ("", "") else: return "" return extract_diff_header(status, deleted, with_diff_header, suppress_header, out)
def do(self): argv = utils.shell_split(prefs.history_browser()) if self.revision: argv.append(self.revision) if self.paths: argv.append('--') argv.extend(self.paths) try: core.fork(argv) except Exception as e: _, details = utils.format_exception(e) title = N_('Error Launching History Browser') msg = (N_('Cannot exec "%s": please configure a history browser') % ' '.join(argv)) Interaction.critical(title, message=msg, details=details)
def diff_helper(commit=None, ref=None, endref=None, filename=None, cached=True, deleted=False, head=None, amending=False, with_diff_header=False, suppress_header=True, reverse=False, git=git): "Invokes git diff on a filepath." if commit: ref, endref = commit+'^', commit argv = [] if ref and endref: argv.append('%s..%s' % (ref, endref)) elif ref: for r in utils.shell_split(ref.strip()): argv.append(r) elif head and amending and cached: argv.append(head) encoding = None if filename: argv.append('--') if type(filename) is list: argv.extend(filename) else: argv.append(filename) cfg = gitcfg.current() encoding = cfg.file_encoding(filename) status, out, err = git.diff(R=reverse, M=True, cached=cached, _encoding=encoding, *argv, **common_diff_opts()) if status != 0: # git init if with_diff_header: return ('', '') else: return '' return extract_diff_header(status, deleted, with_diff_header, suppress_header, out)
def apply_filter(self): text = self.text.value() paths = utils.shell_split(text) self.main_model.update_path_filter(paths)
def do(self): browser = utils.shell_split(prefs.history_browser()) core.fork(browser + [self.model.currentbranch])
def do(self): browser = utils.shell_split(prefs.history_browser()) core.fork(browser + ['--all'])
def do(self): cfg = gitcfg.current() cmd = cfg.terminal() argv = utils.shell_split(cmd) argv.append(os.getenv('SHELL', '/bin/sh')) core.fork(argv, cwd=self.path)
def _words(self): return utils.shell_split(self.value())
def do(self): cmd = _config.get('cola.terminal', 'xterm -e $SHELL') cmd = os.path.expandvars(cmd) argv = utils.shell_split(cmd) core.fork(argv, cwd=self.path)
def do(self): browser = utils.shell_split(prefs.history_browser()) launch_history_browser(browser + [self.model.currentbranch])
def do(self): browser = utils.shell_split(prefs.history_browser()) launch_history_browser(browser + ['--all'])
def results(self): query, opts = self.common_args() args = utils.shell_split(query) return self.revisions(all=True, *args, **opts)
def do(self): browser = utils.shell_split(self.model.history_browser()) utils.fork(browser + ['--all'])
def _words(self): return utils.shell_split(ustr(self.text()))
def results(self): query, args = self.common_args() paths = ['--'] + utils.shell_split(query) return self.revisions(all=True, *paths, **args)
def do(self): browser = utils.shell_split(self.model.history_browser()) utils.fork(browser + [self.model.currentbranch])
def do(self): cmd = _config.terminal() argv = utils.shell_split(cmd) argv.append(os.getenv('SHELL', '/bin/sh')) core.fork(argv, cwd=self.path)