def mergetools(self): seen, installed = [], [] for key, value in self.ui.configitems('merge-tools'): t = key.split('.')[0] if t not in seen: seen.append(t) if filemerge._findtool(self.ui, t): installed.append(t) return installed
def _refresh_vlist(self): for vbox, info, widgets in self.pages: for row, (label, cpath, values, tooltip) in enumerate(info): combo = widgets[row] vlist = combo.get_model() vlist.clear() # Get currently configured value from this config file curvalue = self.get_ini_config(cpath) if cpath == 'tortoisehg.vdiff': # Special case, add extdiff.cmd.* to possible values for name, value in self.ui.configitems('extdiff'): if name.startswith('cmd.') and name[4:] not in values: values.append(name[4:]) elif cpath == 'ui.merge': # Special case, add [merge-tools] to possible values try: from mercurial import filemerge tools = [] for key, value in self.ui.configitems('merge-tools'): t = key.split('.')[0] if t not in tools: tools.append(t) for t in tools: # Ensure the tool is installed if filemerge._findtool(self.ui, t): values.append(t) except ImportError: pass currow = None vlist.append([_unspecstr, False]) if values: vlist.append(['Suggested', True]) for v in values: vlist.append([v, False]) if v == curvalue: currow = len(vlist) - 1 if cpath in self.history.get_keys(): separator = False for v in self.history.mrul(cpath): if v in values: continue if not separator: vlist.append(['History', True]) separator = True vlist.append([v, False]) if v == curvalue: currow = len(vlist) - 1 if curvalue is None: combo.set_active(0) elif currow is None: combo.child.set_text(curvalue) else: combo.set_active(currow)
def resolve_with(stat, tool, files): if tool: exe = filemerge._findtool(self.repo.ui, tool) oldmergeenv = os.environ.get('HGMERGE') os.environ['HGMERGE'] = exe resolve(stat, files) if tool: if oldmergeenv: os.environ['HGMERGE'] = oldmergeenv else: del os.environ['HGMERGE']
def difftools(ui): global _difftools if _difftools: return _difftools def fixup_extdiff(diffopts): if '$child' not in diffopts: diffopts.append('$parent1') diffopts.append('$child') if '$parent2' in diffopts: mergeopts = diffopts[:] diffopts.remove('$parent2') else: mergeopts = [] return diffopts, mergeopts tools = {} for cmd, path in ui.configitems('extdiff'): if cmd.startswith('cmd.'): cmd = cmd[4:] if not path: path = cmd diffopts = ui.config('extdiff', 'opts.' + cmd, '') diffopts = shlex.split(diffopts) diffopts, mergeopts = fixup_extdiff(diffopts) tools[cmd] = [path, diffopts, mergeopts] elif cmd.startswith('opts.'): continue else: # command = path opts if path: diffopts = shlex.split(path) path = diffopts.pop(0) else: path, diffopts = cmd, [] diffopts, mergeopts = fixup_extdiff(diffopts) tools[cmd] = [path, diffopts, mergeopts] mt = [] mergetools(ui, mt) for t in mt: if t.startswith('internal:'): continue dopts = ui.config('merge-tools', t + '.diffargs', '') mopts = ui.config('merge-tools', t + '.diff3args', '') dopts, mopts = shlex.split(dopts), shlex.split(mopts) tools[t] = [filemerge._findtool(ui, t), dopts, mopts] _difftools = tools return tools
def difftools(ui): global _difftools if _difftools: return _difftools def fixup_extdiff(diffopts): if "$child" not in diffopts: diffopts.append("$parent1") diffopts.append("$child") if "$parent2" in diffopts: mergeopts = diffopts[:] diffopts.remove("$parent2") else: mergeopts = [] return diffopts, mergeopts tools = {} for cmd, path in ui.configitems("extdiff"): if cmd.startswith("cmd."): cmd = cmd[4:] if not path: path = cmd diffopts = ui.config("extdiff", "opts." + cmd, "") diffopts = shlex.split(diffopts) diffopts, mergeopts = fixup_extdiff(diffopts) tools[cmd] = [path, diffopts, mergeopts] elif cmd.startswith("opts."): continue else: # command = path opts if path: diffopts = shlex.split(path) path = diffopts.pop(0) else: path, diffopts = cmd, [] diffopts, mergeopts = fixup_extdiff(diffopts) tools[cmd] = [path, diffopts, mergeopts] mt = [] mergetools(ui, mt) for t in mt: if t.startswith("internal:"): continue dopts = ui.config("merge-tools", t + ".diffargs", "") mopts = ui.config("merge-tools", t + ".diff3args", "") dopts, mopts = shlex.split(dopts), shlex.split(mopts) tools[t] = [filemerge._findtool(ui, t), dopts, mopts] _difftools = tools return tools
def mergetools(ui, values=None): 'returns the configured merge tools and the internal ones' if values == None: values = [] seen = values[:] for key, value in ui.configitems('merge-tools'): t = key.split('.')[0] if t not in seen: seen.append(t) # Ensure the tool is installed if filemerge._findtool(ui, t): values.append(t) values.append('internal:merge') values.append('internal:prompt') values.append('internal:dump') values.append('internal:local') values.append('internal:other') values.append('internal:fail') return values
def mergetools(ui, values=None): "returns the configured merge tools and the internal ones" if values == None: values = [] seen = values[:] for key, value in ui.configitems("merge-tools"): t = key.split(".")[0] if t not in seen: seen.append(t) # Ensure the tool is installed if filemerge._findtool(ui, t): values.append(t) values.append("internal:merge") values.append("internal:prompt") values.append("internal:dump") values.append("internal:local") values.append("internal:other") values.append("internal:fail") return values