Mercurial > hgsubversion
comparison hgsubversion/svnmeta.py @ 1555:cff81f35b31e
cleanup: reference Abort from mercurial.error instead of mercurial.util
It's been there since hg 1.7 or so, which lets us avoid any need for
compat shims.
author | Augie Fackler <raf@durin42.com> |
---|---|
date | Sat, 24 Mar 2018 16:39:30 -0400 |
parents | 8410a978c650 |
children | ae572c9be4e6 |
comparison
equal
deleted
inserted
replaced
1554:258fb67fb956 | 1555:cff81f35b31e |
---|---|
1 import posixpath | 1 import posixpath |
2 import os | 2 import os |
3 import tempfile | 3 import tempfile |
4 | 4 |
5 from mercurial import context | 5 from mercurial import context |
6 from mercurial import error as hgerror | |
6 from mercurial import util as hgutil | 7 from mercurial import util as hgutil |
7 from mercurial import revlog | 8 from mercurial import revlog |
8 from mercurial import node | 9 from mercurial import node |
9 | 10 |
10 import compathacks | 11 import compathacks |
162 | 163 |
163 try: | 164 try: |
164 rootlist = svn.list_dir('', revision=revision) | 165 rootlist = svn.list_dir('', revision=revision) |
165 except svnwrap.SubversionException, e: | 166 except svnwrap.SubversionException, e: |
166 err = "%s (subversion error: %d)" % (e.args[0], e.args[1]) | 167 err = "%s (subversion error: %d)" % (e.args[0], e.args[1]) |
167 raise hgutil.Abort(err) | 168 raise hgerror.Abort(err) |
168 if sum(map(lambda x: x in rootlist, ('branches', 'tags', 'trunk'))): | 169 if sum(map(lambda x: x in rootlist, ('branches', 'tags', 'trunk'))): |
169 layout = 'standard' | 170 layout = 'standard' |
170 else: | 171 else: |
171 layout = 'single' | 172 layout = 'single' |
172 self.ui.setconfig('hgsubversion', 'layout', layout) | 173 self.ui.setconfig('hgsubversion', 'layout', layout) |
238 stored_subdir = util.load(subdirfile) | 239 stored_subdir = util.load(subdirfile) |
239 assert stored_subdir is not None | 240 assert stored_subdir is not None |
240 if subdir is None: | 241 if subdir is None: |
241 self.__subdir = stored_subdir | 242 self.__subdir = stored_subdir |
242 elif subdir and subdir != stored_subdir: | 243 elif subdir and subdir != stored_subdir: |
243 raise hgutil.Abort('unable to work on a different path in the ' | 244 raise hgerror.Abort('unable to work on a different path in the ' |
244 'repository') | 245 'repository') |
245 else: | 246 else: |
246 self.__subdir = subdir | 247 self.__subdir = subdir |
247 elif subdir is not None: | 248 elif subdir is not None: |
248 util.dump(subdir, subdirfile) | 249 util.dump(subdir, subdirfile) |
249 self.__subdir = subdir | 250 self.__subdir = subdir |
250 elif not self._skiperror: | 251 elif not self._skiperror: |
251 raise hgutil.Abort("hgsubversion metadata unavailable; " | 252 raise hgerror.Abort("hgsubversion metadata unavailable; " |
252 "please run 'hg svn rebuildmeta'") | 253 "please run 'hg svn rebuildmeta'") |
253 | 254 |
254 subdir = property(_get_subdir, _set_subdir, None, | 255 subdir = property(_get_subdir, _set_subdir, None, |
255 'Error-checked sub-directory of source Subversion ' | 256 'Error-checked sub-directory of source Subversion ' |
256 'repository.') | 257 'repository.') |
263 uuidfile = os.path.join(self.metapath, 'uuid') | 264 uuidfile = os.path.join(self.metapath, 'uuid') |
264 if os.path.isfile(uuidfile): | 265 if os.path.isfile(uuidfile): |
265 stored_uuid = util.load(uuidfile) | 266 stored_uuid = util.load(uuidfile) |
266 assert stored_uuid | 267 assert stored_uuid |
267 if uuid and uuid != stored_uuid: | 268 if uuid and uuid != stored_uuid: |
268 raise hgutil.Abort('unable to operate on unrelated repository') | 269 raise hgerror.Abort('unable to operate on unrelated repository') |
269 self.__uuid = uuid or stored_uuid | 270 self.__uuid = uuid or stored_uuid |
270 elif uuid: | 271 elif uuid: |
271 util.dump(uuid, uuidfile) | 272 util.dump(uuid, uuidfile) |
272 self.__uuid = uuid | 273 self.__uuid = uuid |
273 elif not self._skiperror: | 274 elif not self._skiperror: |
274 raise hgutil.Abort("hgsubversion metadata unavailable; " | 275 raise hgerror.Abort("hgsubversion metadata unavailable; " |
275 "please run 'hg svn rebuildmeta'") | 276 "please run 'hg svn rebuildmeta'") |
276 | 277 |
277 uuid = property(_get_uuid, _set_uuid, None, | 278 uuid = property(_get_uuid, _set_uuid, None, |
278 'Error-checked UUID of source Subversion repository.') | 279 'Error-checked UUID of source Subversion repository.') |
279 | 280 |
370 elif impl == 'sqlite': | 371 elif impl == 'sqlite': |
371 return maps.SqliteRevMap | 372 return maps.SqliteRevMap |
372 elif impl is None: | 373 elif impl is None: |
373 return self._defaultrevmapclass | 374 return self._defaultrevmapclass |
374 else: | 375 else: |
375 raise hgutil.Abort('unknown revmapimpl: %s' % impl) | 376 raise hgerror.Abort('unknown revmapimpl: %s' % impl) |
376 | 377 |
377 def fixdate(self, date): | 378 def fixdate(self, date): |
378 if date is not None: | 379 if date is not None: |
379 date = util.forceutf8(date) | 380 date = util.forceutf8(date) |
380 date = date.replace('T', ' ').replace('Z', '').split('.')[0] | 381 date = date.replace('T', ' ').replace('Z', '').split('.')[0] |