# HG changeset patch # User Matt Mackall # Date 2009-08-31 15:58:33 # Node ID 1444a42f60524f8b1dd4deef6a057026e9d12400 # Parent 3738c8cff1bf380ef20044b0ace1134e4e91997f Make distinct lookup error for localrepo.lookup This allows clone/share to correctly distinguish lookup errors from corruption errors and catch only the former. diff --git a/mercurial/error.py b/mercurial/error.py --- a/mercurial/error.py +++ b/mercurial/error.py @@ -36,6 +36,9 @@ class ConfigError(Exception): class RepoError(Exception): pass +class RepoLookupError(RepoError): + pass + class CapabilityError(RepoError): pass diff --git a/mercurial/hg.py b/mercurial/hg.py --- a/mercurial/hg.py +++ b/mercurial/hg.py @@ -137,10 +137,12 @@ def share(ui, source, dest=None, update= if update is not True: checkout = update for test in (checkout, 'default', 'tip'): + if test is None: + continue try: uprev = r.lookup(test) break - except LookupError: + except error.RepoLookupError: continue _update(r, uprev) @@ -309,10 +311,12 @@ def clone(ui, source, dest=None, pull=Fa if update is not True: checkout = update for test in (checkout, 'default', 'tip'): + if test is None: + continue try: uprev = dest_repo.lookup(test) break - except: + except error.RepoLookupError: continue _update(dest_repo, uprev) diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -509,7 +509,7 @@ class localrepository(repo.repository): key = hex(key) except: pass - raise error.RepoError(_("unknown revision '%s'") % key) + raise error.RepoLookupError(_("unknown revision '%s'") % key) def local(self): return True