Esempio n. 1
0
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())]
Esempio n. 2
0
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())]
Esempio n. 3
0
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
Esempio n. 4
0
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
Esempio n. 5
0
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
Esempio n. 6
0
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
Esempio n. 7
0
 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)
Esempio n. 8
0
 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
Esempio n. 9
0
 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
Esempio n. 10
0
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
Esempio n. 11
0
 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()
Esempio n. 12
0
 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)
Esempio n. 13
0
 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()
Esempio n. 14
0
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
Esempio n. 15
0
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
Esempio n. 16
0
 def __init__(self, ui, abort, existingiter):
     self._ui = ui
     self._abort = abort
     self._map = {}
     for f in existingiter:
         self._map[encoding.lower(f)] = f
Esempio n. 17
0
 def lowercontains(container):
     return kw in encoding.lower(container)  # translated in helptable
Esempio n. 18
0
def lower(text):
    """:lower: Any text. Converts the text to lowercase."""
    return encoding.lower(text)
Esempio n. 19
0
 def lowercontains(container):
     return kw in encoding.lower(container)  # translated in helptable
Esempio n. 20
0
 def __init__(self, ui, abort, existingiter):
     self._ui = ui
     self._abort = abort
     self._map = {}
     for f in existingiter:
         self._map[encoding.lower(f)] = f
Esempio n. 21
0
def lower(text):
    """:lower: Any text. Converts the text to lowercase."""
    return encoding.lower(text)