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