Mercurial > hg
comparison mercurial/streamclone.py @ 26461:09cc3c2e9ece
streamclone: move applyremotedata() into maybeperformstreamclone()
Future work around stream cloning will be implemented in a bundle2
world. This code will only be used in the legacy code path and
doesn't need to be abstracted or extensible.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sun, 04 Oct 2015 11:27:10 -0700 |
parents | 79ef867538ea |
children | 3b0ec09192ae |
comparison
equal
deleted
inserted
replaced
26460:79ef867538ea | 26461:09cc3c2e9ece |
---|---|
95 elif resp == 2: | 95 elif resp == 2: |
96 raise util.Abort(_('locking the remote repository failed')) | 96 raise util.Abort(_('locking the remote repository failed')) |
97 elif resp != 0: | 97 elif resp != 0: |
98 raise util.Abort(_('the server sent an unknown error code')) | 98 raise util.Abort(_('the server sent an unknown error code')) |
99 | 99 |
100 applyremotedata(repo, requirements, rbranchmap, fp) | 100 lock = repo.lock() |
101 try: | |
102 consumev1(repo, fp) | |
103 | |
104 # new requirements = old non-format requirements + | |
105 # new format-related remote requirements | |
106 # requirements from the streamed-in repository | |
107 repo.requirements = requirements | ( | |
108 repo.requirements - repo.supportedformats) | |
109 repo._applyopenerreqs() | |
110 repo._writerequirements() | |
111 | |
112 if rbranchmap: | |
113 branchmap.replacecache(repo, rbranchmap) | |
114 | |
115 repo.invalidate() | |
116 finally: | |
117 lock.release() | |
101 | 118 |
102 def allowservergeneration(ui): | 119 def allowservergeneration(ui): |
103 """Whether streaming clones are allowed from the server.""" | 120 """Whether streaming clones are allowed from the server.""" |
104 return ui.configbool('server', 'uncompressed', True, untrusted=True) | 121 return ui.configbool('server', 'uncompressed', True, untrusted=True) |
105 | 122 |
228 repo.ui.status(_('transferred %s in %.1f seconds (%s/sec)\n') % | 245 repo.ui.status(_('transferred %s in %.1f seconds (%s/sec)\n') % |
229 (util.bytecount(total_bytes), elapsed, | 246 (util.bytecount(total_bytes), elapsed, |
230 util.bytecount(total_bytes / elapsed))) | 247 util.bytecount(total_bytes / elapsed))) |
231 finally: | 248 finally: |
232 lock.release() | 249 lock.release() |
233 | |
234 def applyremotedata(repo, remotereqs, remotebranchmap, fp): | |
235 """Apply stream clone data to a repository. | |
236 | |
237 "remotereqs" is a set of requirements to handle the incoming data. | |
238 "remotebranchmap" is the result of a branchmap lookup on the remote. It | |
239 can be None. | |
240 "fp" is a file object containing the raw stream data, suitable for | |
241 feeding into consumev1(). | |
242 """ | |
243 lock = repo.lock() | |
244 try: | |
245 consumev1(repo, fp) | |
246 | |
247 # new requirements = old non-format requirements + | |
248 # new format-related remote requirements | |
249 # requirements from the streamed-in repository | |
250 repo.requirements = remotereqs | ( | |
251 repo.requirements - repo.supportedformats) | |
252 repo._applyopenerreqs() | |
253 repo._writerequirements() | |
254 | |
255 if remotebranchmap: | |
256 branchmap.replacecache(repo, remotebranchmap) | |
257 | |
258 repo.invalidate() | |
259 finally: | |
260 lock.release() |