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

Python cmdutil.match函数代码示例

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

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



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

示例1: new_commit

def new_commit(orig_commit, ui, repo, *pats, **opts):
    if opts['message'] or opts['logfile']:
        # don't act if user already specified a message
        return orig_commit(ui, repo, *pats, **opts)

    # check if changelog changed
    logname = ui.config('changelog', 'filename', 'CHANGES')
    if pats:
        match = cmdutil.match(repo, pats, opts)
        if logname not in match:
            # changelog is not mentioned
            return orig_commit(ui, repo, *pats, **opts)
    logmatch = cmdutil.match(repo, [logname], {})
    logmatch.bad = lambda f, msg: None  # don't complain if file is missing

    # get diff of changelog
    log = []
    for chunk in patch.diff(repo, None, None, match=logmatch):
        for line in chunk.splitlines():
            # naive: all added lines are the changelog
            if line.startswith('+') and not line.startswith('+++'):
                log.append(line[1:].rstrip().expandtabs())
    log = normalize_log(log)

    # always let the user edit the message
    opts['force_editor'] = True
    opts['message'] = log
    return orig_commit(ui, repo, *pats, **opts)
开发者ID:abtris,项目名称:dotfiles,代码行数:28,代码来源:hgchangelog.py


示例2: perfwalk

def perfwalk(ui, repo, *pats):
    try:
        m = cmdutil.match(repo, pats, {})
        timer(lambda: len(list(repo.dirstate.walk(m, [], True, False))))
    except:
        try:
            m = cmdutil.match(repo, pats, {})
            timer(lambda: len([b for a, b, c in repo.dirstate.statwalk([], m)]))
        except:
            timer(lambda: len(list(cmdutil.walk(repo, pats, {}))))
开发者ID:helloandre,项目名称:cr48,代码行数:10,代码来源:perf.py


示例3: add

 def add(self, filepaths, dry_run=False, subrepo=None):
     "add the specified files on the next commit"
     m = match(self.repo, filepaths)
     prefix = ""
     uio = self.repo.ui
     rejected = cmdutil.add(uio, self.repo, m, dry_run, subrepo, prefix)
     return rejected
开发者ID:Focus3D,项目名称:rad2py,代码行数:7,代码来源:repo_hg.py


示例4: _casecollide

def _casecollide(ui, repo, *pats, **opts):
    '''check the case of the given file against the repository. Return True
    on collisions and (optionally) print a list of problem-files.'''
    override = opts['override'] or ui.configbool('caseguard', 'override')
    nowinchk = opts['nowincheck'] or ui.configbool('caseguard', 'nowincheck')

    loglevel = _defaultloglevel(ui, not override)

    if len(set(s.lower() for s in pats)) != len(pats):
        colliding = True
        ui.note(_('file list contains a possible case-fold collision\n'))

    added = repo.status()[1] + repo.status()[3]
    exclst = [item[0] for item in repo['.'].manifest().iteritems()] + added
    chklst = [item.lower() for item in exclst]
    mtch = dict(zip(chklst, exclst))
    m = cmdutil.match(repo, pats, opts)

    for f in repo.walk(m):
        flwr = f.lower()
        _wincheck(ui, f, loglevel)
        _charcheck(ui, f, loglevel)
        if f not in repo.dirstate and f not in exclst and flwr in mtch:
            loglevel(_('possible case-folding collision for %s') % f)
        mtch[flwr] = f
开发者ID:avuori,项目名称:dotfiles,代码行数:25,代码来源:caseguard.py


示例5: cleanup

    def cleanup(self, repo, pats, opts):
        '''removes all changes from the working copy and makes it so
        there isn't a patch applied'''

        # find added files in the user's chosen set
        m = cmdutil.match(repo, pats, opts)
        added = repo.status(match=m)[1]

        revertopts = { 'include': opts.get('include'),
                       'exclude': opts.get('exclude'),
                       'date': None,
                       'all': True,
                       'rev': '.',
                       'no_backup': True,
                     }
        self.ui.pushbuffer()            # silence revert
        try:
            commands.revert(self.ui, repo, *pats, **revertopts)

            # finish the job of reverting added files (safe because they are
            # saved in the attic patch)
            for fn in added:
                self.ui.status(_('removing %s\n') % fn)
                util.unlink(fn)
        finally:
            self.ui.popbuffer()

        self.applied = ''
        self.persiststate()
