##// END OF EJS Templates
shrink-revlog: add --dry-run option
Patrick Mezard -
r10241:4b2a086b default
parent child Browse files
Show More
@@ -189,25 +189,32 b' def shrink(ui, repo, **opts):'
189 if os.path.exists(tmpdatafn):
189 if os.path.exists(tmpdatafn):
190 os.unlink(tmpdatafn)
190 os.unlink(tmpdatafn)
191 raise
191 raise
192 # Racy since both files cannot be renamed atomically
192 if not opts.get('dry_run'):
193 util.os_link(indexfn, oldindexfn)
193 # Racy since both files cannot be renamed atomically
194 util.os_link(datafn, olddatafn)
194 util.os_link(indexfn, oldindexfn)
195 util.rename(tmpindexfn, indexfn)
195 util.os_link(datafn, olddatafn)
196 util.rename(tmpdatafn, datafn)
196 util.rename(tmpindexfn, indexfn)
197 util.rename(tmpdatafn, datafn)
198 else:
199 os.unlink(tmpindexfn)
200 os.unlink(tmpdatafn)
197 finally:
201 finally:
198 lock.release()
202 lock.release()
199
203
200 ui.write('note: old revlog saved in:\n'
204 if not opts.get('dry_run'):
201 ' %s\n'
205 ui.write('note: old revlog saved in:\n'
202 ' %s\n'
206 ' %s\n'
203 '(You can delete those files when you are satisfied that your\n'
207 ' %s\n'
204 'repository is still sane. '
208 '(You can delete those files when you are satisfied that your\n'
205 'Running \'hg verify\' is strongly recommended.)\n'
209 'repository is still sane. '
206 % (oldindexfn, olddatafn))
210 'Running \'hg verify\' is strongly recommended.)\n'
211 % (oldindexfn, olddatafn))
207
212
208 cmdtable = {
213 cmdtable = {
209 'shrink': (shrink,
214 'shrink': (shrink,
210 [('', 'revlog', '', 'index (.i) file of the revlog to shrink')],
215 [('', 'revlog', '', 'index (.i) file of the revlog to shrink'),
216 ('n', 'dry-run', None, 'do not shrink, simulate only'),
217 ],
211 'hg shrink [--revlog PATH]')
218 'hg shrink [--revlog PATH]')
212 }
219 }
213
220
General Comments 0
You need to be logged in to leave comments. Login now