##// END OF EJS Templates
shrink-revlog: add --sort option for user-selectable toposort algorithm.
Greg Ward -
r10622:bc81f126 default
parent child Browse files
Show More
@@ -24,7 +24,7 b' from mercurial import revlog, transactio'
24 from mercurial import changegroup
24 from mercurial import changegroup
25 from mercurial.i18n import _
25 from mercurial.i18n import _
26
26
27 def toposort(ui, rl):
27 def toposort_branchsort(ui, rl):
28
28
29 children = {}
29 children = {}
30 root = []
30 root = []
@@ -130,9 +130,18 b' def report(ui, r1, r2):'
130 % (shrink_percent, shrink_factor))
130 % (shrink_percent, shrink_factor))
131
131
132 def shrink(ui, repo, **opts):
132 def shrink(ui, repo, **opts):
133 """shrink a revlog by reordering revisions
134
135 Rewrites all the entries in some revlog of the current repository
136 (by default, the manifest log) to save space.
137
138 Different sort algorithms have different performance
139 characteristics. Use ``--sort`` to select a sort algorithm so you
140 can determine which works best for your data. The default
141 algorithm, ``branchsort``, works well for workflows with lots of
142 active (unmerged) branches, but not so well when all branches have
143 been merged and there is only one repository head.
133 """
144 """
134 Shrink revlog by re-ordering revisions. Will operate on manifest for
135 the given repository if no other revlog is specified."""
136
145
137 if not repo.local():
146 if not repo.local():
138 raise util.Abort(_('not a local repository: %s') % repo.root)
147 raise util.Abort(_('not a local repository: %s') % repo.root)
@@ -151,6 +160,12 b' def shrink(ui, repo, **opts):'
151 raise util.Abort(_('--revlog option must specify a revlog in %s, '
160 raise util.Abort(_('--revlog option must specify a revlog in %s, '
152 'not %s') % (store, indexfn))
161 'not %s') % (store, indexfn))
153
162
163 sortname = opts['sort']
164 try:
165 toposort = globals()['toposort_' + sortname]
166 except KeyError:
167 raise util.Abort(_('no such toposort algorithm: %s') % sortname)
168
154 if not os.path.exists(indexfn):
169 if not os.path.exists(indexfn):
155 raise util.Abort(_('no such file: %s') % indexfn)
170 raise util.Abort(_('no such file: %s') % indexfn)
156 if '00changelog' in indexfn:
171 if '00changelog' in indexfn:
@@ -241,6 +256,7 b' cmdtable = {'
241 'shrink': (shrink,
256 'shrink': (shrink,
242 [('', 'revlog', '', _('index (.i) file of the revlog to shrink')),
257 [('', 'revlog', '', _('index (.i) file of the revlog to shrink')),
243 ('n', 'dry-run', None, _('do not shrink, simulate only')),
258 ('n', 'dry-run', None, _('do not shrink, simulate only')),
259 ('', 'sort', 'branchsort', 'name of sort algorithm to use'),
244 ],
260 ],
245 _('hg shrink [--revlog PATH]'))
261 _('hg shrink [--revlog PATH]'))
246 }
262 }
General Comments 0
You need to be logged in to leave comments. Login now