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


Python match.match函数代码示例

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


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

示例1: gignore

def gignore(root, files, warn, extrapatterns=None):
    allpats = []
    pats = []
    if ignoremod:
        pats = ignore.readpats(root, files, warn)
        for f, patlist in pats:
            allpats.extend(patlist)
    else:
        allpats.extend(['include:%s' % f for f in files])

    if extrapatterns:
        allpats.extend(extrapatterns)
    if not allpats:
        return util.never
    try:
        ignorefunc = matchmod.match(root, '', [], allpats)
    except util.Abort:
        for f, patlist in pats:
            try:
                matchmod.match(root, '', [], patlist)
            except util.Abort, inst:
                raise util.Abort('%s: %s' % (f, inst[0]))
        if extrapatterns:
            try:
                matchmod.match(root, '', [], extrapatterns)
            except util.Abort, inst:
                raise util.Abort('%s: %s' % ('extra patterns', inst[0]))
开发者ID:schacon,项目名称:hg-git,代码行数:27,代码来源:gitdirstate.py

示例2: addEntry

 def addEntry(self):
     newfilter = hglib.fromunicode(self.le.text()).strip()
     if newfilter == '':
         return
     self.le.clear()
     if self.recombo.currentIndex() == 0:
         test = 'glob:' + newfilter
         try:
             match.match(self.repo.root, '', [], [test])
             self.insertFilters([newfilter], False)
         except util.Abort, inst:
             qtlib.WarningMsgBox(_('Invalid glob expression'), str(inst),
                                 parent=self)
             return
开发者ID:velorientc,项目名称:git_test7,代码行数:14,代码来源:hgignore.py

示例3: testSetGetNodeSuffix

    def testSetGetNodeSuffix(self):
        clean = self.parsemanifest(A_SHORT_MANIFEST)
        m = self.parsemanifest(A_SHORT_MANIFEST)
        h = m['foo']
        f = m.flags('foo')
        want = h + 'a'
        # Merge code wants to set 21-byte fake hashes at times
        m['foo'] = want
        self.assertEqual(want, m['foo'])
        self.assertEqual([('bar/baz/qux.py', BIN_HASH_2),
                          ('foo', BIN_HASH_1 + 'a')],
                         list(m.iteritems()))
        # Sometimes it even tries a 22-byte fake hash, but we can
        # return 21 and it'll work out
        m['foo'] = want + '+'
        self.assertEqual(want, m['foo'])
        # make sure the suffix survives a copy
        match = matchmod.match('', '', ['re:foo'])
        m2 = m.matches(match)
        self.assertEqual(want, m2['foo'])
        self.assertEqual(1, len(m2))
        m2 = m.copy()
        self.assertEqual(want, m2['foo'])
        # suffix with iteration
        self.assertEqual([('bar/baz/qux.py', BIN_HASH_2),
                          ('foo', want)],
                         list(m.iteritems()))

        # shows up in diff
        self.assertEqual({'foo': ((want, f), (h, ''))}, m.diff(clean))
        self.assertEqual({'foo': ((h, ''), (want, f))}, clean.diff(m))
开发者ID:Distrotech,项目名称:mercurial,代码行数:31,代码来源:test-manifest.py

示例4: promptForLfiles

def promptForLfiles(parent, ui, repo, files):
    lfiles = []
    uself = 'largefiles' in repo.extensions()
    section = 'largefiles'
    try:
        minsize = int(ui.config(section, 'minsize', default='10'))
    except ValueError:
        minsize = 10
    patterns = ui.config(section, 'patterns', default=())
    if patterns:
        patterns = patterns.split(' ')
        matcher = match.match(repo.root, '', list(patterns))
    else:
        matcher = None
    for wfile in files:
        if matcher and matcher(wfile):
            # patterns have always precedence over size
            lfiles.append(wfile)
        else:
            # check for minimal size
            filesize = os.path.getsize(repo.wjoin(wfile))
            if filesize > minsize*1024*1024:
                lfiles.append(wfile)
    if lfiles:
        ret = LfilesPrompt(parent, files).run()
        if ret == 0:
            # add as largefiles/bfiles
            for lfile in lfiles:
                files.remove(lfile)
        elif ret == 1:
            # add as normal files
            lfiles = []
        elif ret == 2:
            return None
    return files, lfiles
