comparison mercurial/hg.py @ 499:81c563a254be

Add exception class for repository errors -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Add exception class for repository errors This gives friendlier errors for repo exceptions manifest hash: f3bef1ddb0c3911b9866ebdafa1fe72df48c8ecd -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) iD8DBQFCwRCfywK+sNU5EO8RAg7fAJ9PMka8pJCy7mMTqFFJ5aQFemHpxwCfezPR cZRAXmbWTTI+/WnVFDjpfM0= =8crk -----END PGP SIGNATURE-----
author mpm@selenic.com
date Tue, 28 Jun 2005 00:55:59 -0800
parents e94cebc60d96
children 7ea1c88792bf
comparison
equal deleted inserted replaced
498:8cf3999b3d03 499:81c563a254be
316 316
317 return file(f, mode) 317 return file(f, mode)
318 318
319 return o 319 return o
320 320
321 class RepoError(Exception): pass
322
321 class localrepository: 323 class localrepository:
322 def __init__(self, ui, path=None, create=0): 324 def __init__(self, ui, path=None, create=0):
323 self.remote = 0 325 self.remote = 0
324 if path and path[:7] == "http://": 326 if path and path[:7] == "http://":
325 self.remote = 1 327 self.remote = 1
328 if not path: 330 if not path:
329 p = os.getcwd() 331 p = os.getcwd()
330 while not os.path.isdir(os.path.join(p, ".hg")): 332 while not os.path.isdir(os.path.join(p, ".hg")):
331 oldp = p 333 oldp = p
332 p = os.path.dirname(p) 334 p = os.path.dirname(p)
333 if p == oldp: raise "No repo found" 335 if p == oldp: raise RepoError("no repo found")
334 path = p 336 path = p
335 self.path = os.path.join(path, ".hg") 337 self.path = os.path.join(path, ".hg")
336 338
337 if not create and not os.path.isdir(self.path): 339 if not create and not os.path.isdir(self.path):
338 raise "repository %s not found" % self.path 340 raise RepoError("repository %s not found" % self.path)
339 341
340 self.root = path 342 self.root = path
341 self.ui = ui 343 self.ui = ui
342 344
343 if create: 345 if create:
909 break 911 break
910 p, f = i, f * 2 912 p, f = i, f * 2
911 913
912 for f in fetch: 914 for f in fetch:
913 if f in m: 915 if f in m:
914 raise "already have", short(f[:4]) 916 raise RepoError("already have changeset " + short(f[:4]))
915 917
916 self.ui.note("adding new changesets starting at " + 918 self.ui.note("adding new changesets starting at " +
917 " ".join([short(f) for f in fetch]) + "\n") 919 " ".join([short(f) for f in fetch]) + "\n")
918 920
919 self.ui.debug("%d total queries\n" % reqcnt) 921 self.ui.debug("%d total queries\n" % reqcnt)