From 401dd9ef389d7f1200ffb7d3329569b83efcd82b Mon Sep 17 00:00:00 2001 From: Max Horn Date: Tue, 28 Oct 2014 18:46:53 +0100 Subject: [PATCH] Add debug mode, activated by setting the DEBUG_REMOTEHG env var For now, all debug mode does is to let exceptions propagate to the top (and thus print their backtrace), while in non-debug mode, backtraces are now suppressed. This should be a bit more user friendly. Additionally, we get rid of one try/except pair which replaced the potentially helpful exception message with a bland 'Repository error'; now the user can e.g. distinguish whether a 404 error occurred, authentication failed or the domain name is unknown (due to a typo). --- git-remote-hg | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/git-remote-hg b/git-remote-hg index 677ae20..13b80d1 100755 --- a/git-remote-hg +++ b/git-remote-hg @@ -53,6 +53,8 @@ import time as ptime # Commits are modified to preserve hg information and allow bidirectionality. # +DEBUG_REMOTEHG = os.environ.get("DEBUG_REMOTEHG") != None + NAME_RE = re.compile('^([^<>]+)') AUTHOR_RE = re.compile('^([^<>]+?)? ?[<>]([^<>]*)(?:$|>)') EMAIL_RE = re.compile(r'([^ \t<>]+@[^ \t<>]+)') @@ -426,10 +428,7 @@ def get_repo(url, alias): util.writefile(os.path.join(local_path, '.hg', 'sharedpath'), hg_path) repo = hg.repository(myui, local_path) - try: - peer = hg.peer(repo.ui, {}, url) - except: - die('Repository error') + peer = hg.peer(repo.ui, {}, url) repo.pull(peer, heads=None, force=True) updatebookmarks(repo, peer) @@ -1322,4 +1321,10 @@ def bye(): shutil.rmtree(dirname) atexit.register(bye) -sys.exit(main(sys.argv)) + +try: + sys.exit(main(sys.argv)) +except Exception, e: + if DEBUG_REMOTEHG: + raise + die(str(e))