Mercurial > public > mercurial-scm > hg
comparison mercurial/localrepo.py @ 20969:7a679918ee2b
localrepo: add unbundle support
Localrepo now supports the unbundle method of pushing changegroups. We
plan to use the unbundle call for bundle2 so it is important that all
peers supports it. The `peer.unbundle` and `peer.addchangegroup` code
path have small difference so cause some test output changes. None of those
changes seems problematic.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Fri, 04 Apr 2014 17:50:44 -0700 |
parents | ffddabb8aa5d |
children | 37cdf1fca1b2 |
comparison
equal
deleted
inserted
replaced
20968:33d5fdd9bd99 | 20969:7a679918ee2b |
---|---|
61 def wrapper(repo, *args, **kwargs): | 61 def wrapper(repo, *args, **kwargs): |
62 return orig(repo.unfiltered(), *args, **kwargs) | 62 return orig(repo.unfiltered(), *args, **kwargs) |
63 return wrapper | 63 return wrapper |
64 | 64 |
65 moderncaps = set(('lookup', 'branchmap', 'pushkey', 'known', 'getbundle', | 65 moderncaps = set(('lookup', 'branchmap', 'pushkey', 'known', 'getbundle', |
66 'bundle2')) | 66 'bundle2', 'unbundle')) |
67 legacycaps = moderncaps.union(set(['changegroupsubset'])) | 67 legacycaps = moderncaps.union(set(['changegroupsubset'])) |
68 | 68 |
69 class localpeer(peer.peerrepository): | 69 class localpeer(peer.peerrepository): |
70 '''peer for a local repo; reflects only the most recent API''' | 70 '''peer for a local repo; reflects only the most recent API''' |
71 | 71 |
109 return exchange.getbundle(self._repo, source, heads=heads, | 109 return exchange.getbundle(self._repo, source, heads=heads, |
110 common=common, bundlecaps=bundlecaps) | 110 common=common, bundlecaps=bundlecaps) |
111 | 111 |
112 # TODO We might want to move the next two calls into legacypeer and add | 112 # TODO We might want to move the next two calls into legacypeer and add |
113 # unbundle instead. | 113 # unbundle instead. |
114 | |
115 def unbundle(self, cg, heads, url): | |
116 """apply a bundle on a repo | |
117 | |
118 This function handles the repo locking itself.""" | |
119 try: | |
120 return exchange.unbundle(self._repo, cg, heads, 'push', url) | |
121 except exchange.PushRaced, exc: | |
122 raise error.ResponseError(_('push failed:'), exc.message) | |
114 | 123 |
115 def lock(self): | 124 def lock(self): |
116 return self._repo.lock() | 125 return self._repo.lock() |
117 | 126 |
118 def addchangegroup(self, cg, source, url): | 127 def addchangegroup(self, cg, source, url): |