[PATCH 3 of 6] shrink-revlog: add --sort option for user-selectable toposort algorithm
Greg Ward
greg-hg at gerg.ca
Sun Mar 7 12:57:58 CST 2010
# HG changeset patch
# User Greg Ward <greg-hg at gerg.ca>
# Date 1267107399 18000
# Node ID c0411bca1d9814aec5fe6869da5ecaed32997484
# Parent f57e0059b98dc348537b0470f1a9d5880658ea04
shrink-revlog: add --sort option for user-selectable toposort algorithm.
diff --git a/contrib/shrink-revlog.py b/contrib/shrink-revlog.py
old mode 100755
new mode 100644
--- a/contrib/shrink-revlog.py
+++ b/contrib/shrink-revlog.py
@@ -24,7 +24,7 @@
from mercurial import changegroup
from mercurial.i18n import _
-def toposort(ui, rl):
+def toposort_branchsort(ui, rl):
children = {}
root = []
@@ -131,9 +131,18 @@
% (shrink_percent, shrink_factor))
def shrink(ui, repo, **opts):
+ """shrink a revlog by reordering revisions
+
+ Rewrites all the entries in some revlog of the current repository
+ (by default, the manifest log) to save space.
+
+ Different sort algorithms have different performance
+ characteristics. Use ``--sort`` to select a sort algorithm so you
+ can determine which works best for your data. The default
+ algorithm, ``branchsort``, works well for workflows with lots of
+ active (unmerged) branches, but not so well when all branches have
+ been merged and there is only one repository head.
"""
- Shrink revlog by re-ordering revisions. Will operate on manifest for
- the given repository if no other revlog is specified."""
if not repo.local():
raise util.Abort(_('not a local repository: %s') % repo.root)
@@ -152,6 +161,12 @@
raise util.Abort(_('--revlog option must specify a revlog in %s, '
'not %s') % (store, indexfn))
+ sortname = opts['sort']
+ try:
+ toposort = globals()['toposort_' + sortname]
+ except KeyError:
+ raise util.Abort(_('no such toposort algorithm: %s') % sortname)
+
if not os.path.exists(indexfn):
raise util.Abort(_('no such file: %s') % indexfn)
if '00changelog' in indexfn:
@@ -242,6 +257,7 @@
'shrink': (shrink,
[('', 'revlog', '', _('index (.i) file of the revlog to shrink')),
('n', 'dry-run', None, _('do not shrink, simulate only')),
+ ('', 'sort', 'branchsort', 'name of sort algorithm to use'),
],
_('hg shrink [--revlog PATH]'))
}
More information about the Mercurial-devel
mailing list