开发者ID:axtl,项目名称:dotfiles,代码行数:29,代码来源:attic.py


示例6: autodiff

def autodiff(ui, repo, *pats, **opts):
    diffopts = patch.diffopts(ui, opts)
    git = opts.get('git', 'no')
    brokenfiles = set()
    losedatafn = None
    if git in ('yes', 'no'):
        diffopts.git = git == 'yes'
        diffopts.upgrade = False
    elif git == 'auto':
        diffopts.git = False
        diffopts.upgrade = True
    elif git == 'warn':
        diffopts.git = False
        diffopts.upgrade = True
        def losedatafn(fn=None, **kwargs):
            brokenfiles.add(fn)
            return True
    elif git == 'abort':
        diffopts.git = False
        diffopts.upgrade = True
        def losedatafn(fn=None, **kwargs):
            raise util.Abort('losing data for %s' % fn)
    else:
        raise util.Abort('--git must be yes, no or auto')

    node1, node2 = cmdutil.revpair(repo, [])
    m = cmdutil.match(repo, pats, opts)
    it = patch.diff(repo, node1, node2, match=m, opts=diffopts,
                    losedatafn=losedatafn)
    for chunk in it:
        ui.write(chunk)
    for fn in sorted(brokenfiles):
        ui.write('data lost for: %s\n' % fn)
开发者ID:MezzLabs,项目名称:mercurial,代码行数:33,代码来源:autodiff.py


示例7: _get_history_1_4

    def _get_history_1_4(self, repo, pats, opts, limit):
        matcher = cmdutil.match(repo, pats, opts)
        if self.isfile:
            fncache = {}
            def prep(ctx, fns):
                if self.isfile:
                    fncache[ctx.rev()] = fns[0]
        else:
            def prep(ctx, fns):
                pass

        # keep one lookahead entry so that we can detect renames
        path = self.path
        entry = None
        count = 1
        for ctx in cmdutil.walkchangerevs(repo, matcher, opts, prep):
            if self.isfile and entry:
                path = fncache[ctx.rev()]
                if path != entry[0]:
                    entry = entry[0:2] + (Changeset.COPY,)
            if entry:
                count += 1
                yield entry
            entry = (path, self.repos.hg_display(ctx.node()), Changeset.EDIT)
        if entry:
            if count < limit:
                entry = entry[0:2] + (Changeset.ADD,)
            yield entry
开发者ID:dokipen,项目名称:trac-hg-plugin,代码行数:28,代码来源:backend.py


示例8: casecheck

def casecheck(ui, repo, *pats, **opts):
    if not repo.local():
        ui.note(_('Only local repositories can be checked'))
        return
    '''check an existing local repository for filename issues (caseguard)'''
    try:
        # Mercurial >= 1.9
        m = scmutil.match(repo[0], pats, opts)
    except ImportError:
        # Mercurial <= 1.8
        m = cmdutil.match(repo, pats, opts)

    seen = dict()

    def dostatus(msg):
        ui.status('%s\n' % msg)

    for f in repo.walk(m):
        if f in repo.dirstate:
            badname = _wincheck(ui, f, dostatus) or \
                        _charcheck(ui, f, dostatus)
            if f.lower() in seen:
                dostatus(_('%s collides with %s') % (f, seen[f.lower()]))
            else:
                seen[f.lower()] = f
                if not badname:
                    ui.note(_('\t[OK] %s\n') % f)
开发者ID:avuori,项目名称:dotfiles,代码行数:27,代码来源:caseguard.py


