def author(repo, subset, x): """``author(string)`` Alias for ``user(string)``. """ # i18n: "author" is a keyword n = encoding.lower(getstring(x, _("author requires a string"))) return [r for r in subset if n in encoding.lower(repo[r].user())]
def desc(repo, subset, x): """``desc(string)`` Search commit message for string. The match is case-insensitive. """ # i18n: "desc" is a keyword ds = encoding.lower(getstring(x, _("desc requires a string"))) l = [] for r in subset: c = repo[r] if ds in encoding.lower(c.description()): l.append(r) return l
def keyword(repo, subset, x): """``keyword(string)`` Search commit message, user name, and names of changed files for string. The match is case-insensitive. """ # i18n: "keyword" is a keyword kw = encoding.lower(getstring(x, _("keyword requires a string"))) l = [] for r in subset: c = repo[r] t = " ".join(c.files() + [c.user(), c.description()]) if kw in encoding.lower(t): l.append(r) return l
def __call__(self, f): fl = encoding.lower(f) if fl in self._loweredfiles and f not in self._dirstate and f not in self._newfiles: msg = _("possible case-folding collision for %s") % f if self._abort: raise util.Abort(msg) self._ui.warn(_("warning: %s\n") % msg) self._loweredfiles.add(fl) self._newfiles.add(f)
def __call__(self, f): fl = encoding.lower(f) map = self._map if fl in map and map[fl] != f: msg = _('possible case-folding collision for %s') % f if self._abort: raise util.Abort(msg) self._ui.warn(_("warning: %s\n") % msg) map[fl] = f
def _checkcollision(mctx): "check for case folding collisions in the destination context" folded = {} for fn in mctx: fold = encoding.lower(fn) if fold in folded: raise util.Abort(_("case-folding collision between %s and %s") % (fn, folded[fold])) folded[fold] = fn
def __init__(self, ui, abort, dirstate): self._ui = ui self._abort = abort allfiles = '\0'.join(dirstate._map) self._loweredfiles = set(encoding.lower(allfiles).split('\0')) self._dirstate = dirstate # The purpose of _newfiles is so that we don't complain about # case collisions if someone were to call this object with the # same filename twice. self._newfiles = set()
def __call__(self, f): fl = encoding.lower(f) if (fl in self._loweredfiles and f not in self._dirstate and f not in self._newfiles): msg = _('possible case-folding collision for %s') % f if self._abort: raise util.Abort(msg) self._ui.warn(_("warning: %s\n") % msg) self._loweredfiles.add(fl) self._newfiles.add(f)
def topicmatch(kw): """Return help topics matching kw. Returns {'section': [(name, summary), ...], ...} where section is one of topics, commands, extensions, or extensioncommands. """ kw = encoding.lower(kw) def lowercontains(container): return kw in encoding.lower(container) # translated in helptable results = { 'topics': [], 'commands': [], 'extensions': [], 'extensioncommands': [], } for names, header, doc in helptable: # Old extensions may use a str as doc. if (sum(map(lowercontains, names)) or lowercontains(header) or (callable(doc) and lowercontains(doc()))): results['topics'].append((names[0], header)) import commands # avoid cycle for cmd, entry in commands.table.iteritems(): if len(entry) == 3: summary = entry[2] else: summary = '' # translate docs *before* searching there docs = _(getattr(entry[0], '__doc__', None)) or '' if kw in cmd or lowercontains(summary) or lowercontains(docs): doclines = docs.splitlines() if doclines: summary = doclines[0] cmdname = cmd.split('|')[0].lstrip('^') results['commands'].append((cmdname, summary)) for name, docs in itertools.chain( extensions.enabled(False).iteritems(), extensions.disabled().iteritems()): # extensions.load ignores the UI argument mod = extensions.load(None, name, '') name = name.split('.')[-1] if lowercontains(name) or lowercontains(docs): # extension docs are already translated results['extensions'].append((name, docs.splitlines()[0])) for cmd, entry in getattr(mod, 'cmdtable', {}).iteritems(): if kw in cmd or (len(entry) > 2 and lowercontains(entry[2])): cmdname = cmd.split('|')[0].lstrip('^') if entry[0].__doc__: cmddoc = gettext(entry[0].__doc__).splitlines()[0] else: cmddoc = _('(no help text available)') results['extensioncommands'].append((cmdname, cmddoc)) return results
def topicmatch(kw): """Return help topics matching kw. Returns {'section': [(name, summary), ...], ...} where section is one of topics, commands, extensions, or extensioncommands. """ kw = encoding.lower(kw) def lowercontains(container): return kw in encoding.lower(container) # translated in helptable results = {'topics': [], 'commands': [], 'extensions': [], 'extensioncommands': [], } for names, header, doc in helptable: if (sum(map(lowercontains, names)) or lowercontains(header) or lowercontains(doc())): results['topics'].append((names[0], header)) import commands # avoid cycle for cmd, entry in commands.table.iteritems(): if cmd.startswith('debug'): continue if len(entry) == 3: summary = entry[2] else: summary = '' # translate docs *before* searching there docs = _(getattr(entry[0], '__doc__', None)) or '' if kw in cmd or lowercontains(summary) or lowercontains(docs): doclines = docs.splitlines() if doclines: summary = doclines[0] cmdname = cmd.split('|')[0].lstrip('^') results['commands'].append((cmdname, summary)) for name, docs in itertools.chain( extensions.enabled(False).iteritems(), extensions.disabled().iteritems()): # extensions.load ignores the UI argument mod = extensions.load(None, name, '') name = name.split('.')[-1] if lowercontains(name) or lowercontains(docs): # extension docs are already translated results['extensions'].append((name, docs.splitlines()[0])) for cmd, entry in getattr(mod, 'cmdtable', {}).iteritems(): if kw in cmd or (len(entry) > 2 and lowercontains(entry[2])): cmdname = cmd.split('|')[0].lstrip('^') if entry[0].__doc__: cmddoc = gettext(entry[0].__doc__).splitlines()[0] else: cmddoc = _('(no help text available)') results['extensioncommands'].append((cmdname, cmddoc)) return results
def __init__(self, ui, abort, existingiter): self._ui = ui self._abort = abort self._map = {} for f in existingiter: self._map[encoding.lower(f)] = f
def lowercontains(container): return kw in encoding.lower(container) # translated in helptable
def lower(text): """:lower: Any text. Converts the text to lowercase.""" return encoding.lower(text)