def __init__(self, ui, path, revs=None): super(gnuarch_source, self).__init__(ui, path, revs=revs) if not os.path.exists(os.path.join(path, '{arch}')): raise common.NoRepo(_("%s does not look like a GNU Arch repository") % path) # Could use checktool, but we want to check for baz or tla. self.execmd = None if util.findexe('baz'): self.execmd = 'baz' else: if util.findexe('tla'): self.execmd = 'tla' else: raise error.Abort(_('cannot find a GNU Arch tool')) common.commandline.__init__(self, ui, self.execmd) self.path = os.path.realpath(path) self.tmppath = None self.treeversion = None self.lastrev = None self.changes = {} self.parents = {} self.tags = {} self.catlogparser = email.Parser.Parser() self.encoding = encoding.encoding self.archives = []
def __init__(self, ui, path, revs=None): super(gnuarch_source, self).__init__(ui, path, revs=revs) if not os.path.exists(os.path.join(path, '{arch}')): raise common.NoRepo( _("%s does not look like a GNU Arch repository") % path) # Could use checktool, but we want to check for baz or tla. self.execmd = None if util.findexe('baz'): self.execmd = 'baz' else: if util.findexe('tla'): self.execmd = 'tla' else: raise error.Abort(_('cannot find a GNU Arch tool')) common.commandline.__init__(self, ui, self.execmd) self.path = os.path.realpath(path) self.tmppath = None self.treeversion = None self.lastrev = None self.changes = {} self.parents = {} self.tags = {} self.catlogparser = email.Parser.Parser() self.encoding = encoding.encoding self.archives = []
def _findtool(ui, tool): global toolcache if tool in toolcache: return toolcache[tool] for kn in ("regkey", "regkeyalt"): k = _toolstr(ui, tool, kn) if not k: continue p = util.lookupreg(k, _toolstr(ui, tool, "regname")) if p: p = util.findexe(p + _toolstr(ui, tool, "regappend")) if p: toolcache[tool] = p return p global _platformexecutablekey exe = _toolstr(ui, tool, _platformexecutablekey) if not exe: exe = _toolstr(ui, tool, 'executable', tool) path = util.findexe(util.expandpath(exe)) if path: toolcache[tool] = path return path elif tool != exe: path = util.findexe(tool) toolcache[tool] = path return path toolcache[tool] = None return None
def uisetup(ui): for cmd, path in ui.configitems('extdiff'): path = util.expandpath(path) if cmd.startswith('cmd.'): cmd = cmd[4:] if not path: path = util.findexe(cmd) if path is None: path = filemerge.findexternaltool(ui, cmd) or cmd diffopts = ui.config('extdiff', 'opts.' + cmd, '') cmdline = util.shellquote(path) if diffopts: cmdline += ' ' + diffopts elif cmd.startswith('opts.'): continue else: if path: # case "cmd = path opts" cmdline = path diffopts = len(shlex.split(cmdline)) > 1 else: # case "cmd =" path = util.findexe(cmd) if path is None: path = filemerge.findexternaltool(ui, cmd) or cmd cmdline = util.shellquote(path) diffopts = False # look for diff arguments in [diff-tools] then [merge-tools] if not diffopts: args = ui.config('diff-tools', cmd+'.diffargs') or \ ui.config('merge-tools', cmd+'.diffargs') if args: cmdline += ' ' + args command(cmd, extdiffopts[:], _('hg %s [OPTION]... [FILE]...') % cmd, inferrepo=True)(savedcmd(path, cmdline))
def uisetup(ui): for cmd, path in ui.configitems('extdiff'): path = util.expandpath(path) if cmd.startswith('cmd.'): cmd = cmd[4:] if not path: path = util.findexe(cmd) if path is None: path = filemerge.findexternaltool(ui, cmd) or cmd diffopts = ui.config('extdiff', 'opts.' + cmd, '') cmdline = util.shellquote(path) if diffopts: cmdline += ' ' + diffopts elif cmd.startswith('opts.'): continue else: if path: # case "cmd = path opts" cmdline = path diffopts = len(shlex.split(cmdline)) > 1 else: # case "cmd =" path = util.findexe(cmd) if path is None: path = filemerge.findexternaltool(ui, cmd) or cmd cmdline = util.shellquote(path) diffopts = False # look for diff arguments in [diff-tools] then [merge-tools] if not diffopts: args = ui.config('diff-tools', cmd+'.diffargs') or \ ui.config('merge-tools', cmd+'.diffargs') if args: cmdline += ' ' + args def save(cmdline): '''use closure to save diff command to use''' def mydiff(ui, repo, *pats, **opts): options = ' '.join(map(util.shellquote, opts['option'])) if options: options = ' ' + options return dodiff(ui, repo, cmdline + options, pats, opts) # We can't pass non-ASCII through docstrings (and path is # in an unknown encoding anyway) docpath = path.encode("string-escape") mydiff.__doc__ = '''\ use %(path)s to diff repository (or selected files) Show differences between revisions for the specified files, using the %(path)s program. When two revision arguments are given, then changes are shown between those revisions. If only one revision is specified then that revision is compared to the working directory, and, when no revisions are specified, the working directory files are compared to its parent.\ ''' % {'path': util.uirepr(docpath)} return mydiff command(cmd, extdiffopts[:], _('hg %s [OPTION]... [FILE]...') % cmd, inferrepo=True)(save(cmdline))
def checktool(exe, name=None, abort=True): name = name or exe if not util.findexe(exe): if abort: exc = error.Abort else: exc = MissingTool raise exc(_('cannot find required "%s" tool') % name)
def checktool(exe, name=None, abort=True, debname=None): name = name or exe if not util.findexe(exe): exc = abort and util.Abort or MissingTool raise exc( _('cannot find required "%s" tool') % name + (debname and _(' (try installing the %s package)') % debname or '') )
def uisetup(ui): for cmd, path in ui.configitems('extdiff'): path = util.expandpath(path) if cmd.startswith('cmd.'): cmd = cmd[4:] if not path: path = util.findexe(cmd) if path is None: path = filemerge.findexternaltool(ui, cmd) or cmd diffopts = ui.config('extdiff', 'opts.' + cmd, '') cmdline = util.shellquote(path) if diffopts: cmdline += ' ' + diffopts elif cmd.startswith('opts.'): continue else: if path: # case "cmd = path opts" cmdline = path diffopts = len(pycompat.shlexsplit(cmdline)) > 1 else: # case "cmd =" path = util.findexe(cmd) if path is None: path = filemerge.findexternaltool(ui, cmd) or cmd cmdline = util.shellquote(path) diffopts = False # look for diff arguments in [diff-tools] then [merge-tools] if not diffopts: args = ui.config('diff-tools', cmd+'.diffargs') or \ ui.config('merge-tools', cmd+'.diffargs') if args: cmdline += ' ' + args command(cmd, extdiffopts[:], _('hg %s [OPTION]... [FILE]...') % cmd, inferrepo=True)(savedcmd(path, cmdline))
def uisetup(ui): for cmd, path in ui.configitems('extdiff'): if cmd.startswith('cmd.'): cmd = cmd[4:] if not path: path = util.findexe(cmd) if path is None: path = filemerge.findexternaltool(ui, cmd) or cmd diffopts = ui.config('extdiff', 'opts.' + cmd, '') cmdline = util.shellquote(path) if diffopts: cmdline += ' ' + diffopts elif cmd.startswith('opts.'): continue else: if path: # case "cmd = path opts" cmdline = path diffopts = len(shlex.split(cmdline)) > 1 else: # case "cmd =" path = util.findexe(cmd) if path is None: path = filemerge.findexternaltool(ui, cmd) or cmd cmdline = util.shellquote(path) diffopts = False # look for diff arguments in [diff-tools] then [merge-tools] if not diffopts: args = ui.config('diff-tools', cmd+'.diffargs') or \ ui.config('merge-tools', cmd+'.diffargs') if args: cmdline += ' ' + args def save(cmdline): '''use closure to save diff command to use''' def mydiff(ui, repo, *pats, **opts): options = ' '.join(map(util.shellquote, opts['option'])) if options: options = ' ' + options return dodiff(ui, repo, cmdline + options, pats, opts) doc = _('''\ use %(path)s to diff repository (or selected files) Show differences between revisions for the specified files, using the %(path)s program. When two revision arguments are given, then changes are shown between those revisions. If only one revision is specified then that revision is compared to the working directory, and, when no revisions are specified, the working directory files are compared to its parent.\ ''') % { 'path': util.uirepr(path) } # We must translate the docstring right away since it is # used as a format string. The string will unfortunately # be translated again in commands.helpcmd and this will # fail when the docstring contains non-ASCII characters. # Decoding the string to a Unicode string here (using the # right encoding) prevents that. mydiff.__doc__ = doc.decode(encoding.encoding) return mydiff cmdtable[cmd] = (save(cmdline), cmdtable['extdiff'][1][1:], _('hg %s [OPTION]... [FILE]...') % cmd)
def uisetup(ui): for cmd, path in ui.configitems('extdiff'): path = util.expandpath(path) if cmd.startswith('cmd.'): cmd = cmd[4:] if not path: path = util.findexe(cmd) if path is None: path = filemerge.findexternaltool(ui, cmd) or cmd diffopts = ui.config('extdiff', 'opts.' + cmd, '') cmdline = util.shellquote(path) if diffopts: cmdline += ' ' + diffopts elif cmd.startswith('opts.'): continue else: if path: # case "cmd = path opts" cmdline = path diffopts = len(shlex.split(cmdline)) > 1 else: # case "cmd =" path = util.findexe(cmd) if path is None: path = filemerge.findexternaltool(ui, cmd) or cmd cmdline = util.shellquote(path) diffopts = False # look for diff arguments in [diff-tools] then [merge-tools] if not diffopts: args = ui.config('diff-tools', cmd+'.diffargs') or \ ui.config('merge-tools', cmd+'.diffargs') if args: cmdline += ' ' + args def save(cmdline): '''use closure to save diff command to use''' def mydiff(ui, repo, *pats, **opts): options = ' '.join(map(util.shellquote, opts['option'])) if options: options = ' ' + options return dodiff(ui, repo, cmdline + options, pats, opts) doc = _('''\ use %(path)s to diff repository (or selected files) Show differences between revisions for the specified files, using the %(path)s program. When two revision arguments are given, then changes are shown between those revisions. If only one revision is specified then that revision is compared to the working directory, and, when no revisions are specified, the working directory files are compared to its parent.\ ''') % {'path': util.uirepr(path)} # We must translate the docstring right away since it is # used as a format string. The string will unfortunately # be translated again in commands.helpcmd and this will # fail when the docstring contains non-ASCII characters. # Decoding the string to a Unicode string here (using the # right encoding) prevents that. mydiff.__doc__ = doc.decode(encoding.encoding) return mydiff command(cmd, extdiffopts[:], _('hg %s [OPTION]... [FILE]...') % cmd, inferrepo=True)(save(cmdline))
def uisetup(ui): for cmd, path in ui.configitems("extdiff"): if cmd.startswith("cmd."): cmd = cmd[4:] if not path: path = util.findexe(cmd) if path is None: path = filemerge.findexternaltool(ui, cmd) or cmd diffopts = ui.config("extdiff", "opts." + cmd, "") cmdline = util.shellquote(path) if diffopts: cmdline += " " + diffopts elif cmd.startswith("opts."): continue else: if path: # case "cmd = path opts" cmdline = path diffopts = len(shlex.split(cmdline)) > 1 else: # case "cmd =" path = util.findexe(cmd) if path is None: path = filemerge.findexternaltool(ui, cmd) or cmd cmdline = util.shellquote(path) diffopts = False # look for diff arguments in [diff-tools] then [merge-tools] if not diffopts: args = ui.config("diff-tools", cmd + ".diffargs") or ui.config("merge-tools", cmd + ".diffargs") if args: cmdline += " " + args def save(cmdline): """use closure to save diff command to use""" def mydiff(ui, repo, *pats, **opts): options = " ".join(map(util.shellquote, opts["option"])) if options: options = " " + options return dodiff(ui, repo, cmdline + options, pats, opts) doc = ( _( """\ use %(path)s to diff repository (or selected files) Show differences between revisions for the specified files, using the %(path)s program. When two revision arguments are given, then changes are shown between those revisions. If only one revision is specified then that revision is compared to the working directory, and, when no revisions are specified, the working directory files are compared to its parent.\ """ ) % {"path": util.uirepr(path)} ) # We must translate the docstring right away since it is # used as a format string. The string will unfortunately # be translated again in commands.helpcmd and this will # fail when the docstring contains non-ASCII characters. # Decoding the string to a Unicode string here (using the # right encoding) prevents that. mydiff.__doc__ = doc.decode(encoding.encoding) return mydiff cmdtable[cmd] = (save(cmdline), cmdtable["extdiff"][1][1:], _("hg %s [OPTION]... [FILE]...") % cmd)
def checktool(exe, name=None, abort=True): name = name or exe if not util.findexe(exe): exc = abort and util.Abort or MissingTool raise exc(_('cannot find required "%s" tool') % name)
def checktool(exe, name=None, abort=True, debname=None): name = name or exe if not util.findexe(exe): exc = abort and util.Abort or MissingTool raise exc(_('cannot find required "%s" tool') % name + (debname and _(' (try installing the %s package)') % debname or ''))