本文整理汇总了Python中mercurial.scmutil.revrange函数的典型用法代码示例。如果您正苦于以下问题:Python revrange函数的具体用法?Python revrange怎么用?Python revrange使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了revrange函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: getlogrevs
def getlogrevs(repo, pats, opts):
"""Return (revs, expr, filematcher) where revs is a list of
revision numbers, expr is a revset string built from log options
and file patterns or None, and used to filter 'revs'. If --stat or
--patch are not passed filematcher is None. Otherwise it is a
callable taking a revision number and returning a match objects
filtering the files to be detailed when displaying the revision.
"""
if not len(repo):
return [], None, None
# Default --rev value depends on --follow but --follow behaviour
# depends on revisions resolved from --rev...
follow = opts.get('follow') or opts.get('follow_first')
if opts.get('rev'):
revs = scmutil.revrange(repo, opts['rev'])
else:
if follow and len(repo) > 0:
revs = scmutil.revrange(repo, ['.:0'])
else:
revs = range(len(repo) - 1, -1, -1)
if not revs:
return [], None, None
expr, filematcher = _makelogrevset(repo, pats, opts, revs)
if expr:
# Evaluate revisions in changelog order for performance
# reasons but preserve the original sequence order in the
# filtered result.
matched = set(revset.match(repo.ui, expr)(repo, sorted(revs)))
revs = [r for r in revs if r in matched]
if not opts.get('hidden'):
# --hidden is still experimental and not worth a dedicated revset
# yet. Fortunately, filtering revision number is fast.
revs = [r for r in revs if r not in repo.changelog.hiddenrevs]
return revs, expr, filematcher
开发者ID:Pelonza,项目名称:Learn2Mine-Main,代码行数:34,代码来源:graphlog.py
示例2: delete
def delete(self, repo, patches, opts):
if not patches and not opts.get('rev'):
raise util.Abort(_('qdelete requires at least one revision or '
'patch name'))
realpatches = []
for patch in patches:
patch = self.lookup(patch, strict=True)
info = self.isapplied(patch)
if info:
raise util.Abort(_("cannot delete applied patch %s") % patch)
if patch not in self.series:
raise util.Abort(_("patch %s not in series file") % patch)
if patch not in realpatches:
realpatches.append(patch)
numrevs = 0
if opts.get('rev'):
if not self.applied:
raise util.Abort(_('no patches applied'))
revs = scmutil.revrange(repo, opts.get('rev'))
if len(revs) > 1 and revs[0] > revs[1]:
revs.reverse()
revpatches = self._revpatches(repo, revs)
realpatches += revpatches
numrevs = len(revpatches)
self._cleanup(realpatches, numrevs, opts.get('keep'))
开发者ID:peiyaoyao,项目名称:intellij-community,代码行数:28,代码来源:mq.py
示例3: squash
def squash(ui, repo, **opts):
"""Simple extension that squashes multiple revisions into a single one"""
revrange = scmutil.revrange(repo, opts["rev"])
if not revrange:
raise util.Abort(_("Please specify a revision"))
start = revrange[0]
end = revrange[-1]
revs = find_revisions(start, end, repo)
if not revs:
raise util.Abort(_("The revision %s is not an ancestor of %s\n") % (start, end))
elif len(revs) == 1:
raise util.Abort(_("Please specify a start and an end revision"))
verify_user(ui, repo, revs)
no_children(ui, repo, end)
has_parent(ui, repo, start)
verify_pending_commits(repo)
squash_revisions(ui, repo, revs, start, end)
for r in revs:
ui.status("rev: %s, owner: %s\n" % (repo[r], ui.username()))
开发者ID:cgiacomi,项目名称:squash,代码行数:29,代码来源:squash.py
示例4: check_hook
def check_hook(ui, repo, hooktype, node, **kwargs):
'''blocks commits/changesets containing tabs or trailing whitespace'''
if hooktype == 'pretxncommit':
ui.note('checkfiles: checking commit for tabs or trailing whitespace...\n')
cf = CheckFiles(ui, repo, repo.changectx(node))
return cf.check()
elif hooktype == 'pretxnchangegroup':
try:
from mercurial.scmutil import revrange
except ImportError:
# 1.8 and earlier
from mercurial.cmdutil import revrange
ui.note('checkfiles: checking incoming changes for tabs or trailing whitespace...\n')
cf = CheckFiles(ui, repo, repo[None])
fail = False
for rev in revrange(repo, ['%s::' % node]):
cf.set_changectx(repo.changectx(rev))
cf.files = cf.ctx.files()
fail = cf.check() or fail
return fail
else:
from mercurial import util
raise util.Abort(_('checkfiles: check_hook installed as unsupported hooktype: %s') %
hooktype)
开发者ID:SeanTAllen,项目名称:dotfiles,代码行数:29,代码来源:checkfiles.py
示例5: pull
def pull(orig, ui, repo, *pats, **opts):
result = orig(ui, repo, *pats, **opts)
if shallowrepo.requirement in repo.requirements:
# prefetch if it's configured
prefetchrevset = ui.config('remotefilelog', 'pullprefetch', None)
bgrepack = repo.ui.configbool('remotefilelog',
'backgroundrepack', False)
bgprefetch = repo.ui.configbool('remotefilelog',
'backgroundprefetch', False)
if prefetchrevset:
ui.status(_("prefetching file contents\n"))
revs = scmutil.revrange(repo, [prefetchrevset])
base = repo['.'].rev()
if bgprefetch:
repo.backgroundprefetch(prefetchrevset, repack=bgrepack)
else:
repo.prefetch(revs, base=base)
if bgrepack:
repackmod.backgroundrepack(repo, incremental=True)
elif bgrepack:
repackmod.backgroundrepack(repo, incremental=True)
return result
开发者ID:davidshepherd7,项目名称:dotfiles,代码行数:25,代码来源:__init__.py
示例6: graphlog
def graphlog(ui, repo, *pats, **opts):
"""show revision history alongside an ASCII revision graph
Print a revision history alongside a revision graph drawn with
ASCII characters.
Nodes printed as an @ character are parents of the working
directory.
"""
revs, expr, filematcher = getlogrevs(repo, pats, opts)
revs = sorted(revs, reverse=1)
limit = cmdutil.loglimit(opts)
if limit is not None:
revs = revs[:limit]
revdag = graphmod.dagwalker(repo, revs)
getrenamed = None
if opts.get('copies'):
endrev = None
if opts.get('rev'):
endrev = max(scmutil.revrange(repo, opts.get('rev'))) + 1
getrenamed = templatekw.getrenamedfn(repo, endrev=endrev)
displayer = show_changeset(ui, repo, opts, buffered=True)
showparents = [ctx.node() for ctx in repo[None].parents()]
generate(ui, revdag, displayer, showparents, asciiedges, getrenamed,
filematcher)
开发者ID:Pelonza,项目名称:Learn2Mine-Main,代码行数:27,代码来源:graphlog.py
示例7: _revive
def _revive(repo, rev):
"""Brings the given rev back into the repository. Finding it in backup
bundles if necessary.
"""
unfi = repo.unfiltered()
try:
ctx = unfi[rev]
except error.RepoLookupError:
# It could either be a revset or a stripped commit.
pass
else:
if ctx.obsolete():
try:
inhibit = extensions.find('inhibit')
except KeyError:
raise error.Abort(_('cannot revive %s - inhibit extension '
'is not enabled') % ctx)
else:
torevive = unfi.set('::%d & obsolete()', ctx.rev())
inhibit.revive(torevive, operation='reset')
try:
revs = scmutil.revrange(repo, [rev])
if len(revs) > 1:
raise error.Abort(_('exactly one revision must be specified'))
if len(revs) == 1:
return repo[revs.first()]
except error.RepoLookupError:
revs = []
return _pullbundle(repo, rev)
开发者ID:davidshepherd7,项目名称:dotfiles,代码行数:31,代码来源:reset.py
示例8: keepset
def keepset(repo, keyfn, lastkeepkeys=None):
"""Computes a keepset which is not garbage collected.
'keyfn' is a function that maps filename, node to a unique key.
'lastkeepkeys' is an optional argument and if provided the keepset
function updates lastkeepkeys with more keys and returns the result.
"""
if not lastkeepkeys:
keepkeys = set()
else:
keepkeys = lastkeepkeys
# We want to keep:
# 1. Working copy parent
# 2. Draft commits
# 3. Parents of draft commits
# 4. Pullprefetch and bgprefetchrevs revsets if specified
revs = ['.', 'draft()', 'parents(draft())']
prefetchrevs = repo.ui.config('remotefilelog', 'pullprefetch', None)
if prefetchrevs:
revs.append('(%s)' % prefetchrevs)
prefetchrevs = repo.ui.config('remotefilelog', 'bgprefetchrevs', None)
if prefetchrevs:
revs.append('(%s)' % prefetchrevs)
revs = '+'.join(revs)
revs = ['sort((%s), "topo")' % revs]
keep = scmutil.revrange(repo, revs)
processed = set()
lastmanifest = None
# process the commits in toposorted order starting from the oldest
for r in reversed(keep._list):
if repo[r].p1().rev() in processed:
# if the direct parent has already been processed
# then we only need to process the delta
m = repo[r].manifestctx().readdelta()
else:
# otherwise take the manifest and diff it
# with the previous manifest if one exists
if lastmanifest:
m = repo[r].manifest().diff(lastmanifest)
else:
m = repo[r].manifest()
lastmanifest = repo[r].manifest()
processed.add(r)
# populate keepkeys with keys from the current manifest
if type(m) is dict:
# m is a result of diff of two manifests and is a dictionary that
# maps filename to ((newnode, newflag), (oldnode, oldflag)) tuple
for filename, diff in m.iteritems():
if diff[0][0] is not None:
keepkeys.add(keyfn(filename, diff[0][0]))
else:
# m is a manifest object
for filename, filenode in m.iteritems():
keepkeys.add(keyfn(filename, filenode))
return keepkeys
开发者ID:davidshepherd7,项目名称:dotfiles,代码行数:60,代码来源:repack.py
示例9: lfpull
def lfpull(ui, repo, source="default", **opts):
"""pull largefiles for the specified revisions from the specified source
Pull largefiles that are referenced from local changesets but missing
locally, pulling from a remote repository to the local cache.
If SOURCE is omitted, the 'default' path will be used.
See :hg:`help urls` for more information.
.. container:: verbose
Some examples:
- pull largefiles for all branch heads::
hg lfpull -r "head() and not closed()"
- pull largefiles on the default branch::
hg lfpull -r "branch(default)"
"""
repo.lfpullsource = source
revs = opts.get('rev', [])
if not revs:
raise util.Abort(_('no revisions specified'))
revs = scmutil.revrange(repo, revs)
numcached = 0
for rev in revs:
ui.note(_('pulling largefiles for revision %s\n') % rev)
(cached, missing) = cachelfiles(ui, repo, rev)
numcached += len(cached)
ui.status(_("%d largefiles cached\n") % numcached)
开发者ID:RayFerr000,项目名称:PLTL,代码行数:34,代码来源:lfcommands.py
示例10: fastmanifesttocache
def fastmanifesttocache(repo, subset, x):
"""Revset of the interesting revisions to cache. This returns:
- Drafts
- Revisions with a bookmarks
- Revisions with some selected remote bookmarks (master, stable ...)
- Their parents (to make diff -c faster)
- TODO The base of potential rebase operations
- Filtering all of the above to only include recent changes
"""
# Add relevant remotenames to the list of interesting revs
revs = _relevantremonamesrevs(repo)
# Add all the other relevant revs
query = "(not public() & not hidden()) + bookmark()"
cutoff = repo.ui.configint("fastmanifest", "cachecutoffdays", 60)
if cutoff == -1: # no cutoff
datelimit = ""
else:
datelimit = "and date(-%d)" % cutoff
revs.update(scmutil.revrange(repo,["(%s + parents(%s)) %s"
% (query, query, datelimit)]))
metricscollector.get().recordsample("revsetsize", size=len(revs))
return subset & revs
开发者ID:davidshepherd7,项目名称:dotfiles,代码行数:26,代码来源:cachemanager.py
示例11: check_hook
def check_hook(ui, repo, hooktype, **kwargs):
"""blocks commits/changesets containing tabs or trailing whitespace"""
if hooktype == 'precommit':
ui.note('checkfiles: checking for tabs and/or trailing whitespace ' \
'in changed files...\n')
cf = CheckFiles(ui, repo, repo[None])
return cf.check()
if hooktype == 'pretxncommit':
ui.note('checkfiles: checking commit for tabs or trailing ' \
'whitespace...\n')
node = kwargs['node']
cf = CheckFiles(ui, repo, repo.changectx(node))
return cf.check()
elif hooktype == 'pretxnchangegroup':
ui.note('checkfiles: checking incoming changes for tabs or trailing ' \
'whitespace...\n')
cf = CheckFiles(ui, repo, repo[None])
fail = False
node = kwargs['node']
for rev in revrange(repo, ['%s::' % node]):
cf.set_changectx(repo.changectx(rev))
cf.files = cf.ctx.files()
fail = cf.check() or fail
return fail
else:
raise util.Abort(_('checkfiles: check_hook installed as unsupported ' \
'hooktype: %s') % hooktype)
开发者ID:jmagnusson,项目名称:hg-checkfiles,代码行数:34,代码来源:checkfiles.py
示例12: critic
def critic(ui, repo, rev='.', entire=False, **opts):
"""Perform a critique of changeset(s).
This will perform static analysis on changeset(s) and report any issues
found.
"""
for r in scmutil.revrange(repo, [rev]):
critique(ui, repo, node=r, entire=entire, **opts)
开发者ID:armenzg,项目名称:version-control-tools,代码行数:8,代码来源:__init__.py
示例13: get_revs
def get_revs(repo, rev_opt):
if rev_opt:
revs = scmutil.revrange(repo, rev_opt)
if len(revs) == 0:
return (nullrev, nullrev)
return (max(revs), min(revs))
else:
return (len(repo) - 1, 0)
开发者ID:Pelonza,项目名称:Learn2Mine-Main,代码行数:8,代码来源:graphlog.py
示例14: get_hgtags_from_heads
def get_hgtags_from_heads(ui, repo, rev):
from mercurial import scmutil
heads = scmutil.revrange(repo,['heads(%d::)' % (rev)])
head_hgtags = dict()
for h in heads:
if '.hgtags' in repo[h]:
hgtags = repo[h]['.hgtags'].data()
head_hgtags[hex(repo[h].node())] = hgtags
return head_hgtags
开发者ID:philbritton,项目名称:dotfiles-1,代码行数:9,代码来源:collapse.py
示例15: obsoleteinfo
def obsoleteinfo(repo, hgcmd):
"""Return obsolescence markers that are relevant to smartlog revset"""
unfi = repo.unfiltered()
revs = scmutil.revrange(unfi, ["smartlog()"])
hashes = '|'.join(unfi[rev].hex() for rev in revs)
markers = hgcmd(debugcommands.debugobsolete, rev=[])
pat = re.compile('(^.*(?:'+hashes+').*$)', re.MULTILINE)
relevant = pat.findall(markers)
return "\n".join(relevant)
开发者ID:davidshepherd7,项目名称:dotfiles,代码行数:9,代码来源:rage.py
示例16: getpatches
def getpatches(revs):
prev = repo['.'].rev()
for r in scmutil.revrange(repo, revs):
if r == prev and (repo[None].files() or repo[None].deleted()):
ui.warn(_('warning: working directory has '
'uncommitted changes\n'))
output = cStringIO.StringIO()
cmdutil.export(repo, [r], fp=output,
opts=patch.diffopts(ui, opts))
yield output.getvalue().split('\n')
开发者ID:ZanderZhang,项目名称:Andriod-Learning,代码行数:10,代码来源:patchbomb.py
示例17: hide
def hide(ui, repo, *revs, **opts):
"""hide changesets and their descendants
Hidden changesets are still accessible by their hashes which can be found
in ``hg journal``.
If a parent of the working directory is hidden, then the working directory
will automatically be updated to the most recent available ancestor of the
hidden parent.
If there is a bookmark pointing to the commit it will be removed.
"""
revs = list(revs) + opts.pop('rev', [])
revs = set(scmutil.revrange(repo, revs))
hidectxs = list(repo.set("(%ld)::", revs))
if not hidectxs:
raise error.Abort(_('nothing to hide'))
with repo.wlock(), repo.lock(), repo.transaction('hide') as tr:
# revs to be hidden
for ctx in hidectxs:
if not ctx.mutable():
raise error.Abort(
_('cannot hide immutable changeset: %s') % ctx,
hint="see 'hg help phases' for details")
wdp = repo['.']
newnode = wdp
while newnode in hidectxs:
newnode = newnode.parents()[0]
if newnode.node() != wdp.node():
cmdutil.bailifchanged(repo, merge=False)
hg.update(repo, newnode, False)
ui.status(_('working directory now at %s\n')
% ui.label(str(newnode), 'node'))
# create markers
obsolete.createmarkers(repo, [(r, []) for r in hidectxs],
operation='hide')
ui.status(_('%i changesets hidden\n') % len(hidectxs))
# remove bookmarks pointing to hidden changesets
hnodes = [r.node() for r in hidectxs]
bmchanges = []
for book, node in bookmarksmod.listbinbookmarks(repo):
if node in hnodes:
bmchanges.append((book, None))
repo._bookmarks.applychanges(repo, tr, bmchanges)
if len(bmchanges) > 0:
ui.status(_('%i bookmarks removed\n') % len(bmchanges))
开发者ID:davidshepherd7,项目名称:dotfiles,代码行数:54,代码来源:hide.py
示例18: email
def email(ui, repoagent, *revs, **opts):
"""send changesets by email"""
from tortoisehg.hgqt import hgemail
# TODO: same options as patchbomb
if opts.get('rev'):
if revs:
raise util.Abort(_('use only one form to specify the revision'))
revs = opts.get('rev')
repo = repoagent.rawRepo()
revs = scmutil.revrange(repo, revs)
return hgemail.EmailDialog(repoagent, revs)
开发者ID:seewindcn,项目名称:tortoisehg,代码行数:12,代码来源:run.py
示例19: get_hgtags_from_heads
def get_hgtags_from_heads(ui, repo, rev):
from mercurial import scmutil
heads = scmutil.revrange(repo,['heads(%d::)' % (rev)])
ui.debug(_('get_hgtags_from_heads: rev: %d heads: %r\n') % (rev, heads))
head_hgtags = dict()
for h in heads:
if '.hgtags' in repo[h]:
hgtags = repo[h]['.hgtags'].data()
hnode = hex(repo[h].node())
ui.debug(_('get_hgtags_from_heads: head_hgtags[%s]:\n%s\n')
% (hnode, hgtags))
head_hgtags[hnode] = hgtags
return head_hgtags
开发者ID:ellipsis-index,项目名称:zeekay-dot-files,代码行数:13,代码来源:collapse.py
示例20: __init__
def __init__(self, ui, path, rev=None):
converter_source.__init__(self, ui, path, rev)
self.ignoreerrors = ui.configbool('convert', 'hg.ignoreerrors', False)
self.ignored = set()
self.saverev = ui.configbool('convert', 'hg.saverev', False)
try:
self.repo = hg.repository(self.ui, path)
# try to provoke an exception if this isn't really a hg
# repo, but some other bogus compatible-looking url
if not self.repo.local():
raise error.RepoError
except error.RepoError:
ui.traceback()
raise NoRepo(_("%s is not a local Mercurial repository") % path)
self.lastrev = None
self.lastctx = None
self._changescache = None, None
self.convertfp = None
# Restrict converted revisions to startrev descendants
startnode = ui.config('convert', 'hg.startrev')
hgrevs = ui.config('convert', 'hg.revs')
if hgrevs is None:
if startnode is not None:
try:
startnode = self.repo.lookup(startnode)
except error.RepoError:
raise util.Abort(_('%s is not a valid start revision')
% startnode)
startrev = self.repo.changelog.rev(startnode)
children = {startnode: 1}
for r in self.repo.changelog.descendants([startrev]):
children[self.repo.changelog.node(r)] = 1
self.keep = children.__contains__
else:
self.keep = util.always
if rev:
self._heads = [self.repo[rev].node()]
else:
self._heads = self.repo.heads()
else:
if rev or startnode is not None:
raise util.Abort(_('hg.revs cannot be combined with '
'hg.startrev or --rev'))
nodes = set()
parents = set()
for r in scmutil.revrange(self.repo, [hgrevs]):
ctx = self.repo[r]
nodes.add(ctx.node())
parents.update(p.node() for p in ctx.parents())
self.keep = nodes.__contains__
self._heads = nodes - parents
开发者ID:areshero,项目名称:ThirdWorldApp,代码行数:51,代码来源:hg.py
注:本文中的mercurial.scmutil.revrange函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论