Show More
@@ -107,37 +107,26 b' def report(ui, olddatafn, newdatafn):' | |||
|
107 | 107 | shrink_factor = oldsize / newsize |
|
108 | 108 | ui.write('shrinkage: %.1f%% (%.1fx)\n' % (shrink_percent, shrink_factor)) |
|
109 | 109 | |
|
110 | def main(): | |
|
110 | def shrink(ui, repo, **opts): | |
|
111 | """ | |
|
112 | Shrink revlog by re-ordering revisions. Will operate on manifest for | |
|
113 | the given repository if no other revlog is specified.""" | |
|
111 | 114 | |
|
112 | 115 | # Unbuffer stdout for nice progress output. |
|
113 | 116 | sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0) |
|
114 | 117 | |
|
115 | parser = optparse.OptionParser(description=__doc__) | |
|
116 | parser.add_option('-R', '--repository', | |
|
117 | default=os.path.curdir, | |
|
118 | metavar='REPO', | |
|
119 | help='repository root directory [default: current dir]') | |
|
120 | parser.add_option('--revlog', | |
|
121 | metavar='FILE', | |
|
122 | help='shrink FILE [default: REPO/hg/store/00manifest.i]') | |
|
123 | (options, args) = parser.parse_args() | |
|
124 | if args: | |
|
125 | raise util.Abort('too many arguments') | |
|
118 | if not repo.local(): | |
|
119 | raise util.Abort('not a local repository: %s' % repo.root) | |
|
126 | 120 | |
|
127 | # Open the specified repository. | |
|
128 | ui = ui_.ui() | |
|
129 | repo = hg.repository(ui, options.repository) | |
|
130 | if not repo.local(): | |
|
131 | raise util.Abort('not a local repository: %s' % options.repository) | |
|
132 | ||
|
133 | if options.revlog is None: | |
|
121 | fn = opts.get('revlog') | |
|
122 | if not fn: | |
|
134 | 123 | indexfn = repo.sjoin('00manifest.i') |
|
135 | 124 | else: |
|
136 |
if not |
|
|
125 | if not fn.endswith('.i'): | |
|
137 | 126 | raise util.Abort('--revlog option must specify the revlog index ' |
|
138 |
'file (*.i), not %s' % opt |
|
|
127 | 'file (*.i), not %s' % opts.get('revlog')) | |
|
139 | 128 | |
|
140 |
indexfn = os.path.realpath( |
|
|
129 | indexfn = os.path.realpath(fn) | |
|
141 | 130 | store = repo.sjoin('') |
|
142 | 131 | if not indexfn.startswith(store): |
|
143 | 132 | raise util.Abort('--revlog option must specify a revlog in %s, ' |
@@ -213,9 +202,8 b' def main():' | |||
|
213 | 202 | 'Running \'hg verify\' is strongly recommended.)\n' |
|
214 | 203 | % (oldindexfn, olddatafn)) |
|
215 | 204 | |
|
216 | try: | |
|
217 | main() | |
|
218 | except util.Abort, inst: | |
|
219 | print inst.args[0] | |
|
220 | except KeyboardInterrupt: | |
|
221 | sys.exit("interrupted") | |
|
205 | cmdtable = { | |
|
206 | 'shrink': (shrink, | |
|
207 | [('', 'revlog', '', 'shrink file')], | |
|
208 | 'hg shrink [--revlog PATH]') | |
|
209 | } |
General Comments 0
You need to be logged in to leave comments.
Login now