Mercurial > hg-stable
changeset 10241:4b2a086bee31
shrink-revlog: add --dry-run option
author | Patrick Mezard <pmezard@gmail.com> |
---|---|
date | Tue, 12 Jan 2010 22:20:21 +0100 |
parents | 3af4b39afe2a |
children | c4c0502be198 |
files | contrib/shrink-revlog.py |
diffstat | 1 files changed, 20 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/contrib/shrink-revlog.py Sun Jan 10 18:13:34 2010 +0100 +++ b/contrib/shrink-revlog.py Tue Jan 12 22:20:21 2010 +0100 @@ -189,25 +189,32 @@ if os.path.exists(tmpdatafn): os.unlink(tmpdatafn) raise - # Racy since both files cannot be renamed atomically - util.os_link(indexfn, oldindexfn) - util.os_link(datafn, olddatafn) - util.rename(tmpindexfn, indexfn) - util.rename(tmpdatafn, datafn) + if not opts.get('dry_run'): + # Racy since both files cannot be renamed atomically + util.os_link(indexfn, oldindexfn) + util.os_link(datafn, olddatafn) + util.rename(tmpindexfn, indexfn) + util.rename(tmpdatafn, datafn) + else: + os.unlink(tmpindexfn) + os.unlink(tmpdatafn) finally: lock.release() - ui.write('note: old revlog saved in:\n' - ' %s\n' - ' %s\n' - '(You can delete those files when you are satisfied that your\n' - 'repository is still sane. ' - 'Running \'hg verify\' is strongly recommended.)\n' - % (oldindexfn, olddatafn)) + if not opts.get('dry_run'): + ui.write('note: old revlog saved in:\n' + ' %s\n' + ' %s\n' + '(You can delete those files when you are satisfied that your\n' + 'repository is still sane. ' + 'Running \'hg verify\' is strongly recommended.)\n' + % (oldindexfn, olddatafn)) cmdtable = { 'shrink': (shrink, - [('', 'revlog', '', 'index (.i) file of the revlog to shrink')], + [('', 'revlog', '', 'index (.i) file of the revlog to shrink'), + ('n', 'dry-run', None, 'do not shrink, simulate only'), + ], 'hg shrink [--revlog PATH]') }