remote-hg: show more proper errors

When cloning or pushing fails, we don't want to show a stack-trace. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Felipe Contreras committed Apr 11, 2013 at 07:23 UTC cbf6237c2ba989794815f980af1d26860840daf6
1 file changed +9 -3
contrib/remote-helpers/git-remote-hg
+9 -3
@@ -9,7 +9,7 @@
9 # Then you can clone with:
10 # git clone hg::/path/to/mercurial/repo/
11
12 -from mercurial import hg, ui, bookmarks, context, util, encoding, node
12 +from mercurial import hg, ui, bookmarks, context, util, encoding, node, error
13
14 import re
15 import sys
@@ -284,11 +284,17 @@ def get_repo(url, alias):
284 else:
285 local_path = os.path.join(dirname, 'clone')
286 if not os.path.exists(local_path):
287 - peer, dstpeer = hg.clone(myui, {}, url, local_path, update=False, pull=True)
287 + try:
288 + peer, dstpeer = hg.clone(myui, {}, url, local_path, update=True, pull=True)
289 + except:
290 + die('Repository error')
291 repo = dstpeer.local()
292 else:
293 repo = hg.repository(myui, local_path)
291 - peer = hg.peer(myui, {}, url)
294 + try:
295 + peer = hg.peer(myui, {}, url)
296 + except:
297 + die('Repository error')
298 repo.pull(peer, heads=None, force=True)
299
300 return repo