comparison hggit/git_handler.py @ 391:9b6597b70839

Improve error reporting in get_refs With this patch, attempts to push (or run outgoing) to read-only git URLs at github return github's helpful error message instead of just saying the remote end hung up.
author Brendan Cully <brendan@kublai.com>
date Tue, 17 May 2011 16:26:13 -0700
parents ed28dd69df61
children 8bb058d6a9ee
comparison
equal deleted inserted replaced
390:3f0f0c64f81c 391:9b6597b70839
1 import os, math, urllib, re 1 import os, math, urllib, re
2 2
3 from dulwich.errors import HangupException 3 from dulwich.errors import HangupException, GitProtocolError
4 from dulwich.index import commit_tree 4 from dulwich.index import commit_tree
5 from dulwich.objects import Blob, Commit, Tag, Tree, parse_timezone 5 from dulwich.objects import Blob, Commit, Tag, Tree, parse_timezone
6 from dulwich.pack import create_delta, apply_delta 6 from dulwich.pack import create_delta, apply_delta
7 from dulwich.repo import Repo 7 from dulwich.repo import Repo
8 from dulwich import client 8 from dulwich import client
149 new = [bin(self.map_hg_get(new_refs[ref])) for ref in changed_refs] 149 new = [bin(self.map_hg_get(new_refs[ref])) for ref in changed_refs]
150 old = dict( (bin(self.map_hg_get(old_refs[r])), 1) 150 old = dict( (bin(self.map_hg_get(old_refs[r])), 1)
151 for r in old_refs) 151 for r in old_refs)
152 152
153 return old, new 153 return old, new
154 except HangupException: 154 except (HangupException, GitProtocolError), e:
155 raise hgutil.Abort("the remote end hung up unexpectedly") 155 raise hgutil.Abort(_("git remote error: ") + str(e))
156 156
157 def push(self, remote, revs, force): 157 def push(self, remote, revs, force):
158 self.export_commits() 158 self.export_commits()
159 changed_refs = self.upload_pack(remote, revs, force) 159 changed_refs = self.upload_pack(remote, revs, force)
160 remote_name = self.remote_name(remote) 160 remote_name = self.remote_name(remote)