##// END OF EJS Templates
compression: introduce a `storage.revlog.zlib.level` configuration...
compression: introduce a `storage.revlog.zlib.level` configuration This option control the zlib compression level used when compression revlog chunk. This is also a good excuse to pave the way for a similar configuration option for the zstd compression engine. Having a dedicated option for each compression algorithm is useful because they don't support the same range of values. Using a higher zlib compression impact CPU consumption at compression time, but does not directly affected decompression time. However dealing with small compressed chunk can directly help decompression and indirectly help other revlog logic. I ran some basic test on repositories using different level. I am using the mercurial, pypy, netbeans and mozilla-central clone from our benchmark suite. All tested repository use sparse-revlog and got all their delta recomputed. The different compression level has a small effect on the repository size (about 10% variation in the total range). My quick analysis is that revlog mostly store small delta, that are not affected by the compression level much. So the variation probably mostly comes from better compression of the snapshots revisions, and snapshot revision only represent a small portion of the repository content. I also made some basic timings measurements. The "read" timings are gathered using simple run of `hg perfrevlogrevisions`, the "write" timings using `hg perfrevlogwrite` (restricted to the last 5000 revisions for netbeans and mozilla central). The timings are gathered on a generic machine, (not one of our performance locked machine), so small variation might not be meaningful. However large trend remains relevant. Keep in mind that these numbers are not pure compression/decompression time. They also involve the full revlog logic. In particular the difference in chunk size has an impact on the delta chain structure, affecting performance when writing or reading them. On read/write performance, the compression level has a bigger impact. Counter-intuitively, the higher compression levels improve "write" performance for the large repositories in our tested setting. Maybe because the last 5000 delta chain end up having a very different shape in this specific spot? Or maybe because of a more general trend of better delta chains thanks to the smaller chunk and snapshot. This series does not intend to change the default compression level. However, these result call for a deeper analysis of this performance difference in the future. Full data ========= repo level .hg/store size 00manifest.d read write ---------------------------------------------------------------- mercurial 1 49,402,813 5,963,475 0.170159 53.250304 mercurial 6 47,197,397 5,875,730 0.182820 56.264320 mercurial 9 47,121,596 5,849,781 0.189219 56.293612 pypy 1 370,830,572 28,462,425 2.679217 460.721984 pypy 6 340,112,317 27,648,747 2.768691 467.537158 pypy 9 338,360,736 27,639,003 2.763495 476.589918 netbeans 1 1,281,847,810 165,495,457 122.477027 520.560316 netbeans 6 1,205,284,353 159,161,207 139.876147 715.930400 netbeans 9 1,197,135,671 155,034,586 141.620281 678.297064 mozilla 1 2,775,497,186 298,527,987 147.867662 751.263721 mozilla 6 2,596,856,420 286,597,671 170.572118 987.056093 mozilla 9 2,587,542,494 287,018,264 163.622338 739.803002

File last commit:

