diff options
Diffstat (limited to 'git_config.py')
-rw-r--r-- | git_config.py | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/git_config.py b/git_config.py index 8e3dfb1b..286e89ca 100644 --- a/git_config.py +++ b/git_config.py | |||
@@ -19,6 +19,8 @@ import re | |||
19 | import subprocess | 19 | import subprocess |
20 | import sys | 20 | import sys |
21 | import time | 21 | import time |
22 | import urllib2 | ||
23 | |||
22 | from signal import SIGTERM | 24 | from signal import SIGTERM |
23 | from urllib2 import urlopen, HTTPError | 25 | from urllib2 import urlopen, HTTPError |
24 | from error import GitError, UploadError | 26 | from error import GitError, UploadError |
@@ -74,6 +76,14 @@ class GitConfig(object): | |||
74 | else: | 76 | else: |
75 | self._pickle = pickleFile | 77 | self._pickle = pickleFile |
76 | 78 | ||
79 | def ClearCache(self): | ||
80 | if os.path.exists(self._pickle): | ||
81 | os.remove(self._pickle) | ||
82 | self._cache_dict = None | ||
83 | self._section_dict = None | ||
84 | self._remotes = {} | ||
85 | self._branches = {} | ||
86 | |||
77 | def Has(self, name, include_defaults = True): | 87 | def Has(self, name, include_defaults = True): |
78 | """Return true if this configuration file has the key. | 88 | """Return true if this configuration file has the key. |
79 | """ | 89 | """ |
@@ -535,23 +545,25 @@ class Remote(object): | |||
535 | try: | 545 | try: |
536 | info = urlopen(u).read() | 546 | info = urlopen(u).read() |
537 | if info == 'NOT_AVAILABLE': | 547 | if info == 'NOT_AVAILABLE': |
538 | raise UploadError('Upload over ssh unavailable') | 548 | raise UploadError('%s: SSH disabled' % self.review) |
539 | if '<' in info: | 549 | if '<' in info: |
540 | # Assume the server gave us some sort of HTML | 550 | # Assume the server gave us some sort of HTML |
541 | # response back, like maybe a login page. | 551 | # response back, like maybe a login page. |
542 | # | 552 | # |
543 | raise UploadError('Cannot read %s:\n%s' % (u, info)) | 553 | raise UploadError('%s: Cannot parse response' % u) |
544 | 554 | ||
545 | self._review_protocol = 'ssh' | 555 | self._review_protocol = 'ssh' |
546 | self._review_host = info.split(" ")[0] | 556 | self._review_host = info.split(" ")[0] |
547 | self._review_port = info.split(" ")[1] | 557 | self._review_port = info.split(" ")[1] |
558 | except urllib2.URLError, e: | ||
559 | raise UploadError('%s: %s' % (self.review, e.reason[1])) | ||
548 | except HTTPError, e: | 560 | except HTTPError, e: |
549 | if e.code == 404: | 561 | if e.code == 404: |
550 | self._review_protocol = 'http-post' | 562 | self._review_protocol = 'http-post' |
551 | self._review_host = None | 563 | self._review_host = None |
552 | self._review_port = None | 564 | self._review_port = None |
553 | else: | 565 | else: |
554 | raise UploadError('Cannot guess Gerrit version') | 566 | raise UploadError('Upload over ssh unavailable') |
555 | 567 | ||
556 | REVIEW_CACHE[u] = ( | 568 | REVIEW_CACHE[u] = ( |
557 | self._review_protocol, | 569 | self._review_protocol, |