123 def unbundle(self, cg, heads, url): |
123 def unbundle(self, cg, heads, url): |
124 """apply a bundle on a repo |
124 """apply a bundle on a repo |
125 |
125 |
126 This function handles the repo locking itself.""" |
126 This function handles the repo locking itself.""" |
127 try: |
127 try: |
128 cg = exchange.readbundle(self.ui, cg, None) |
128 try: |
129 ret = exchange.unbundle(self._repo, cg, heads, 'push', url) |
129 cg = exchange.readbundle(self.ui, cg, None) |
130 if util.safehasattr(ret, 'getchunks'): |
130 ret = exchange.unbundle(self._repo, cg, heads, 'push', url) |
131 # This is a bundle20 object, turn it into an unbundler. |
131 if util.safehasattr(ret, 'getchunks'): |
132 # This little dance should be dropped eventually when the API |
132 # This is a bundle20 object, turn it into an unbundler. |
133 # is finally improved. |
133 # This little dance should be dropped eventually when the |
134 stream = util.chunkbuffer(ret.getchunks()) |
134 # API is finally improved. |
135 ret = bundle2.getunbundler(self.ui, stream) |
135 stream = util.chunkbuffer(ret.getchunks()) |
136 return ret |
136 ret = bundle2.getunbundler(self.ui, stream) |
|
137 return ret |
|
138 except Exception, exc: |
|
139 raise |
137 except error.PushRaced, exc: |
140 except error.PushRaced, exc: |
138 raise error.ResponseError(_('push failed:'), str(exc)) |
141 raise error.ResponseError(_('push failed:'), str(exc)) |
139 |
142 |
140 def lock(self): |
143 def lock(self): |
141 return self._repo.lock() |
144 return self._repo.lock() |