r42161:550a172a default
r42210:1fac9b93 default
Show More
uncommit.py
223 lines | 7.8 KiB | text/x-python | PythonLexer
# uncommit - undo the actions of a commit
#
# Copyright 2011 Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
# Logilab SA <contact@logilab.fr>
# Pierre-Yves David <pierre-yves.david@ens-lyon.org>
# Patrick Mezard <patrick@mezard.eu>
# Copyright 2016 Facebook, Inc.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
"""uncommit part or all of a local changeset (EXPERIMENTAL)
This command undoes the effect of a local commit, returning the affected
files to their uncommitted state. This means that files modified, added or
removed in the changeset will be left unchanged, and so will remain modified,
added and removed in the working directory.
"""
from __future__ import absolute_import
from mercurial.i18n import _
from mercurial import (
cmdutil,
commands,
context,
copies as copiesmod,
error,
node,
obsutil,
pycompat,
registrar,
rewriteutil,
scmutil,
)
cmdtable = {}
command = registrar.command(cmdtable)
configtable = {}
configitem = registrar.configitem(configtable)
configitem('experimental', 'uncommitondirtywdir',
default=False,
)
configitem('experimental', 'uncommit.keep',
default=False,
)
# Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
# extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
# be specifying the version(s) of Mercurial they are tested with, or
# leave the attribute unspecified.
testedwith = 'ships-with-hg-core'
def _commitfiltered(repo, ctx, match, keepcommit):
"""Recommit ctx with changed files not in match. Return the new
node identifier, or None if nothing changed.
"""
base = ctx.p1()
# ctx
initialfiles = set(ctx.files())
exclude = set(f for f in initialfiles if match(f))
# No files matched commit, so nothing excluded
if not exclude:
return None
# return the p1 so that we don't create an obsmarker later
if not keepcommit:
return ctx.p1().node()
files = (initialfiles - exclude)
# Filter copies
copied = copiesmod.pathcopies(base, ctx)
copied = dict((dst, src) for dst, src in copied.iteritems()
if dst in files)
def filectxfn(repo, memctx, path, contentctx=ctx, redirect=()):
if path not in contentctx:
return None
fctx = contentctx[path]
mctx = context.memfilectx(repo, memctx, fctx.path(), fctx.data(),
fctx.islink(),
fctx.isexec(),
copysource=copied.get(path))
return mctx
if not files:
repo.ui.status(_("note: keeping empty commit\n"))
new = context.memctx(repo,
parents=[base.node(), node.nullid],
text=ctx.description(),
files=files,
filectxfn=filectxfn,
user=ctx.user(),
date=ctx.date(),
extra=ctx.extra())
return repo.commitctx(new)
@command('uncommit',
[('', 'keep', None, _('allow an empty commit after uncommiting')),
('', 'allow-dirty-working-copy', False,
_('allow uncommit with outstanding changes'))
] + commands.walkopts,
_('[OPTION]... [FILE]...'),
helpcategory=command.CATEGORY_CHANGE_MANAGEMENT)
def uncommit(ui, repo, *pats, **opts):
"""uncommit part or all of a local changeset
This command undoes the effect of a local commit, returning the affected
files to their uncommitted state. This means that files modified or
deleted in the changeset will be left unchanged, and so will remain
modified in the working directory.
If no files are specified, the commit will be pruned, unless --keep is
given.
"""
opts = pycompat.byteskwargs(opts)
with repo.wlock(), repo.lock():
m, a, r, d = repo.status()[:4]
isdirtypath = any(set(m + a + r + d) & set(pats))
allowdirtywcopy = (opts['allow_dirty_working_copy'] or
repo.ui.configbool('experimental', 'uncommitondirtywdir'))
if not allowdirtywcopy and (not pats or isdirtypath):
cmdutil.bailifchanged(repo, hint=_('requires '
'--allow-dirty-working-copy to uncommit'))
old = repo['.']
rewriteutil.precheck(repo, [old.rev()], 'uncommit')
if len(old.parents()) > 1:
raise error.Abort(_("cannot uncommit merge changeset"))
with repo.transaction('uncommit'):
match = scmutil.match(old, pats, opts)
keepcommit = pats
if not keepcommit:
if opts.get('keep') is not None:
keepcommit = opts.get('keep')
else:
keepcommit = ui.configbool('experimental', 'uncommit.keep')
newid = _commitfiltered(repo, old, match, keepcommit)
if newid is None:
ui.status(_("nothing to uncommit\n"))
return 1
mapping = {}
if newid != old.p1().node():
# Move local changes on filtered changeset
mapping[old.node()] = (newid,)
else:
# Fully removed the old commit
mapping[old.node()] = ()
with repo.dirstate.parentchange():
scmutil.movedirstate(repo, repo[newid], match)
scmutil.cleanupnodes(repo, mapping, 'uncommit', fixphase=True)
def predecessormarkers(ctx):
"""yields the obsolete markers marking the given changeset as a successor"""
for data in ctx.repo().obsstore.predecessors.get(ctx.node(), ()):
yield obsutil.marker(ctx.repo(), data)
@command('unamend', [], helpcategory=command.CATEGORY_CHANGE_MANAGEMENT,
helpbasic=True)
def unamend(ui, repo, **opts):
"""undo the most recent amend operation on a current changeset
This command will roll back to the previous version of a changeset,
leaving working directory in state in which it was before running
`hg amend` (e.g. files modified as part of an amend will be
marked as modified `hg status`)
"""
unfi = repo.unfiltered()
with repo.wlock(), repo.lock(), repo.transaction('unamend'):
# identify the commit from which to unamend
curctx = repo['.']
rewriteutil.precheck(repo, [curctx.rev()], 'unamend')
# identify the commit to which to unamend
markers = list(predecessormarkers(curctx))
if len(markers) != 1:
e = _("changeset must have one predecessor, found %i predecessors")
raise error.Abort(e % len(markers))
prednode = markers[0].prednode()
predctx = unfi[prednode]
# add an extra so that we get a new hash
# note: allowing unamend to undo an unamend is an intentional feature
extras = predctx.extra()
extras['unamend_source'] = curctx.hex()
def filectxfn(repo, ctx_, path):
try:
return predctx.filectx(path)
except KeyError:
return None
# Make a new commit same as predctx
newctx = context.memctx(repo,
parents=(predctx.p1(), predctx.p2()),
text=predctx.description(),
files=predctx.files(),
filectxfn=filectxfn,
user=predctx.user(),
date=predctx.date(),
extra=extras)
newprednode = repo.commitctx(newctx)
newpredctx = repo[newprednode]
dirstate = repo.dirstate
with dirstate.parentchange():
scmutil.movedirstate(repo, newpredctx)
mapping = {curctx.node(): (newprednode,)}
scmutil.cleanupnodes(repo, mapping, 'unamend', fixphase=True)