Mercurial > public > mercurial-scm > hg
comparison mercurial/localrepo.py @ 24798:9fbf0a2a72a1
bundle2: add on more layer of exception catching in localrepo.unbundle
We are going to add output related logic in this function. We do the
indentation first to help next changeset readability. We need a new try except
because we want to handle output on any exception, including PushRaced ones.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Thu, 16 Apr 2015 05:09:37 -0400 |
parents | 7d0421de8de3 |
children | d99d7e3f5cda |
comparison
equal
deleted
inserted
replaced
24797:0c4d5e01b31f | 24798:9fbf0a2a72a1 |
---|---|
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() |