Show More
@@ -122,47 +122,46 b' def main():' | |||||
122 | help='shrink FILE [default: REPO/hg/store/00manifest.i]') |
|
122 | help='shrink FILE [default: REPO/hg/store/00manifest.i]') | |
123 | (options, args) = parser.parse_args() |
|
123 | (options, args) = parser.parse_args() | |
124 | if args: |
|
124 | if args: | |
125 |
|
|
125 | raise util.Abort('too many arguments') | |
126 |
|
126 | |||
127 | # Open the specified repository. |
|
127 | # Open the specified repository. | |
128 | ui = ui_.ui() |
|
128 | ui = ui_.ui() | |
129 | repo = hg.repository(ui, options.repository) |
|
129 | repo = hg.repository(ui, options.repository) | |
130 | if not repo.local(): |
|
130 | if not repo.local(): | |
131 |
|
|
131 | raise util.Abort('not a local repository: %s' % options.repository) | |
132 |
|
132 | |||
133 | if options.revlog is None: |
|
133 | if options.revlog is None: | |
134 | indexfn = repo.sjoin('00manifest.i') |
|
134 | indexfn = repo.sjoin('00manifest.i') | |
135 | else: |
|
135 | else: | |
136 | if not options.revlog.endswith('.i'): |
|
136 | if not options.revlog.endswith('.i'): | |
137 |
|
|
137 | raise util.Abort('--revlog option must specify the revlog index ' | |
138 | '(*.i), not %s' % options.revlog) |
|
138 | 'file (*.i), not %s' % options.revlog) | |
139 |
|
139 | |||
140 | indexfn = os.path.realpath(options.revlog) |
|
140 | indexfn = os.path.realpath(options.revlog) | |
141 | store = repo.sjoin('') |
|
141 | store = repo.sjoin('') | |
142 | if not indexfn.startswith(store): |
|
142 | if not indexfn.startswith(store): | |
143 |
|
|
143 | raise util.Abort('--revlog option must specify a revlog in %s, ' | |
144 | % (store, indexfn)) |
|
144 | 'not %s' % (store, indexfn)) | |
145 |
|
145 | |||
146 | datafn = indexfn[:-2] + '.d' |
|
146 | datafn = indexfn[:-2] + '.d' | |
147 | if not os.path.exists(indexfn): |
|
147 | if not os.path.exists(indexfn): | |
148 |
|
|
148 | raise util.Abort('no such file: %s' % indexfn) | |
149 | if '00changelog' in indexfn: |
|
149 | if '00changelog' in indexfn: | |
150 |
|
|
150 | raise util.Abort('shrinking the changelog will corrupt your repository') | |
151 | if not os.path.exists(datafn): |
|
151 | if not os.path.exists(datafn): | |
152 | # This is just a lazy shortcut because I can't be bothered to |
|
152 | # This is just a lazy shortcut because I can't be bothered to | |
153 | # handle all the special cases that entail from no .d file. |
|
153 | # handle all the special cases that entail from no .d file. | |
154 |
|
|
154 | raise util.Abort('%s does not exist: revlog not big enough ' | |
155 | 'to be worth shrinking' % datafn) |
|
155 | 'to be worth shrinking' % datafn) | |
156 |
|
156 | |||
157 | oldindexfn = indexfn + '.old' |
|
157 | oldindexfn = indexfn + '.old' | |
158 | olddatafn = datafn + '.old' |
|
158 | olddatafn = datafn + '.old' | |
159 | if os.path.exists(oldindexfn) or os.path.exists(olddatafn): |
|
159 | if os.path.exists(oldindexfn) or os.path.exists(olddatafn): | |
160 |
|
|
160 | raise util.Abort('one or both of\n' | |
161 | ' %s\n' |
|
161 | ' %s\n' | |
162 | ' %s\n' |
|
162 | ' %s\n' | |
163 | 'exists from a previous run; please clean up before ' |
|
163 | 'exists from a previous run; please clean up before ' | |
164 | 'running again' |
|
164 | 'running again' % (oldindexfn, olddatafn)) | |
165 | % (oldindexfn, olddatafn)) |
|
|||
166 |
|
165 | |||
167 | ui.write('shrinking %s\n' % indexfn) |
|
166 | ui.write('shrinking %s\n' % indexfn) | |
168 | prefix = os.path.basename(indexfn)[:-1] |
|
167 | prefix = os.path.basename(indexfn)[:-1] | |
@@ -216,5 +215,7 b' def main():' | |||||
216 |
|
215 | |||
217 | try: |
|
216 | try: | |
218 | main() |
|
217 | main() | |
|
218 | except util.Abort, inst: | |||
|
219 | print inst.args[0] | |||
219 | except KeyboardInterrupt: |
|
220 | except KeyboardInterrupt: | |
220 | sys.exit("interrupted") |
|
221 | sys.exit("interrupted") |
General Comments 0
You need to be logged in to leave comments.
Login now