本文整理汇总了Python中mercurial.util.any函数的典型用法代码示例。如果您正苦于以下问题:Python any函数的具体用法?Python any怎么用?Python any使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了any函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: verify
def verify(self, revs, contents=False):
'''Verify the existence (and, optionally, contents) of every big
file revision referenced by every changeset in revs.
Return 0 if all is well, non-zero on any errors.'''
write = self.ui.write
failed = False
write(_('searching %d changesets for largefiles\n') % len(revs))
verified = set() # set of (filename, filenode) tuples
for rev in revs:
cctx = self.repo[rev]
cset = "%d:%s" % (cctx.rev(), node.short(cctx.node()))
failed = util.any(self._verifyfile(
cctx, cset, contents, standin, verified) for standin in cctx)
numrevs = len(verified)
numlfiles = len(set([fname for (fname, fnode) in verified]))
if contents:
write(_('verified contents of %d revisions of %d largefiles\n')
% (numrevs, numlfiles))
else:
write(_('verified existence of %d revisions of %d largefiles\n')
% (numrevs, numlfiles))
return int(failed)
开发者ID:Pelonza,项目名称:Learn2Mine-Main,代码行数:27,代码来源:basestore.py
示例2: buildcmdargs
def buildcmdargs(name, *args, **opts):
r"""Build list of command-line arguments
>>> buildcmdargs('push', branch='foo')
['push', '--branch', 'foo']
>>> buildcmdargs('graft', r=['0', '1'])
['graft', '-r', '0', '-r', '1']
>>> buildcmdargs('log', no_merges=True, quiet=False, limit=None)
['log', '--no-merges']
>>> buildcmdargs('commit', user='')
['commit', '--user', '']
positional arguments:
>>> buildcmdargs('add', 'foo', 'bar')
['add', 'foo', 'bar']
>>> buildcmdargs('cat', '-foo', rev='0')
['cat', '--rev', '0', '--', '-foo']
type conversion to string:
>>> from PyQt4.QtCore import QString
>>> buildcmdargs('email', r=[0, 1])
['email', '-r', '0', '-r', '1']
>>> buildcmdargs('grep', 'foo', rev=2)
['grep', '--rev', '2', 'foo']
>>> buildcmdargs('tag', u'\xc0', message=u'\xc1')
['tag', '--message', u'\xc1', u'\xc0']
>>> buildcmdargs(QString('tag'), QString(u'\xc0'), message=QString(u'\xc1'))
[u'tag', '--message', u'\xc1', u'\xc0']
"""
stringfy = '%s'.__mod__ # (unicode, QString) -> unicode, otherwise -> str
fullargs = [stringfy(name)]
for k, v in opts.iteritems():
if v is None:
continue
if len(k) == 1:
aname = '-%s' % k
else:
aname = '--%s' % k.replace('_', '-')
if isinstance(v, bool):
if v:
fullargs.append(aname)
elif isinstance(v, list):
for e in v:
fullargs.append(aname)
fullargs.append(stringfy(e))
else:
fullargs.append(aname)
fullargs.append(stringfy(v))
args = map(stringfy, args)
if util.any(e.startswith('-') for e in args):
fullargs.append('--')
fullargs.extend(args)
return fullargs
开发者ID:velorientc,项目名称:git_test7,代码行数:59,代码来源:hglib.py
示例3: _updateAnnotateOption
def _updateAnnotateOption(self):
# make sure at least one option is checked
if not util.any(a.isChecked() for a in self._annoptactions):
self.sender().setChecked(True)
self._setupLineAnnotation()
self.fillModel()
self._saveAnnotateSettings()
开发者ID:gilshwartz,项目名称:tortoisehg-caja,代码行数:8,代码来源:fileview.py
示例4: pathinstatus
def pathinstatus(path, status, uncleanpaths):
"""Test path is included by the status filter"""
if util.any(c in self._statusfilter and path in e
for c, e in status.iteritems()):
return True
if 'C' in self._statusfilter and path not in uncleanpaths:
return True
return False
开发者ID:velorientc,项目名称:git_test7,代码行数:8,代码来源:manifestmodel.py
示例5: _loadAnnotateSettings
def _loadAnnotateSettings(self):
s = QSettings()
wb = "Annotate/"
for a in self._annoptactions:
a.setChecked(s.value(wb + a.data().toString()).toBool())
if not util.any(a.isChecked() for a in self._annoptactions):
self._annoptactions[-1].setChecked(True) # 'rev' by default
self._setupLineAnnotation()
开发者ID:gilshwartz,项目名称:tortoisehg-caja,代码行数:8,代码来源:fileview.py
示例6: _updateattachmodes
def _updateattachmodes(self):
"""Update checkboxes to select the embedding style of the patch"""
attachmodes = [self._qui.attach_check, self._qui.inline_check]
body = self._qui.body_check
# --attach and --inline are exclusive
if self.sender() in attachmodes and self.sender().isChecked():
for w in attachmodes:
if w is not self.sender():
w.setChecked(False)
# --body is mandatory if no attach modes are specified
body.setEnabled(util.any(w.isChecked() for w in attachmodes))
if not body.isEnabled():
body.setChecked(True)
开发者ID:velorientc,项目名称:git_test7,代码行数:15,代码来源:hgemail.py
示例7: _asconfigliststr
def _asconfigliststr(value):
r"""
>>> _asconfigliststr('foo')
'foo'
>>> _asconfigliststr('foo bar')
'"foo bar"'
>>> _asconfigliststr('foo,bar')
'"foo,bar"'
>>> _asconfigliststr('foo "bar"')
'"foo \\"bar\\""'
"""
# ui.configlist() uses isspace(), which is locale-dependent
if util.any(c.isspace() or c == ',' for c in value):
return '"' + value.replace('"', '\\"') + '"'
else:
return value
开发者ID:velorientc,项目名称:git_test7,代码行数:16,代码来源:serve.py
示例8: _defaultlanguage
def _defaultlanguage():
if os.name != 'nt' or util.any(e in os.environ for e in _localeenvs):
return # honor posix-style env var
# On Windows, UI language can be determined by GetUserDefaultUILanguage(),
# but gettext doesn't take it into account.
# Note that locale.getdefaultlocale() uses GetLocaleInfo(), which may be
# different from UI language.
#
# For details, please read "User Interface Language Management":
# http://msdn.microsoft.com/en-us/library/dd374098(v=VS.85).aspx
try:
from ctypes import windll # requires Python>=2.5
langid = windll.kernel32.GetUserDefaultUILanguage()
return locale.windows_locale[langid]
except (ImportError, AttributeError, KeyError):
pass
开发者ID:gilshwartz,项目名称:tortoisehg-caja,代码行数:17,代码来源:i18n.py
示例9: getsearchmode
def getsearchmode(query):
try:
ctx = web.repo[query]
except (error.RepoError, error.LookupError):
# query is not an exact revision pointer, need to
# decide if it's a revset expression or keywords
pass
else:
return MODE_REVISION, ctx
revdef = 'reverse(%s)' % query
try:
tree, pos = revset.parse(revdef)
except ParseError:
# can't parse to a revset tree
return MODE_KEYWORD, query
if revset.depth(tree) <= 2:
# no revset syntax used
return MODE_KEYWORD, query
if util.any((token, (value or '')[:3]) == ('string', 're:')
for token, value, pos in revset.tokenize(revdef)):
return MODE_KEYWORD, query
funcsused = revset.funcsused(tree)
if not funcsused.issubset(revset.safesymbols):
return MODE_KEYWORD, query
mfunc = revset.match(web.repo.ui, revdef)
try:
revs = mfunc(web.repo, list(web.repo))
return MODE_REVSET, revs
# ParseError: wrongly placed tokens, wrongs arguments, etc
# RepoLookupError: no such revision, e.g. in 'revision:'
# Abort: bookmark/tag not exists
# LookupError: ambiguous identifier, e.g. in '(bc)' on a large repo
except (ParseError, RepoLookupError, Abort, LookupError):
return MODE_KEYWORD, query
开发者ID:spraints,项目名称:for-example,代码行数:39,代码来源:webcommands.py
示例10: allhunks
def allhunks(self):
return util.any(self.allhunks_re.match(h) for h in self.header)
开发者ID:jordigh,项目名称:mercurial-crew,代码行数:2,代码来源:record.py
示例11: checkrequireslfiles
def checkrequireslfiles(ui, repo, **kwargs):
if 'largefiles' not in repo.requirements and util.any(
lfutil.shortname+'/' in f[0] for f in repo.store.datafiles()):
repo.requirements.add('largefiles')
repo._writerequirements()
开发者ID:32bitfloat,项目名称:intellij-community,代码行数:5,代码来源:reposetup.py
示例12: sign
def sign(ui, repo, *revs, **opts):
"""add a signature for the current or given revision
If no revision is given, the parent of the working directory is used,
or tip if no revision is checked out.
See 'hg help dates' for a list of formats valid for -d/--date.
"""
mygpg = SSHAuthority.from_ui(ui)
sigver = "0"
sigmessage = ""
date = opts.get('date')
if date:
opts['date'] = util.parsedate(date)
if revs:
nodes = [repo.lookup(n) for n in revs]
else:
nodes = [node for node in repo.dirstate.parents()
if node != hgnode.nullid]
if len(nodes) > 1:
raise util.Abort(_('uncommitted merge - please provide a '
'specific revision'))
if not nodes:
nodes = [repo.changelog.tip()]
for n in nodes:
hexnode = hgnode.hex(n)
ui.write(_("Signing %d:%s\n") % (repo.changelog.rev(n),
hgnode.short(n)))
# build data
data = node2txt(repo, n, sigver)
sig = mygpg.sign(data)
if not sig:
raise util.Abort(_("Error while signing"))
sig = binascii.b2a_base64(sig)
sig = sig.replace("\n", "")
sigmessage += "%s %s %s\n" % (hexnode, sigver, sig)
# write it
if opts['local']:
repo.opener("localsigs", "ab").write(sigmessage)
return
msigs = match.exact(repo.root, '', ['.hgsshsigs'])
s = repo.status(match=msigs, unknown=True, ignored=True)[:6]
if util.any(s) and not opts["force"]:
raise util.Abort(_("working copy of .hgsshsigs is changed "
"(please commit .hgsshsigs manually "
"or use --force)"))
repo.wfile(".hgsshsigs", "ab").write(sigmessage)
if '.hgsshsigs' not in repo.dirstate:
repo.add([".hgsshsigs"])
if opts["no_commit"]:
return
message = opts['message']
if not message:
# we don't translate commit messages
message = "\n".join(["Added signature for changeset %s"
% hgnode.short(n)
for n in nodes])
try:
repo.commit(message, opts['user'], opts['date'], match=msigs)
except ValueError, inst:
raise util.Abort(str(inst))
开发者ID:mcrute,项目名称:hg_sshsign,代码行数:71,代码来源:__init__.py
示例13: islfilesrepo
def islfilesrepo(repo):
if ('largefiles' in repo.requirements and
util.any(shortnameslash in f[0] for f in repo.store.datafiles())):
return True
return util.any(openlfdirstate(repo.ui, repo, False))
开发者ID:ZanderZhang,项目名称:Andriod-Learning,代码行数:6,代码来源:lfutil.py
示例14: _histedit
def _histedit(ui, repo, state, *freeargs, **opts):
# TODO only abort if we try and histedit mq patches, not just
# blanket if mq patches are applied somewhere
mq = getattr(repo, 'mq', None)
if mq and mq.applied:
raise util.Abort(_('source has mq patches applied'))
# basic argument incompatibility processing
outg = opts.get('outgoing')
cont = opts.get('continue')
editplan = opts.get('edit_plan')
abort = opts.get('abort')
force = opts.get('force')
rules = opts.get('commands', '')
revs = opts.get('rev', [])
goal = 'new' # This invocation goal, in new, continue, abort
if force and not outg:
raise util.Abort(_('--force only allowed with --outgoing'))
if cont:
if util.any((outg, abort, revs, freeargs, rules, editplan)):
raise util.Abort(_('no arguments allowed with --continue'))
goal = 'continue'
elif abort:
if util.any((outg, revs, freeargs, rules, editplan)):
raise util.Abort(_('no arguments allowed with --abort'))
goal = 'abort'
elif editplan:
if util.any((outg, revs, freeargs)):
raise util.Abort(_('only --commands argument allowed with '
'--edit-plan'))
goal = 'edit-plan'
else:
if os.path.exists(os.path.join(repo.path, 'histedit-state')):
raise util.Abort(_('history edit already in progress, try '
'--continue or --abort'))
if outg:
if revs:
raise util.Abort(_('no revisions allowed with --outgoing'))
if len(freeargs) > 1:
raise util.Abort(
_('only one repo argument allowed with --outgoing'))
else:
revs.extend(freeargs)
if len(revs) == 0:
histeditdefault = ui.config('histedit', 'defaultrev')
if histeditdefault:
revs.append(histeditdefault)
if len(revs) != 1:
raise util.Abort(
_('histedit requires exactly one ancestor revision'))
replacements = []
keep = opts.get('keep', False)
# rebuild state
if goal == 'continue':
state.read()
state = bootstrapcontinue(ui, state, opts)
elif goal == 'edit-plan':
state.read()
if not rules:
comment = editcomment % (state.parentctx, node.short(state.topmost))
rules = ruleeditor(repo, ui, state.rules, comment)
else:
if rules == '-':
f = sys.stdin
else:
f = open(rules)
rules = f.read()
f.close()
rules = [l for l in (r.strip() for r in rules.splitlines())
if l and not l.startswith('#')]
rules = verifyrules(rules, repo, [repo[c] for [_a, c] in state.rules])
state.rules = rules
state.write()
return
elif goal == 'abort':
state.read()
mapping, tmpnodes, leafs, _ntm = processreplacement(state)
ui.debug('restore wc to old parent %s\n' % node.short(state.topmost))
# Recover our old commits if necessary
if not state.topmost in repo and state.backupfile:
backupfile = repo.join(state.backupfile)
f = hg.openpath(ui, backupfile)
gen = exchange.readbundle(ui, f, backupfile)
changegroup.addchangegroup(repo, gen, 'histedit',
'bundle:' + backupfile)
os.remove(backupfile)
# check whether we should update away
parentnodes = [c.node() for c in repo[None].parents()]
for n in leafs | set([state.parentctxnode]):
if n in parentnodes:
hg.clean(repo, state.topmost)
break
else:
pass
cleanupnode(ui, repo, 'created', tmpnodes)
#.........这里部分代码省略.........
开发者ID:RayFerr000,项目名称:PLTL,代码行数:101,代码来源:histedit.py
示例15: sign
def sign(ui, repo, *revs, **opts):
"""add a signature for the current or given revision
If no revision is given, the parent of the working directory is used,
or tip if no revision is checked out.
See :hg:`help dates` for a list of formats valid for -d/--date.
"""
mygpg = newgpg(ui, **opts)
sigver = "0"
sigmessage = ""
date = opts.get("date")
if date:
opts["date"] = util.parsedate(date)
if revs:
nodes = [repo.lookup(n) for n in revs]
else:
nodes = [node for node in repo.dirstate.parents() if node != hgnode.nullid]
if len(nodes) > 1:
raise util.Abort(_("uncommitted merge - please provide a " "specific revision"))
if not nodes:
nodes = [repo.changelog.tip()]
for n in nodes:
hexnode = hgnode.hex(n)
ui.write(_("signing %d:%s\n") % (repo.changelog.rev(n), hgnode.short(n)))
# build data
data = node2txt(repo, n, sigver)
sig = mygpg.sign(data)
if not sig:
raise util.Abort(_("error while signing"))
sig = binascii.b2a_base64(sig)
sig = sig.replace("\n", "")
sigmessage += "%s %s %s\n" % (hexnode, sigver, sig)
# write it
if opts["local"]:
repo.vfs.append("localsigs", sigmessage)
return
if not opts["force"]:
msigs = match.exact(repo.root, "", [".hgsigs"])
if util.any(repo.status(match=msigs, unknown=True, ignored=True)):
raise util.Abort(_("working copy of .hgsigs is changed "), hint=_("please commit .hgsigs manually"))
sigsfile = repo.wfile(".hgsigs", "ab")
sigsfile.write(sigmessage)
sigsfile.close()
if ".hgsigs" not in repo.dirstate:
repo[None].add([".hgsigs"])
if opts["no_commit"]:
return
message = opts["message"]
if not message:
# we don't translate commit messages
message = "\n".join(["Added signature for changeset %s" % hgnode.short(n) for n in nodes])
try:
editor = cmdutil.getcommiteditor(editform="gpg.sign", **opts)
repo.commit(message, opts["user"], opts["date"], match=msigs, editor=editor)
except ValueError, inst:
raise util.Abort(str(inst))
开发者ID:nixiValor,项目名称:Waterfox,代码行数:67,代码来源:gpg.py
示例16: _isinterceptable
def _isinterceptable(self, event):
if event.key() in self._keys:
return True
if util.any(event.matches(e) for e in self._keyseqs):
return True
return False
开发者ID:gilshwartz,项目名称:tortoisehg-caja,代码行数:6,代码来源:qscilib.py
示例17: islfilesrepo
def islfilesrepo(repo):
return ('largefiles' in repo.requirements and
util.any(shortname + '/' in f[0] for f in repo.store.datafiles()))
开发者ID:sandeepprasanna,项目名称:ODOO,代码行数:3,代码来源:lfutil.py
示例18: commit
def commit(self, text="", user=None, date=None, match=None,
force=False, editor=False, extra={}):
orig = super(lfiles_repo, self).commit
wlock = repo.wlock()
try:
if getattr(repo, "_isrebasing", False):
# We have to take the time to pull down the new
# largefiles now. Otherwise if we are rebasing,
# any largefiles that were modified in the
# destination changesets get overwritten, either
# by the rebase or in the first commit after the
# rebase.
lfcommands.updatelfiles(repo.ui, repo)
# Case 1: user calls commit with no specific files or
# include/exclude patterns: refresh and commit all files that
# are "dirty".
if ((match is None) or
(not match.anypats() and not match.files())):
# Spend a bit of time here to get a list of files we know
# are modified so we can compare only against those.
# It can cost a lot of time (several seconds)
# otherwise to update all standins if the largefiles are
# large.
lfdirstate = lfutil.openlfdirstate(ui, self)
dirtymatch = match_.always(repo.root, repo.getcwd())
s = lfdirstate.status(dirtymatch, [], False, False, False)
modifiedfiles = []
for i in s:
modifiedfiles.extend(i)
lfiles = lfutil.listlfiles(self)
# this only loops through largefiles that exist (not
# removed/renamed)
for lfile in lfiles:
if lfile in modifiedfiles:
if os.path.exists(self.wjoin(lfutil.standin(lfile))):
# this handles the case where a rebase is being
# performed and the working copy is not updated
# yet.
if os.path.exists(self.wjoin(lfile)):
lfutil.updatestandin(self,
lfutil.standin(lfile))
lfdirstate.normal(lfile)
for lfile in lfdirstate:
if lfile in modifiedfiles:
if not os.path.exists(
repo.wjoin(lfutil.standin(lfile))):
lfdirstate.drop(lfile)
lfdirstate.write()
return orig(text=text, user=user, date=date, match=match,
force=force, editor=editor, extra=extra)
for f in match.files():
if lfutil.isstandin(f):
raise util.Abort(
_('file "%s" is a largefile standin') % f,
hint=('commit the largefile itself instead'))
# Case 2: user calls commit with specified patterns: refresh
# any matching big files.
smatcher = lfutil.composestandinmatcher(self, match)
standins = lfutil.dirstate_walk(self.dirstate, smatcher)
# No matching big files: get out of the way and pass control to
# the usual commit() method.
if not standins:
return orig(text=text, user=user, date=date, match=match,
force=force, editor=editor, extra=extra)
# Refresh all matching big files. It's possible that the
# commit will end up failing, in which case the big files will
# stay refreshed. No harm done: the user modified them and
# asked to commit them, so sooner or later we're going to
# refresh the standins. Might as well leave them refreshed.
lfdirstate = lfutil.openlfdirstate(ui, self)
for standin in standins:
lfile = lfutil.splitstandin(standin)
if lfdirstate[lfile] <> 'r':
lfutil.updatestandin(self, standin)
lfdirstate.normal(lfile)
else:
lfdirstate.drop(lfile)
lfdirstate.write()
# Cook up a new matcher that only matches regular files or
# standins corresponding to the big files requested by the
# user. Have to modify _files to prevent commit() from
# complaining "not tracked" for big files.
lfiles = lfutil.listlfiles(repo)
match = copy.copy(match)
orig_matchfn = match.matchfn
# Check both the list of largefiles and the list of
# standins because if a largefile was removed, it
# won't be in the list of largefiles at this point
match._files += sorted(standins)
actualfiles = []
for f in match._files:
#.........这里部分代码省略.........
开发者ID:mortonfox,项目名称:cr48,代码行数:101,代码来源:reposetup.py
示例19: getchanges
def getchanges(self, rev):
parents = self.commits[rev].parents
if len(parents) > 1:
self.rebuild()
# To decide whether we're interested in rev we:
#
# - calculate what parents rev will have if it turns out we're
# interested in it. If it's going to have more than 1 parent,
# we're interested in it.
#
# - otherwise, we'll compare it with the single parent we found.
# If any of the files we're interested in is different in the
# the two revisions, we're interested in rev.
# A parent p is interesting if its mapped version (self.parentmap[p]):
# - is not SKIPREV
# - is still not in the list of parents (we don't want duplicates)
# - is not an ancestor of the mapped versions of the other parents or
# there is no parent in the same branch than the current revision.
mparents = []
knownparents = set()
branch = self.commits[rev].branch
hasbranchparent = False
for i, p1 in enumerate(parents):
mp1 = self.parentmap[p1]
if mp1 == SKIPREV or mp1 in knownparents:
continue
isancestor = util.any(p2 for p2 in parents
if p1 != p2 and mp1 != self.parentmap[p2]
and mp1 in self.wantedancestors[p2])
if not isancestor and not hasbranchparent and len(parents) > 1:
# This could be expensive, avoid unnecessary calls.
if self._cachedcommit(p1).branch == branch:
hasbranchparent = True
mparents.append((p1, mp1, i, isancestor))
knownparents.add(mp1)
# Discard parents ancestors of other parents if there is a
# non-ancestor one on the same branch than current revision.
if hasbranchparent:
mparents = [p for p in mparents if not p[3]]
wp = None
if mparents:
wp = max(p[2] for p in mparents)
mparents = [p[1] for p in mparents]
elif parents:
wp = 0
self.origparents[rev] = parents
closed = False
if 'close' in self.commits[rev].extra:
# A branch closing revision is only useful if one of its
# parents belong to the branch being closed
pbranches = [self._cachedcommit(p).branch for p in mparents]
if branch in pbranches:
closed = True
if len(mparents) < 2 and not closed and not self.wanted(rev, wp):
# We don't want this revision.
# Update our state and tell the convert process to map this
# revision to the same revision its parent as mapped to.
p = None
if parents:
p = parents[wp]
self.mark_not_wanted(rev, p)
self.convertedorder.append((rev, False, p))
self._discard(*parents)
return self.parentmap[rev]
# We want this revision.
# Rewrite the parents of the commit object
self.commits[rev].parents = mparents
self.mark_wanted(rev, parents)
self.convertedorder.append((rev, True, None))
self._discard(*parents)
# Get the real changes and do the filtering/mapping. To be
# able to get the files later on in getfile, we hide the
# original filename in the rev part of the return value.
changes, copies = self.base.getchanges(rev)
files = {}
for f, r in changes:
newf = self.filemapper(f)
if newf and (newf != f or newf not in files):
files[newf] = (f, r)
files = sorted(files.items())
ncopies = {}
for c in copies:
newc = self.filemapper(c)
if newc:
newsource = self.filemapper(copies[c])
if newsource:
ncopies[newc] = newsource
return files, ncopies
开发者ID:leetaizhu,项目名称:Odoo_ENV_MAC_OS,代码行数:97,代码来源:filemap.py
示例20: isactive
def isactive(start, end, color, line_type, children, rev):
return rev in revset and util.any(r in revset for r in children)
开发者ID:velorientc,项目名称:git_test7,代码行数:2,代码来源:repomodel.py
注:本文中的mercurial.util.any函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论