closes #1958218: don't log traceback on bad url/access denied

authorSylvain Thénault <sylvain.thenault@logilab.fr>
changeset0df9b4b40201
branchstable
phasepublic
hiddenno
parent revision#059bc3a9d30f closes #1958220: we have to watch ourselves for repo shutdown
child revision#5cdd37d33421 1.8.7
files modified by this revision
hooks.py
repohg.py
# HG changeset patch
# User Sylvain Thénault <sylvain.thenault@logilab.fr>
# Date 1317052631 -7200
# Mon Sep 26 17:57:11 2011 +0200
# Branch stable
# Node ID 0df9b4b40201c196dec5b8919d8d55defbc221bc
# Parent 059bc3a9d30f260a0c3619e3964f0e9dba24c998
closes #1958218: don't log traceback on bad url/access denied

diff --git a/hooks.py b/hooks.py
@@ -141,10 +141,12 @@
1                          continue
2                      if (repo.config['repository-import'] or vcsrepo.import_revision_content) \
3                             and vcsrepo.local_cache is not None:
4                          try:
5                              repohdlr.pull_or_clone_cache(vcsrepo.source_url)
6 +                        except bridge.VCSException, ex:
7 +                            repohdlr.error(str(ex))
8                          except Exception:
9                              repohdlr.exception(
10                                  'error while updating local cache of repository %s',
11                                  vcsrepo.eid)
12                      if repo.config['repository-import']:
diff --git a/repohg.py b/repohg.py
@@ -7,10 +7,11 @@
13 
14  from __future__ import with_statement
15 
16  __docformat__ = "restructuredtext en"
17 
18 +import urllib2
19  from os import umask, makedirs
20  from os.path import split, exists, join, dirname
21  from datetime import datetime
22 
23  from mercurial import hg, ui, revlog, context, util, commands as hgcmd
@@ -80,16 +81,22 @@
24          if not exists(self.path):
25              pdir = dirname(self.path)
26              if not exists(pdir):
27                  makedirs(pdir)
28              self.info('cloning %s into %s', url, self.path)
29 -            hgcmd.clone(vcsfile_ui(self), str(url),
30 -                        dest=self.path, stream='compressed', noupdate=True)
31 +            try:
32 +                hgcmd.clone(vcsfile_ui(self), str(url),
33 +                            dest=self.path, stream='compressed', noupdate=True)
34 +            except (util.Abort, urllib2.URLError), ex:
35 +                raise bridge.VCSException(str(ex))
36          else:
37              self.info('pulling from %s into %s', remove_authinfo(url), self.path)
38              vui = vcsfile_ui(self)
39 -            hgcmd.pull(vui, hg.repository(vui, self.path), source=str(url))
40 +            try:
41 +                hgcmd.pull(vui, hg.repository(vui, self.path), source=str(url))
42 +            except (util.Abort, urllib2.URLError), ex:
43 +                raise bridge.VCSException(str(ex))
44 
45      def import_content(self, repoentity, commitevery=10):
46          """import content from the mercurial repository"""
47          assert self.eid == repoentity.eid
48          if not exists(self.path):