当前位置: 首页>>代码示例>>Python>>正文


Python extensions.wrapfunction函数代码示例

本文整理汇总了Python中mercurial.extensions.wrapfunction函数的典型用法代码示例。如果您正苦于以下问题:Python wrapfunction函数的具体用法?Python wrapfunction怎么用?Python wrapfunction使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了wrapfunction函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: extsetup

def extsetup(ui):
    if _fbsparseexists(ui):
        cmdtable.clear()
        return
    _setupclone(ui)
    _setuplog(ui)
    _setupadd(ui)
    _setupdirstate(ui)
    _setupdiff(ui)
    # if fsmonitor is enabled, tell it to use our hash function
    try:
        fsmonitor = extensions.find('fsmonitor')
        def _hashignore(orig, ignore):
            return _hashmatcher(ignore)
        extensions.wrapfunction(fsmonitor, '_hashignore', _hashignore)
    except KeyError:
        pass
    # do the same for hgwatchman, old name
    try:
        hgwatchman = extensions.find('hgwatchman')
        def _hashignore(orig, ignore):
            return _hashmatcher(ignore)
        extensions.wrapfunction(hgwatchman, '_hashignore', _hashignore)
    except KeyError:
        pass
开发者ID:davidshepherd7,项目名称:dotfiles,代码行数:25,代码来源:sparse.py

示例2: extsetup

def extsetup():
    # monkeypatch in the new version
    extensions.wrapfunction(webcommands, '_filerevision',
                            filerevision_highlight)
    extensions.wrapfunction(webcommands, 'annotate', annotate_highlight)
    webcommands.highlightcss = generate_css
    webcommands.__all__.append('highlightcss')
开发者ID:motlin,项目名称:cyg,代码行数:7,代码来源:__init__.py

示例3: winuisetup

def winuisetup(ui):
	if sys.platform != 'win32' or not win32helper.consolehascp():
		return

	win32helper.uisetup(ui)

	try:
		from mercurial import encoding

		encoding.encoding = 'utf8'
	except ImportError:
		util._encoding = "utf-8"

	def localize(h):
		if hasattr(ui, '_buffers'):
			getbuffers = lambda ui: ui._buffers
		else:
			getbuffers = lambda ui: ui.buffers

		def f(orig, ui, *args, **kwds):
			if not getbuffers(ui):
				win32helper.rawprint(h, ''.join(args))
			else:
				orig(ui, *args, **kwds)

		return f

	extensions.wrapfunction(_ui.ui, "write", localize(win32helper.hStdOut))
	extensions.wrapfunction(_ui.ui, "write_err", localize(win32helper.hStdErr))
开发者ID:ddaspit,项目名称:chorus,代码行数:29,代码来源:fixutf8.py

示例4: exchangepull

def exchangepull(orig, repo, remote, *args, **kwargs):
    # Hook into the callstream/getbundle to insert bundle capabilities
    # during a pull.
    def remotecallstream(orig, command, **opts):
        if command == 'getbundle' and 'remotefilelog' in remote._capabilities():
            bundlecaps = opts.get('bundlecaps')
            if bundlecaps:
                bundlecaps = [bundlecaps]
            else:
                bundlecaps = []
            bundlecaps.append('remotefilelog')
            if repo.includepattern:
                bundlecaps.append("includepattern=" + '\0'.join(repo.includepattern))
            if repo.excludepattern:
                bundlecaps.append("excludepattern=" + '\0'.join(repo.excludepattern))
            opts['bundlecaps'] = ','.join(bundlecaps)
        return orig(command, **opts)

    def localgetbundle(orig, source, heads=None, common=None, bundlecaps=None,
                       **kwargs):
        if not bundlecaps:
            bundlecaps = set()
        bundlecaps.add('remotefilelog')
        return orig(source, heads=heads, common=common, bundlecaps=bundlecaps,
                    **kwargs)

    if hasattr(remote, '_callstream'):
        wrapfunction(remote, '_callstream', remotecallstream)
    elif hasattr(remote, 'getbundle'):
        wrapfunction(remote, 'getbundle', localgetbundle)

    return orig(repo, remote, *args, **kwargs)
开发者ID:pycontribs,项目名称:remotefilelog,代码行数:32,代码来源:__init__.py

示例5: uisetup