开发者ID:gilshwartz,项目名称:tortoisehg-caja,代码行数:35,代码来源:lfprompt.py

示例5: isignored

def isignored(ui, repo, path, **opts):
    """Find ignore rule for file or directory, specified in PATH parameter
    """
    if not os.path.exists(path):
        raise util.Abort("Specified path does not exist")

    if not os.path.exists("{0}/.hgignore".format(repo.root)):
        raise util.Abort(".hgignore file not found")

    pats = ignore.readpats(repo.root, ['.hgignore'], 0)

    allpats = []
    for f, patlist in pats:
        allpats.extend(patlist)
    if not allpats:
        return util.never

    for p in patlist:
        matcher = match.match(repo.root, '', [], [p])
        if matcher(path):
            print("Path '{0}' is ignored by:".format(path))
            print(p)
            return

    print("Path '{0}' is not ignored".format(path))
开发者ID:pcdude2143,项目名称:dotfiles,代码行数:25,代码来源:hg-isignored.py

示例6: post_save

    def post_save(cls, request, form, template_path):
        dir = os.path.dirname(template_path) + os.sep
        file = os.path.basename(template_path)

        if request.user.first_name and request.user.last_name:
            author = "%s %s" % (request.user.first_name, request.user.last_name)
        else:
            author = request.user.username

        message = form.cleaned_data['commitmessage'] or '--'

        path = TEMPLATESADMIN_HG_ROOT
        if path is None:
            for template_dir in settings.TEMPLATE_DIRS:
                if dir.startswith(template_dir):
                    if path is None or len(templare_dir)>len(path):
                        path = template_dir
        if path is None:
            raise TemplatesAdminException("Could not find template base directory")
        uio = ui.ui()
        uio.setconfig('ui', 'interactive', False)
        uio.setconfig('ui', 'report_untrusted', False)
        uio.setconfig('ui', 'quiet', True)
        repo = hg.repository(uio, path=path)
        filter = match.match(repo.root, dir, [file])
        repo.commit(match=filter, text=message, user="%s <%s>" % (author, request.user.email))

        return "Template '%s' was committed succesfully into mercurial repository." % file
开发者ID:Azarn,项目名称:django-templatesadmin,代码行数:28,代码来源:hgcommit.py

示例7: makechangegroup

def makechangegroup(orig, repo, outgoing, version, source, *args, **kwargs):
    if not requirement in repo.requirements:
        return orig(repo, outgoing, version, source, *args, **kwargs)

    original = repo.shallowmatch
    try:
        # if serving, only send files the clients has patterns for
        if source == 'serve':
            bundlecaps = kwargs.get('bundlecaps')
            includepattern = None
            excludepattern = None
            for cap in (bundlecaps or []):
                if cap.startswith("includepattern="):
                    raw = cap[len("includepattern="):]
                    if raw:
                        includepattern = raw.split('\0')
                elif cap.startswith("excludepattern="):
                    raw = cap[len("excludepattern="):]
                    if raw:
                        excludepattern = raw.split('\0')
            if includepattern or excludepattern:
                repo.shallowmatch = match.match(repo.root, '', None,
                    includepattern, excludepattern)
            else:
                repo.shallowmatch = match.always(repo.root, '')
        return orig(repo, outgoing, version, source, *args, **kwargs)
    finally:
        repo.shallowmatch = original
开发者ID:davidshepherd7,项目名称:dotfiles,代码行数:28,代码来源:shallowbundle.py

示例8: _findeditor