示例9: createpatch

 def createpatch(self, repo, name, msg, user, date, pats=[], opts={}):
     """creates a patch from the current state of the working copy"""
     fp = self.opener(name, 'w')
     ctx = repo[None]
     fp.write('# HG changeset patch\n')
     if user:
         fp.write('# User %s\n' % user)
     if date:
         fp.write('# Date %d %d\n' % date)
     parents = [p.node() for p in ctx.parents() if p]
     if parents and parents[0]:
         fp.write('# Parent  %s\n' % hex(parents[0]))
     if msg:
         if not isinstance(msg, str):
             msg = '\n'.join(msg)
         if msg and msg[-1] != '\n':
             msg += '\n'
         fp.write(msg)
     m = cmdutil.match(repo, pats, opts)
     chunks = patch.diff(repo, match = m, opts = self.diffopts(opts))
     for chunk in chunks:
         fp.write(chunk)
     fp.close()
     self.currentpatch=name
     self.persiststate()
开发者ID:axtl,项目名称:dotfiles,代码行数:25,代码来源:attic.py


示例10: qrefresh_wrapper

def qrefresh_wrapper(self, repo, *pats, **opts):
    mqmessage = opts.pop('mqmessage', None)
    mqcommit, q, r = mqcommit_info(self, repo, opts)

    diffstat = ""
    if mqcommit and mqmessage:
        if mqmessage.find("%s") != -1:
            buffer = StringIO.StringIO()
            m = cmdutil.match(repo, None, {})
            diffopts = mdiff.diffopts()
            cmdutil.diffordiffstat(self, repo, diffopts,
                                   repo.dirstate.parents()[0], None, m,
                                   stat=True, fp = buffer)
            diffstat = buffer.getvalue()
            buffer.close()

    mq.refresh(self, repo, *pats, **opts)

    if mqcommit and len(q.applied) > 0:
        patch = q.applied[-1].name
        if r is None:
            raise util.Abort("no patch repository found when using -Q option")
        mqmessage = mqmessage.replace("%p", patch)
        mqmessage = mqmessage.replace("%a", 'UPDATE')
        mqmessage = mqmessage.replace("%s", diffstat)
        commands.commit(r.ui, r, message=mqmessage)
开发者ID:hotsphink,项目名称:mqext,代码行数:26,代码来源:__init__.py


示例11: impl_hg_tree

def impl_hg_tree(repo, cid, path, names, *args):
    m = cmdutil.match(repo, pats=[path], default=path)
    data = {}
    for name in names:
        rev_iter = cmdutil.walkchangerevs(repo, m, {'rev': cid}, lambda c,f: None)
        data[name] = rev_iter.next().hex()
    return data
开发者ID:jekatgithub,项目名称:incubator-allura,代码行数:7,代码来源:benchmark-scm.py


示例12: _modified_regions

def _modified_regions(repo, patterns, **kwargs):
    opt_all = kwargs.get('all', False)
    opt_no_ignore = kwargs.get('no_ignore', False)

    # Import the match (repository file name matching helper)
    # function. Different versions of Mercurial keep it in different
    # modules and implement them differently.
    try:
        from mercurial import scmutil
        m = scmutil.match(repo[None], patterns, kwargs)
    except ImportError:
        from mercurial import cmdutil
        m = cmdutil.match(repo, patterns, kwargs)

    modified, added, removed, deleted, unknown, ignore, clean = \
        repo.status(match=m, clean=opt_all)

    if not opt_all:
        try:
            wctx = repo.workingctx()
        except:
            from mercurial import context
            wctx = context.workingctx(repo)

        files = [ (fn, all_regions) for fn in added ] + \
            [ (fn,  modregions(wctx, fn)) for fn in modified ]
    else:
        files = [ (fn, all_regions) for fn in added + modified + clean ]

    for fname, mod_regions in files:
        if opt_no_ignore or not check_ignores(fname):
            yield fname, mod_regions
开发者ID:jiangxilong,项目名称:gem5,代码行数:32,代码来源:style.py


示例13: _casecollide

