• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python extensions.wrapfunction函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: uisetup

def uisetup(ui):
    if ui.plain():
        return
    mode = ui.config('color', 'mode', 'auto')
    if mode == 'auto':
        if os.name == 'nt' and 'TERM' not in os.environ:
            # looks line a cmd.exe console, use win32 API or nothing
            mode = w32effects and 'win32' or 'none'
        else:
            mode = 'ansi'
    if mode == 'win32':
        if w32effects is None:
            # only warn if color.mode is explicitly set to win32
            ui.warn(_('win32console not found, please install pywin32\n'))
            return
        _effects.update(w32effects)
    elif mode != 'ansi':
        return
    def colorcmd(orig, ui_, opts, cmd, cmdfunc):
        coloropt = opts['color']
        auto = coloropt == 'auto'
        always = util.parsebool(coloropt)
        if (always or
            (always is None and
             (auto and (os.environ.get('TERM') != 'dumb' and ui_.formatted())))):
            colorui._colormode = mode
            colorui.__bases__ = (ui_.__class__,)
            ui_.__class__ = colorui
            extstyles()
            configstyles(ui_)
        return orig(ui_, opts, cmd, cmdfunc)
    extensions.wrapfunction(dispatch, '_runcommand', colorcmd)
开发者ID:ThissDJ,项目名称:designhub,代码行数:32,代码来源:color.py


示例17: extsetup

def extsetup(ui):
    entry = wrapcommand(commands.table, 'push', _push)
    try:
        # Don't add the 'to' arg if it already exists
        extensions.find('remotenames')
    except KeyError:
        entry[1].append(('', 'to', '', _('server revision to rebase onto')))

    partorder = exchange.b2partsgenorder
    partorder.insert(partorder.index('changeset'),
                     partorder.pop(partorder.index(rebaseparttype)))

    partorder.insert(0, partorder.pop(partorder.index(commonheadsparttype)))

    wrapfunction(discovery, 'checkheads', _checkheads)
    # we want to disable the heads check because in pushrebase repos, we
    # expect the heads to change during the push and we should not abort.

    # The check heads functions are used to verify that the heads haven't
    # changed since the client did the initial discovery. Pushrebase is meant
    # to allow concurrent pushes, so the heads may have very well changed.
    # So let's not do this check.
    wrapfunction(exchange, 'check_heads', _exchangecheckheads)
    wrapfunction(exchange, '_pushb2ctxcheckheads', _skipcheckheads)

    origpushkeyhandler = bundle2.parthandlermapping['pushkey']
    newpushkeyhandler = lambda *args, **kwargs: \
        bundle2pushkey(origpushkeyhandler, *args, **kwargs)
    newpushkeyhandler.params = origpushkeyhandler.params
    bundle2.parthandlermapping['pushkey'] = newpushkeyhandler
    bundle2.parthandlermapping['b2x:pushkey'] = newpushkeyhandler

    wrapfunction(exchange, 'unbundle', unbundle)

    wrapfunction(hg, '_peerorrepo', _peerorrepo)
开发者ID:kilikkuo,项目名称:version-control-tools,代码行数:35,代码来源:__init__.py


示例18: _applypatch

    def _applypatch(self, repo, patchfile, sim, force=False, **opts):
        """applies a patch the old fashioned way."""
        def epwrapper(orig, *epargs, **epopts):
            if opts.get('reverse'):
                epargs[1].append('-R')
            return orig(*epargs, **epopts)

        def adwrapper(orig, *adargs, **adopts):
            if opts.get('reverse'):
                adopts['reverse'] = True
            return orig(*adargs, **adopts)

        epo = extensions.wrapfunction(patch, 'externalpatch', epwrapper)
        ado = extensions.wrapfunction(patch, 'applydiff', adwrapper)
        files, success = {}, True
        try:
            try:
                fuzz = patch.patch(self.join(patchfile), self.ui, strip = 1,
                                   cwd = repo.root, files = files)
                updatedir(self.ui, repo, files, similarity = sim/100.)
            except Exception, inst:
                self.ui.note(str(inst) + '\n')
                if not self.ui.verbose:
                    self.ui.warn('patch failed, unable to continue (try -v)\n')
                success = False
        finally:
            patch.externalpatch = epo
            patch.applydiff = ado
        return success
开发者ID:axtl,项目名称:dotfiles,代码行数:29,代码来源:attic.py


示例19: _clonesparsecmd

def _clonesparsecmd(orig, ui, repo, *args, **opts):
    include_pat = opts.get('include')
    exclude_pat = opts.get('exclude')
    enableprofile_pat = opts.get('enable_profile')
    include = exclude = enableprofile = False
    if include_pat:
        pat = include_pat
        include = True
    if exclude_pat:
        pat = exclude_pat
        exclude = True
    if enableprofile_pat:
        pat = enableprofile_pat
        enableprofile = True
    if sum([include, exclude, enableprofile]) > 1:
        raise error.Abort(_("too many flags specified."))
    if include or exclude or enableprofile:
        def clone_sparse(orig, self, node, overwrite, *args, **kwargs):
            # sparse clone is a special snowflake as in that case always
            # are outside of the repo's dir hierachy, yet we always want
            # to name our includes/excludes/enables using repo-root
            # relative paths
            overrides = {
                ('sparse', 'includereporootpaths'): True,
                ('sparse', 'enablereporootpaths'): True,
            }
            with self.ui.configoverride(overrides, 'sparse'):
                _config(self.ui, self.unfiltered(), pat, {}, include=include,
                        exclude=exclude, enableprofile=enableprofile)
            return orig(self, node, overwrite, *args, **kwargs)
        extensions.wrapfunction(hg, 'updaterepo', clone_sparse)
    return orig(ui, repo, *args, **opts)
开发者ID:davidshepherd7,项目名称:dotfiles,代码行数:32,代码来源:sparse.py


示例20: uisetup

def uisetup(ui):
    extensions.wrapfunction(repair, 'strip', strip)
    extensions.wrapcommand(commands.table, 'update', tasksupdate)
    extensions.wrapcommand(commands.table, 'log', taskslog)
    extensions.wrapcommand(commands.table, 'export', tasksexport)
    entry = extensions.wrapcommand(commands.table, 'push', taskspush)
    entry[1].append(('', 'completed-tasks', None,
        _('push all heads that have completed tasks only')))
    entry[1].append(('', 'all-tasks', None,
        _('push all heads including those with incomplete tasks')))

    try:
        transplant = extensions.find('transplant')
        if transplant:
            entry = extensions.wrapcommand(transplant.cmdtable, 'transplant',
                taskstransplant)
            entry[1].append(('t', 'task', '',
                _('transplant all changesets in task TASK')))
    except:
        pass
    try:
        patchbomb = extensions.find('patchbomb')
        if patchbomb:
            entry = extensions.wrapcommand(patchbomb.cmdtable, 'email',
                tasksemail)
            entry[1].append(('t', 'task', '',
                _('email all changesets in task TASK')))
    except:
        pass
开发者ID:Evanlec,项目名称:config,代码行数:29,代码来源:tasks.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python hg.clean函数代码示例发布时间:2022-05-27
下一篇:
Python extensions.wrapcommand函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap