Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
Add debug mode, activated by setting the DEBUG_REMOTEHG env var
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
fingolfin committed Oct 28, 2014
1 parent 9205775 commit 401dd9e
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions git-remote-hg
Original file line number Diff line number Diff line change
Expand Up @@ -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<>]+)')
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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))

0 comments on commit 401dd9e

Please sign in to comment.