def _casecollide(ui, repo, *pats, **opts):
    '''check the case of the given file against the repository. Return True
    on collisions and (optionally) print a list of problem-files.'''
    reserved = False
    colliding = False
    casefold = False

    override = opts['override'] or ui.configbool('caseguard', 'override')
    nowinchk = opts['nowincheck'] or ui.configbool('caseguard', 'nowincheck')

    if len(set(s.lower() for s in pats)) != len(pats):
        colliding = True
        ui.note(_('file list contains a possible case-fold collision\n'))

    added = repo.status()[1] + repo.status()[3]
    exclst = [item[0] for item in repo['.'].manifest().iteritems()] + added
    chklst = [item.lower() for item in exclst]
    mtch = dict(zip(chklst, exclst))
    m = cmdutil.match(repo, pats, opts)

    for f in repo.walk(m):
        flwr = f.lower()
        reserved = _wincheck(ui, f) or _charcheck(ui, f) or reserved
        if f not in repo.dirstate and f not in exclst and flwr in mtch:
            colliding = True
            ui.note(_('adding %s may cause a case-fold collision with %s\n') %
                (f, mtch[flwr]))

        mtch[flwr] = f

    casefold = not override and ((reserved and not nowinchk) or colliding)

    return casefold, colliding, reserved and not nowinchk
开发者ID:axtl,项目名称:caseguard,代码行数:33,代码来源:caseguard.py


示例14: get_matcher

def get_matcher(repo, pats=[], opts={}, showbad=True):
    '''Wrapper around cmdutil.match() that adds showbad: if false, neuter
    the match object\'s bad() method so it does not print any warnings
    about missing files or directories.'''
    match = cmdutil.match(repo, pats, opts)
    if not showbad:
        match.bad = lambda f, msg: None
    return match
开发者ID:sergio,项目名称:dotfiles,代码行数:8,代码来源:bfutil.py


示例15: changedlines

def changedlines(ui, repo, ctx1, ctx2, fns):
    lines = 0
    fmatch = cmdutil.match(repo, pats=fns)
    diff = ''.join(patch.diff(repo, ctx1.node(), ctx2.node(), fmatch))
    for l in diff.split('\n'):
        if (l.startswith("+") and not l.startswith("+++ ") or
            l.startswith("-") and not l.startswith("--- ")):
            lines += 1
    return lines
开发者ID:wangbiaouestc,项目名称:WindowsMingWMC,代码行数:9,代码来源:churn.py


示例16: cat

 def cat(self, file1, revision=None):
     "return the current or given revision of a file"
     ctx = revsingle(self.repo, revision)
     m = match(self.repo, (file1,))
     for abs in ctx.walk(m):
         data = ctx[abs].data()
         if self.decode:
             data = self.repo.wwritedata(abs, data)
         return data
开发者ID:Focus3D,项目名称:rad2py,代码行数:9,代码来源:repo_hg.py


示例17: countrate

def countrate(ui, repo, amap, *pats, **opts):
    """Calculate stats"""
    if opts.get('dateformat'):
        def getkey(ctx):
            t, tz = ctx.date()
            date = datetime.datetime(*time.gmtime(float(t) - tz)[:6])
            return date.strftime(opts['dateformat'])
    else:
        tmpl = opts.get('template', '{author|email}')
        tmpl = maketemplater(ui, repo, tmpl)
        def getkey(ctx):
            ui.pushbuffer()
            tmpl.show(ctx)
            return ui.popbuffer()

    state = {'count': 0, 'pct': 0}
    rate = {}
    df = False
    if opts.get('date'):
        df = util.matchdate(opts['date'])

    m = cmdutil.match(repo, pats, opts)
    def prep(ctx, fns):
        rev = ctx.rev()
        if df and not df(ctx.date()[0]): # doesn't match date format
            return

        key = getkey(ctx)
        key = amap.get(key, key) # alias remap
        if opts.get('changesets'):
            rate[key] = (rate.get(key, (0,))[0] + 1, 0)
        else:
            parents = ctx.parents()
            if len(parents) > 1:
                ui.note(_('Revision %d is a merge, ignoring...\n') % (rev,))
                return

            ctx1 = parents[0]
            lines = changedlines(ui, repo, ctx1, ctx, fns)
            rate[key] = [r + l for r, l in zip(rate.get(key, (0, 0)), lines)]

        if opts.get('progress'):
            state['count'] += 1
            newpct = int(100.0 * state['count'] / max(len(repo), 1))
            if state['pct'] < newpct:
                state['pct'] = newpct
                ui.write("\r" + _("generating stats: %d%%") % state['pct'])
                sys.stdout.flush()

    for ctx in cmdutil.walkchangerevs(repo, m, opts, prep):
        continue

    if opts.get('progress'):
        ui.write("\r")
        sys.stdout.flush()

    return rate