def _findeditor(repo, files):
    '''returns tuple of editor name and editor path.

    tools matched by pattern are returned as (name, toolpath)
    tools detected by search are returned as (name, toolpath)
    tortoisehg.editor is returned as         (None, tortoisehg.editor)
    HGEDITOR or ui.editor are returned as    (None, ui.editor)

    So first return value is an [editor-tool] name or None and
    second return value is a toolpath or user configured command line
    '''
    ui = repo.ui

    # first check for tool specified by file patterns.  The first file pattern
    # which matches one of the files being edited selects the editor
    for pat, tool in ui.configitems("editor-patterns"):
        mf = match.match(repo.root, '', [pat])
        toolpath = _findtool(ui, tool)
        if mf(files[0]) and toolpath:
            return (tool, util.shellquote(toolpath))

    # then editor-tools
    tools = {}
    for k, v in ui.configitems("editor-tools"):
        t = k.split('.')[0]
        if t not in tools:
            try:
                priority = int(_toolstr(ui, t, "priority", "0"))
            except ValueError, e:
                priority = -100
            tools[t] = priority
开发者ID:seewindcn,项目名称:tortoisehg,代码行数:31,代码来源:editor.py

示例9: __init__

    def __init__(self, ui, root, data):
        self._decode = {"LF": "to-lf", "CRLF": "to-crlf", "BIN": "is-binary"}
        self._encode = {"LF": "to-lf", "CRLF": "to-crlf", "BIN": "is-binary"}

        self.cfg = config.config()
        # Our files should not be touched. The pattern must be
        # inserted first override a '** = native' pattern.
        self.cfg.set("patterns", ".hg*", "BIN", "eol")
        # We can then parse the user's patterns.
        self.cfg.parse(".hgeol", data)

        isrepolf = self.cfg.get("repository", "native") != "CRLF"
        self._encode["NATIVE"] = isrepolf and "to-lf" or "to-crlf"
        iswdlf = ui.config("eol", "native", os.linesep) in ("LF", "\n")
        self._decode["NATIVE"] = iswdlf and "to-lf" or "to-crlf"

        include = []
        exclude = []
        for pattern, style in self.cfg.items("patterns"):
            key = style.upper()
            if key == "BIN":
                exclude.append(pattern)
            else:
                include.append(pattern)
        # This will match the files for which we need to care
        # about inconsistent newlines.
        self.match = match.match(root, "", [], include, exclude)
开发者ID:areshero,项目名称:ThirdWorldApp,代码行数:27,代码来源:eol.py

示例10: buildmatch

def buildmatch(ui, repo, user, key):
    '''return tuple of (match function, list enabled).'''
    if not ui.has_section(key):
        ui.debug('acl: %s not enabled\n' % key)
        return None

    pats = [pat for pat, users in ui.configitems(key)
            if _usermatch(ui, user, users)]
    ui.debug('acl: %s enabled, %d entries for user %s\n' %
             (key, len(pats), user))

    # Branch-based ACL
    if not repo:
        if pats:
            # If there's an asterisk (meaning "any branch"), always return True;
            # Otherwise, test if b is in pats
            if '*' in pats:
                return util.always
            return lambda b: b in pats
        return util.never

    # Path-based ACL
    if pats:
        return match.match(repo.root, '', pats)
    return util.never
开发者ID:pierfort123,项目名称:mercurial,代码行数:25,代码来源:acl.py

示例11: get_gitdiff

def get_gitdiff(filenode_old, filenode_new):
    """Returns mercurial style git diff between given
    ``filenode_old`` and ``filenode_new``.
    """

    for filenode in (filenode_old, filenode_new):
        if not isinstance(filenode, FileNode):
            raise VCSError("Given object should be FileNode object, not %s"
                % filenode.__class__)

    repo = filenode_new.changeset.repository

    old_raw_id = getattr(filenode_old.changeset, 'raw_id', '0' * 40)
    new_raw_id = getattr(filenode_new.changeset, 'raw_id', '0' * 40)

    root = filenode_new.changeset.repository.path

    file_filter = match(root, '', [filenode_new.path])

    if isinstance(repo, MercurialRepository):

        vcs_gitdiff = patch.diff(repo._repo,
                          old_raw_id,
                          new_raw_id,
                          match=file_filter,
                          opts=diffopts(git=True))

    else:
        vcs_gitdiff = repo._get_diff(old_raw_id, new_raw_id, filenode_new.path)

    return vcs_gitdiff
