本文整理汇总了Python中mercurial.scmutil.match函数的典型用法代码示例。如果您正苦于以下问题:Python match函数的具体用法?Python match怎么用?Python match使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了match函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: perfwalk
def perfwalk(ui, repo, *pats):
try:
m = scmutil.match(repo[None], pats, {})
timer(lambda: len(list(repo.dirstate.walk(m, [], True, False))))
except Exception:
try:
m = scmutil.match(repo[None], pats, {})
timer(lambda: len([b for a, b, c in repo.dirstate.statwalk([], m)]))
except Exception:
timer(lambda: len(list(cmdutil.walk(repo, pats, {}))))
开发者ID:chuchiperriman,项目名称:hg-stable,代码行数:10,代码来源:perf.py
示例2: _get_files
def _get_files(repo, patterns, options):
"""Return all files in the working directory that match the
patterns and are tracked (clean, modified or added). Ignored or
unknown files are only matched when given literally.
If patterns is empty, match all tracked files.
Supports options['include'] and options['exclude'] which work like
the --include and --exclude options of hg status.
"""
ctx = repo[None]
match = match_func(repo, ctx, patterns, options)
try:
ctx.status(listclean=True, listignored=True, listunknown=True)
except TypeError:
# Compatibility with older Mercurial versions.
ctx.status(clean=True, ignored=True, unknown=True)
files = []
for file_list in [ctx.clean(), ctx.modified(), ctx.added()]:
for filename in file_list:
if match(filename):
files.append(filename)
for file_list in [ctx.ignored(), ctx.unknown()]:
for filename in file_list:
if match.exact(filename):
files.append(filename)
return files
开发者ID:harmankumar,项目名称:AI-Assignment3,代码行数:27,代码来源:uncrustify.py
示例3: getstandinmatcher
def getstandinmatcher(repo, rmatcher=None):
'''Return a match object that applies rmatcher to the standin directory'''
standindir = repo.wjoin(shortname)
# no warnings about missing files or directories
badfn = lambda f, msg: None
if rmatcher and not rmatcher.always():
pats = [os.path.join(standindir, pat) for pat in rmatcher.files()]
match = scmutil.match(repo[None], pats, badfn=badfn)
# if pats is empty, it would incorrectly always match, so clear _always
match._always = False
else:
# no patterns: relative to repo root
match = scmutil.match(repo[None], [standindir], badfn=badfn)
return match
开发者ID:pierfort123,项目名称:mercurial,代码行数:16,代码来源:lfutil.py
示例4: badd
def badd(ui, repo, *pats, **opts):
"""add the specified files to big files repo
If no names are given, add all files to the repository.
"""
setignores(ui)
ds = read_bigfiledirstate(ui, repo)
bigfiles = parse_bigfiles(repo)
bad = []
exacts = {}
names = []
m = scmutil.match(repo[None], pats, opts)
oldbad = m.bad
m.bad = lambda x,y: bad.append(x) or oldbad(x,y)
for f in repo.walk(m):
exact = m.exact(f)
if exact or f not in repo.dirstate:
names.append(f)
if ui.verbose or not exact:
ui.status(_('adding %s\n') % m.rel(f))
if not opts.get('dry_run'):
brepo = bigfiles_repo(ui)
_updatebigrepo(ui, repo, names, brepo, bigfiles, ds)
write_dotbigfilesfile(repo, bigfiles)
write_bigfiledirstate(ui, repo, ds)
return bad and 1 or 0
开发者ID:vorou,项目名称:config,代码行数:29,代码来源:bigfiles.py
示例5: _nothingtoshelvemessaging
def _nothingtoshelvemessaging(ui, repo, pats, opts):
stat = repo.status(match=scmutil.match(repo[None], pats, opts))
if stat.deleted:
ui.status(_("nothing changed (%d missing files, see "
"'hg status')\n") % len(stat.deleted))
else:
ui.status(_("nothing changed\n"))
开发者ID:davidshepherd7,项目名称:dotfiles,代码行数:7,代码来源:obsshelve.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 = scmutil.revpair(repo, [])
m = scmutil.match(repo[node2], 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:chuchiperriman,项目名称:hg-stable,代码行数:33,代码来源:autodiff.py
示例7: _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
示例8: _amend
def _amend(orig, ui, repo, old, extra, pats, opts):
# Only wrap if not disabled and repo is instance of
# localrepo.localrepository
if _disabled[0] or not isinstance(repo, localrepo.localrepository):
return orig(ui, repo, old, extra, pats, opts)
with repo.wlock(), repo.lock(), repo.transaction('dirsyncamend'):
wctx = repo[None]
matcher = scmutil.match(wctx, pats, opts)
if (opts.get('addremove')
and scmutil.addremove(repo, matcher, "", opts)):
raise error.Abort(
_("failed to mark all new/missing files as added/removed"))
mirroredfiles = _updateworkingcopy(repo, matcher)
if mirroredfiles and not matcher.always():
# Ensure that all the files to be amended (original + synced) are
# under consideration during the amend operation. We do so by
# setting the value against 'include' key in opts as the only source
# of truth.
pats = ()
opts['include'] = [
f for f in wctx.files() if matcher(f)] + list(mirroredfiles)
return orig(ui, repo, old, extra, pats, opts)
开发者ID:davidshepherd7,项目名称:dotfiles,代码行数:25,代码来源:dirsync.py
示例9: 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
示例10: archive
def archive(web, req, tmpl):
type_ = req.form.get('type', [None])[0]
allowed = web.configlist("web", "allow_archive")
key = req.form['node'][0]
if type_ not in web.archives:
msg = 'Unsupported archive type: %s' % type_
raise ErrorResponse(HTTP_NOT_FOUND, msg)
if not ((type_ in allowed or
web.configbool("web", "allow" + type_, False))):
msg = 'Archive type not allowed: %s' % type_
raise ErrorResponse(HTTP_FORBIDDEN, msg)
reponame = re.sub(r"\W+", "-", os.path.basename(web.reponame))
cnode = web.repo.lookup(key)
arch_version = key
if cnode == key or key == 'tip':
arch_version = short(cnode)
name = "%s-%s" % (reponame, arch_version)
ctx = webutil.changectx(web.repo, req)
pats = []
matchfn = scmutil.match(ctx, [])
file = req.form.get('file', None)
if file:
pats = ['path:' + file[0]]
matchfn = scmutil.match(ctx, pats, default='path')
if pats:
files = [f for f in ctx.manifest().keys() if matchfn(f)]
if not files:
raise ErrorResponse(HTTP_NOT_FOUND,
'file(s) not found: %s' % file[0])
mimetype, artype, extension, encoding = web.archive_specs[type_]
headers = [
('Content-Disposition', 'attachment; filename=%s%s' % (name, extension))
]
if encoding:
headers.append(('Content-Encoding', encoding))
req.headers.extend(headers)
req.respond(HTTP_OK, mimetype)
archival.archive(web.repo, req, cnode, artype, prefix=name,
matchfn=matchfn,
subrepos=web.configbool("web", "archivesubrepos"))
return []
开发者ID:ZanderZhang,项目名称:Andriod-Learning,代码行数:47,代码来源:webcommands.py
示例11: override_remove
def override_remove(orig, ui, repo, *pats, **opts):
manifest = repo[None].manifest()
installnormalfilesmatchfn(manifest)
orig(ui, repo, *pats, **opts)
restorematchfn()
after, force = opts.get('after'), opts.get('force')
if not pats and not after:
raise util.Abort(_('no files specified'))
m = scmutil.match(repo[None], pats, opts)
try:
repo.lfstatus = True
s = repo.status(match=m, clean=True)
finally:
repo.lfstatus = False
modified, added, deleted, clean = [[f for f in list
if lfutil.standin(f) in manifest]
for list in [s[0], s[1], s[3], s[6]]]
def warn(files, reason):
for f in files:
ui.warn(_('not removing %s: %s (use -f to force removal)\n')
% (m.rel(f), reason))
if force:
remove, forget = modified + deleted + clean, added
elif after:
remove, forget = deleted, []
warn(modified + added + clean, _('file still exists'))
else:
remove, forget = deleted + clean, []
warn(modified, _('file is modified'))
warn(added, _('file has been marked for add'))
for f in sorted(remove + forget):
if ui.verbose or not m.exact(f):
ui.status(_('removing %s\n') % m.rel(f))
# Need to lock because standin files are deleted then removed from the
# repository and we could race inbetween.
wlock = repo.wlock()
try:
lfdirstate = lfutil.openlfdirstate(ui, repo)
for f in remove:
if not after:
os.unlink(repo.wjoin(f))
currentdir = os.path.split(f)[0]
while currentdir and not os.listdir(repo.wjoin(currentdir)):
os.rmdir(repo.wjoin(currentdir))
currentdir = os.path.split(currentdir)[0]
lfdirstate.remove(f)
lfdirstate.write()
forget = [lfutil.standin(f) for f in forget]
remove = [lfutil.standin(f) for f in remove]
lfutil.repo_forget(repo, forget)
lfutil.repo_remove(repo, remove, unlink=True)
finally:
wlock.release()
开发者ID:mortonfox,项目名称:cr48,代码行数:59,代码来源:overrides.py
示例12: foamdiff
def foamdiff(ui, repo, *files, **opts):
'''
Compare two OpenFOAM-dictionaries for semantic differences
Very simple. Uses pyFoamCompareDictionary.py and does not pass
options along to it
'''
revs = opts.get('rev')
change = opts.get('change')
if len(files)==0:
raise util.Abort("No files specified")
if revs and change:
msg = _('cannot specify --rev and --change at the same time')
raise util.Abort(msg)
elif change:
node2 = repo.lookup(change)
node1a, node1b = repo.changelog.parents(node2)
else:
node1a, node2 = scmutil.revpair(repo, revs)
if not revs:
node1b = repo.dirstate.parents()[1]
else:
node1b = nullid
if node1b!=nullid:
raise util.Abort("Can't do 3-way comparisons")
matcher = scmutil.match(repo[node2], files, opts)
mod_a, add_a, rem_a = map(set, repo.status(node1a, node2, matcher)[:3])
modadd = mod_a | add_a
common = modadd | rem_a
if not common:
return 0
tmproot = tempfile.mkdtemp(prefix='foamdiff.')
ui.debug("Writing temporary files to %s\n" %tmproot)
try:
dir1a_files = mod_a | rem_a
dir1a=snapshot(ui, repo, dir1a_files, node1a, tmproot)[0]
dir2root = tmproot
if node2:
dir2=snapshot(ui, repo, modadd, node2, tmproot)[0]
else:
dir2=''
dir2root=repo.root
for f in common:
ui.write("\n Comparing: %s\n" %f)
f1=path.join(tmproot,dir1a,f)
f2=path.join(dir2root,dir2,f)
CompareDictionary(args=[f1,f2])
finally:
ui.note(_('cleaning up temp directory\n'))
shutil.rmtree(tmproot)
开发者ID:LeeRuns,项目名称:PyFoam,代码行数:58,代码来源:foamdiff.py
示例13: getmatcher
def getmatcher(repo, pats=[], opts={}, showbad=True):
'''Wrapper around scmutil.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 = scmutil.match(repo[None], pats, opts)
if not showbad:
match.bad = lambda f, msg: None
return match
开发者ID:sandeepprasanna,项目名称:ODOO,代码行数:9,代码来源:lfutil.py
示例14: _status
def _status(ui, repo, wctx, kwt, *pats, **opts):
'''Bails out if [keyword] configuration is not active.
Returns status of working directory.'''
if kwt:
return repo.status(match=scmutil.match(wctx, 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:leetaizhu,项目名称:Odoo_ENV_MAC_OS,代码行数:9,代码来源:keyword.py
示例15: remove_largefiles
def remove_largefiles(ui, repo, *pats, **opts):
after = opts.get('after')
if not pats and not after:
raise util.Abort(_('no files specified'))
m = scmutil.match(repo[None], pats, opts)
try:
repo.lfstatus = True
s = repo.status(match=m, clean=True)
finally:
repo.lfstatus = False
manifest = repo[None].manifest()
modified, added, deleted, clean = [[f for f in list
if lfutil.standin(f) in manifest]
for list in [s[0], s[1], s[3], s[6]]]
def warn(files, reason):
for f in files:
ui.warn(_('not removing %s: %s (use forget to undo)\n')
% (m.rel(f), reason))
if after:
remove, forget = deleted, []
warn(modified + added + clean, _('file still exists'))
else:
remove, forget = deleted + clean, []
warn(modified, _('file is modified'))
warn(added, _('file has been marked for add'))
for f in sorted(remove + forget):
if ui.verbose or not m.exact(f):
ui.status(_('removing %s\n') % m.rel(f))
# Need to lock because standin files are deleted then removed from the
# repository and we could race inbetween.
wlock = repo.wlock()
try:
lfdirstate = lfutil.openlfdirstate(ui, repo)
for f in remove:
if not after:
# If this is being called by addremove, notify the user that we
# are removing the file.
if getattr(repo, "_isaddremove", False):
ui.status(_('removing %s\n' % f))
if os.path.exists(repo.wjoin(f)):
util.unlinkpath(repo.wjoin(f))
lfdirstate.remove(f)
lfdirstate.write()
forget = [lfutil.standin(f) for f in forget]
remove = [lfutil.standin(f) for f in remove]
lfutil.repo_forget(repo, forget)
# If this is being called by addremove, let the original addremove
# function handle this.
if not getattr(repo, "_isaddremove", False):
lfutil.repo_remove(repo, remove, unlink=True)
finally:
wlock.release()
开发者ID:sandeepprasanna,项目名称:ODOO,代码行数:56,代码来源:overrides.py
示例16: add_largefiles
def add_largefiles(ui, repo, *pats, **opts):
large = opts.pop("large", None)
lfsize = lfutil.getminsize(ui, lfutil.islfilesrepo(repo), opts.pop("lfsize", None))
lfmatcher = None
if lfutil.islfilesrepo(repo):
lfpats = ui.configlist(lfutil.longname, "patterns", default=[])
if lfpats:
lfmatcher = match_.match(repo.root, "", list(lfpats))
lfnames = []
m = scmutil.match(repo[None], pats, opts)
m.bad = lambda x, y: None
wctx = repo[None]
for f in repo.walk(m):
exact = m.exact(f)
lfile = lfutil.standin(f) in wctx
nfile = f in wctx
exists = lfile or nfile
# Don't warn the user when they attempt to add a normal tracked file.
# The normal add code will do that for us.
if exact and exists:
if lfile:
ui.warn(_("%s already a largefile\n") % f)
continue
if exact or not exists:
abovemin = lfsize and os.lstat(repo.wjoin(f)).st_size >= lfsize * 1024 * 1024
if large or abovemin or (lfmatcher and lfmatcher(f)):
lfnames.append(f)
if ui.verbose or not exact:
ui.status(_("adding %s as a largefile\n") % m.rel(f))
bad = []
standins = []
# Need to lock, otherwise there could be a race condition between
# when standins are created and added to the repo.
wlock = repo.wlock()
try:
if not opts.get("dry_run"):
lfdirstate = lfutil.openlfdirstate(ui, repo)
for f in lfnames:
standinname = lfutil.standin(f)
lfutil.writestandin(repo, standinname, hash="", executable=lfutil.getexecutable(repo.wjoin(f)))
standins.append(standinname)
if lfdirstate[f] == "r":
lfdirstate.normallookup(f)
else:
lfdirstate.add(f)
lfdirstate.write()
bad += [lfutil.splitstandin(f) for f in lfutil.repo_add(repo, standins) if f in m.files()]
finally:
wlock.release()
return bad
开发者ID:songmm19900210,项目名称:galaxy-tools-prok,代码行数:56,代码来源:overrides.py
示例17: perfaddremove
def perfaddremove(ui, repo, **opts):
timer, fm = gettimer(ui, opts)
try:
oldquiet = repo.ui.quiet
repo.ui.quiet = True
matcher = scmutil.match(repo[None])
timer(lambda: scmutil.addremove(repo, matcher, "", dry_run=True))
finally:
repo.ui.quiet = oldquiet
fm.end()
开发者ID:CSCI-362-02-2015,项目名称:RedTeam,代码行数:10,代码来源:perf.py
示例18: _status
def _status(ui, repo, wctx, kwt, *pats, **opts):
"""Bails out if [keyword] configuration is not active.
Returns status of working directory."""
if kwt:
return repo.status(
match=scmutil.match(wctx, 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:pierfort123,项目名称:mercurial,代码行数:10,代码来源:keyword.py
示例19: 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 = scmutil.match(repo[None], 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).strip()
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)]
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:rybesh,项目名称:mysite-lib,代码行数:54,代码来源:churn.py
示例20: commitextra
def commitextra(ui, repo, *pats, **opts):
'''make a commit with extra fields'''
fields = opts.get('field')
extras = {}
for field in fields:
k, v = field.split('=', 1)
extras[k] = v
message = cmdutil.logmessage(ui, opts)
repo.commit(message, opts.get('user'), opts.get('date'),
match=scmutil.match(repo[None], pats, opts), extra=extras)
return 0
开发者ID:alexreg,项目名称:hg-git,代码行数:11,代码来源:commitextra.py
注:本文中的mercurial.scmutil.match函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论