开发者ID:Frostman,项目名称:intellij-community,代码行数:57,代码来源:churn.py


示例18: _status

def _status(ui, repo, kwt, *pats, **opts):
    '''Bails out if [keyword] configuration is not active.
    Returns status of working directory.'''
    if kwt:
        return repo.status(match=cmdutil.match(repo, pats, opts), clean=True,
                           unknown=opts.get('unknown') or opts.get('all'))
    if ui.configitems('keyword'):
        raise util.Abort(_('[keyword] patterns cannot match'))
    raise util.Abort(_('no [keyword] patterns configured'))
开发者ID:MezzLabs,项目名称:mercurial,代码行数:9,代码来源:keyword.py


示例19: commit

 def commit(self, filepaths, message):
     "commit the specified files or all outstanding changes"
     oldid = self.repo[self.repo.lookup('.')]
     user = date = None
     m = match(self.repo, filepaths)
     node = self.repo.commit(message, user, date, m)
     if self.repo[self.repo.lookup('.')] == oldid:
         return None # no changes
     return True # sucess
开发者ID:Focus3D,项目名称:rad2py,代码行数:9,代码来源:repo_hg.py


示例20: countrate

def countrate(ui, repo, amap, *pats, **opts):
    """Calculate stats"""
    if opts.get('dateformat'):
        def getkey(ctx):
            t, tz = ctx.date()
            date = datetime.datetime(*time.gmtime(float(t) - tz)[:6])
            return date.strftime(opts['dateformat'])
    else:
        tmpl = opts.get('template', '{author|email}')
        tmpl = maketemplater(ui, repo, tmpl)
        def getkey(ctx):
            ui.pushbuffer()
            tmpl.show(ctx)
            return ui.popbuffer()

    state = {'count': 0}
    rate = {}
    df = False
    if opts.get('date'):
        df = util.matchdate(opts['date'])

    m = cmdutil.match(repo, pats, opts)
    def prep(ctx, fns):
        rev = ctx.rev()
        if df and not df(ctx.date()[0]): # doesn't match date format
            return

        key = getkey(ctx)
        key = amap.get(key, key) # alias remap
        key = key.strip() # ignore leading and trailing spaces
        if opts.get('changesets'):
            rate[key] = (rate.get(key, (0,))[0] + 1, 0)
        else:
            parents = ctx.parents()
            if len(parents) > 1:
                ui.note(_('Revision %d is a merge, ignoring...\n') % (rev,))
                return

            ctx1 = parents[0]
            lines = changedlines(ui, repo, ctx1, ctx, fns)
            rate[key] = [r + l for r, l in zip(rate.get(key, (0, 0)), lines)]

        state['count'] += 1
        ui.progress(_('analyzing'), state['count'], total=len(repo))

    for ctx in cmdutil.walkchangerevs(repo, m, opts, prep):
        continue

    ui.progress(_('analyzing'), None)

    return rate
开发者ID:MezzLabs,项目名称:mercurial,代码行数:51,代码来源:churn.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python cmdutil.show_changeset函数代码示例发布时间:2022-05-27
下一篇:
Python cmdutil.findcmd函数代码示例发布时间: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