开发者ID:lukaszb,项目名称:vcs,代码行数:31,代码来源:diffs.py

示例12: getchangegroup

def getchangegroup(orig, repo, source, heads=None, common=None, bundlecaps=None):
    if not requirement in repo.requirements:
        return orig(repo, source, heads=heads, common=common,
                    bundlecaps=bundlecaps)

    original = repo.shallowmatch
    try:
        # if serving, only send files the clients has patterns for
        if source == 'serve':
            includepattern = None
            excludepattern = None
            for cap in (bundlecaps or []):
                if cap.startswith("includepattern="):
                    raw = cap[len("includepattern="):]
                    if raw:
                        includepattern = raw.split('\0')
                elif cap.startswith("excludepattern="):
                    raw = cap[len("excludepattern="):]
                    if raw:
                        excludepattern = raw.split('\0')
            if includepattern or excludepattern:
                repo.shallowmatch = match.match(repo.root, '', None,
                    includepattern, excludepattern)
            else:
                repo.shallowmatch = match.always(repo.root, '')
        return orig(repo, source, heads, common, bundlecaps)
    finally:
        repo.shallowmatch = original
开发者ID:pycontribs,项目名称:remotefilelog,代码行数:28,代码来源:shallowbundle.py

示例13: __init__

    def __init__(self, ui, root, data):
        self._decode = {'LF': 'to-lf', 'CRLF': 'to-crlf', 'BIN': 'is-binary'}
        self._encode = {'LF': 'to-lf', 'CRLF': 'to-crlf', 'BIN': 'is-binary'}

        self.cfg = config.config()
        # Our files should not be touched. The pattern must be
        # inserted first override a '** = native' pattern.
        self.cfg.set('patterns', '.hg*', 'BIN')
        # We can then parse the user's patterns.
        self.cfg.parse('.hgeol', data)

        isrepolf = self.cfg.get('repository', 'native') != 'CRLF'
        self._encode['NATIVE'] = isrepolf and 'to-lf' or 'to-crlf'
        iswdlf = ui.config('eol', 'native', os.linesep) in ('LF', '\n')
        self._decode['NATIVE'] = iswdlf and 'to-lf' or 'to-crlf'

        include = []
        exclude = []
        for pattern, style in self.cfg.items('patterns'):
            key = style.upper()
            if key == 'BIN':
                exclude.append(pattern)
            else:
                include.append(pattern)
        # This will match the files for which we need to care
        # about inconsistent newlines.
        self.match = match.match(root, '', [], include, exclude)
开发者ID:Pelonza,项目名称:Learn2Mine-Main,代码行数:27,代码来源:eol.py

示例14: dirty

def dirty(repo, filepath):
    if not hasattr(repo, '__getitem__'):
        vim_throw('statuns', repo.path)
    m=match.match(None, None, [filepath], exact=True)
    status=repo.status(match=m, unknown=True)
    if any(status[:-2]):
        vim.command('let r=1')
开发者ID:andreiglingeanu,项目名称:dotvim,代码行数:7,代码来源:aumercurial.py

示例15: status

	def status(self, path=None):
		'''Return status of repository or file.

		Without file argument: returns status of the repository:

		:"D?": dirty (tracked modified files: added, removed, deleted, modified),
		:"?U": untracked-dirty (added, but not tracked files)
		:None: clean (status is empty)

		With file argument: returns status of this file: "M"odified, "A"dded,
		"R"emoved, "D"eleted (removed from filesystem, but still tracked),
		"U"nknown, "I"gnored, (None)Clean.
		'''
		repo = self._repo()
		if path:
			m = match.match(None, None, [path], exact=True)
			statuses = repo.status(match=m, unknown=True, ignored=True)
			for status, paths in zip(self.statuses, statuses):
				if paths:
					return status
			return None
		else:
			resulting_status = 0
			for status, paths in zip(self.repo_statuses, repo.status(unknown=True)):
				if paths:
					resulting_status |= status
			return self.repo_statuses_str[resulting_status]
开发者ID:dangerous,项目名称:dotfiles,代码行数:27,代码来源:mercurial.py


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