def uisetup(ui):
    if ui.plain():
        return

    try:
        extensions.find('color')
    except KeyError:
        ui.warn(_("warning: 'diff-highlight' requires 'color' extension "
                  "to be enabled, but not\n"))
        return

    if not isinstance(ui, colorui):
        colorui.__bases__ = (ui.__class__,)
        ui.__class__ = colorui

    def colorconfig(orig, *args, **kwargs):
        ret = orig(*args, **kwargs)

        styles = color._styles
        if INSERT_EMPH not in styles:
            styles[INSERT_EMPH] = styles[INSERT_NORM] + ' inverse'

        if DELETE_EMPH not in styles:
            styles[DELETE_EMPH] = styles[DELETE_NORM] + ' inverse'

        return ret

    extensions.wrapfunction(color, 'configstyles', colorconfig)
开发者ID:tk0miya,项目名称:diff-highlight,代码行数:28,代码来源:diff_highlight.py

示例6: uisetup__disabled

def uisetup__disabled(ui):
    from mercurial import extensions, hook
    import sys; sys.excepthook = None
    extensions.wrapfunction(hook, 'hook', wraphook)
    global HOOKDEBUG, HOOKLOG
    HOOKDEBUG = ui.configbool('anyhook', 'debug')
    HOOKLOG = ui.configbool('anyhook', 'log')
开发者ID:avdd,项目名称:config,代码行数:7,代码来源:hgavdd.py

示例7: extsetup

def extsetup(ui):
    extensions.wrapfunction(dispatch, 'runcommand', runcommand)
    extensions.wrapfunction(bookmarks.bmstore, '_write', recordbookmarks)
    extensions.wrapfunction(
        localrepo.localrepository.dirstate, 'func', wrapdirstate)
    extensions.wrapfunction(hg, 'postshare', wrappostshare)
    extensions.wrapfunction(hg, 'copystore', unsharejournal)
开发者ID:motlin,项目名称:cyg,代码行数:7,代码来源:journal.py

示例8: ancestorcache

def ancestorcache(path):
    # simple cache to speed up revlog.ancestors
    try:
        db = anydbm.open(path, 'c')
    except anydbm.error:
        # database locked, fail gracefully
        yield
    else:
        def revlogancestor(orig, self, a, b):
            key = a + b
            try:
                return db[key]
            except KeyError:
                result = orig(self, a, b)
                db[key] = result
                return result
        extensions.wrapfunction(revlog.revlog, 'ancestor', revlogancestor)
        try:
            yield
        finally:
            extensions.unwrapfunction(revlog.revlog, 'ancestor', revlogancestor)
            try:
                db.close()
            except Exception:
                # database corruption, we just nuke the database
                util.tryunlink(path)
开发者ID:davidshepherd7,项目名称:dotfiles,代码行数:26,代码来源:smartlog.py

示例9: extsetup

def extsetup(ui):
    extensions.wrapfunction(wireproto, '_capabilities', capabilities)
    pushkey.register('strip', pushstrip, liststrip)

    # Add a pushkey namespace to obtain the list of available review
    # repositories. This is used for repository discovery.
    pushkey.register('reviewrepos', lambda *x: False, listreviewrepos)
开发者ID:Nephyrin,项目名称:bzexport,代码行数:7,代码来源:server.py

示例10: _setupwrapper

def _setupwrapper():
    """Wrap hgweb.server.create_server to get along with thg"""
    global _setupwrapper_done
    if not _setupwrapper_done:
        extensions.wrapfunction(hgweb.server, 'create_server',
                                _create_server)
        _setupwrapper_done = True
开发者ID:velorientc,项目名称:git_test7,代码行数:7,代码来源:serve.py

示例11: _create_server

def _create_server(orig, ui, app):
    """wrapper for hgweb.server.create_server to be interruptable"""
    server = orig(ui, app)
    server.accesslog = ui
    server.errorlog = ui  # TODO: ui.warn
    server._serving = False

    def serve_forever(orig):
        server._serving = True
        try:
            try:
                while server._serving:
                    server.handle_request()
            except KeyboardInterrupt:
                # raised outside try-block around process_request().
                # see SocketServer.BaseServer
                pass
        finally:
            server._serving = False
            server.server_close()

    def handle_error(orig, request, client_address):
        type, value, _traceback = sys.exc_info()
        if issubclass(type, KeyboardInterrupt):
            server._serving = False
        else:
            ui.write_err('%s\n' % value)

    extensions.wrapfunction(server, 'serve_forever', serve_forever)
    extensions.wrapfunction(server, 'handle_error', handle_error)
    return server
开发者ID:velorientc,项目名称:git_test7,代码行数:31,代码来源:serve.py

