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


Python cmdutil.match函数代码示例

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


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


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