示例12: uisetup

def uisetup(ui):
    """Wrap context.changectx to catch FilteredRepoLookupError."""
    # uisetup has side effects depending on config. chg only runs uisetup once.
    # Tell chg to reload if [hiddenerror] config section changes.
    chgserver._configsections.append('hiddenerror')

    # Get the error messages from the user's configuration and substitute the
    # hash in.
    msgfmt, hintfmt = _getstrings(ui)

    def _filterederror(orig, repo, rev):
        # If the number is beyond the changelog, it's a short hash that
        # just happened to be a number.
        intrev = None
        try:
            intrev = int(rev)
        except ValueError:
            pass
        if intrev is not None and intrev < len(repo):
            node = repo.unfiltered()[rev].node()
            shorthash = short(node)
            msg = msgfmt.format(shorthash)
            hint = hintfmt and hintfmt.format(shorthash)
            return error.FilteredRepoLookupError(msg, hint=hint)
        return orig(repo, rev)

    extensions.wrapfunction(context, '_filterederror', _filterederror)
开发者ID:davidshepherd7,项目名称:dotfiles,代码行数:27,代码来源:hiddenerror.py

示例13: uisetup

def uisetup(ui):
    def replace_similarity(opts):
        newopts = []
        for idx, opt in enumerate(opts):
            if opt[0] == 's':
                newopt = list(opt)
                newopt[3] = 'backwards compatability; implies -g/--guess'
                opt = tuple(newopt)
            newopts.append(opt)
        return newopts
    
    ar = list(commands.table['addremove'])
    docre = re.compile('Use the -s option.+way can be expensive\.', re.M | re.S)
    ar[0].__doc__ = re.sub(docre,
    """
    Use the -g option to detect renamed files. This option uses a smarter, more
    accurate algorithm than the built-in -s option.
    """.strip(), ar[0].__doc__)
    ar[1] = replace_similarity(ar[1])
    ar[1].append(('g', 'guess', False, 'guess renamed files'))
    commands.table['addremove'] = tuple(ar)
    
    import_ = list(commands.table['import|patch'])
    import_[0].__doc__ = re.sub(r'(--similarity),',
                                r'\1 or -g/--guess,',
                                import_[0].__doc__)
    import_[1] = opts = replace_similarity(import_[1])
    import_[1].append(('g', 'guess', False, 'guess renamed files'))
    commands.table['import'] = tuple(import_)
            
    extensions.wrapfunction(scmutil, 'addremove', addremove)
开发者ID:stangelandcl,项目名称:guess-renames,代码行数:31,代码来源:hgext.py

示例14: setupserver

def setupserver(ui, repo):
    """Sets up a normal Mercurial repo so it can serve files to shallow repos.
    """
    onetimesetup(ui)

    # don't send files to shallow clients during pulls
    def generatefiles(orig, self, changedfiles, linknodes, commonrevs, source):
        caps = self._bundlecaps or []
        if shallowrepo.requirement in caps:
            # only send files that don't match the specified patterns
            includepattern = None
            excludepattern = None
            for cap in (self._bundlecaps or []):
                if cap.startswith("includepattern="):
                    includepattern = cap[len("includepattern="):].split('\0')
                elif cap.startswith("excludepattern="):
                    excludepattern = cap[len("excludepattern="):].split('\0')

            m = match.always(repo.root, '')
            if includepattern or excludepattern:
                m = match.match(repo.root, '', None,
                    includepattern, excludepattern)

            changedfiles = list([f for f in changedfiles if not m(f)])
        return orig(self, changedfiles, linknodes, commonrevs, source)

    wrapfunction(changegroup.cg1packer, 'generatefiles', generatefiles)

    # add incoming hook to continuously generate file blobs
    ui.setconfig("hooks", "changegroup.remotefilelog", incominghook)
开发者ID:pycontribs,项目名称:remotefilelog,代码行数:30,代码来源:remotefilelogserver.py

示例15: extsetup

def extsetup(ui):
    wrapfilecache(localrepo.localrepository, "dirstate", wrapdirstate)
    if sys.platform == "darwin":
        # An assist for avoiding the dangling-symlink fsevents bug
        extensions.wrapfunction(os, "symlink", wrapsymlink)

    extensions.wrapfunction(merge, "update", wrapupdate)
开发者ID:cmjonze,项目名称:mercurial,代码行数:7,代码来源:__init__.py


注:本文中的mercurial.extensions.wrapfunction函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。