Mercurial > hg
diff hgext/largefiles/remotestore.py @ 17127:9e1616307c4c
largefiles: batch statlfile requests when pushing a largefiles repo (issue3386)
This implements a part of issue 3386. It batches the request for the status of
all largefiles in the revisions that are about to be pushed into a single
request, instead of doing N separate requests.
In a real world test case, this change was verified to save 1,116 round-trips to
the server. It only requires a client-side change; it is backwards-compatible
with an older version of the server.
author | Na'Tosha Bard <natosha@unity3d.com> |
---|---|
date | Sun, 24 Jun 2012 20:36:22 +0200 |
parents | 67d010779907 |
children | e95ec38f86b0 |
line wrap: on
line diff
--- a/hgext/largefiles/remotestore.py Wed Jul 04 02:21:04 2012 +0200 +++ b/hgext/largefiles/remotestore.py Sun Jun 24 20:36:22 2012 +0200 @@ -10,6 +10,7 @@ from mercurial import util from mercurial.i18n import _ +from mercurial.wireproto import remotebatch import lfutil import basestore @@ -20,8 +21,6 @@ super(remotestore, self).__init__(ui, repo, url) def put(self, source, hash): - if self._verify(hash): - return if self.sendfile(source, hash): raise util.Abort( _('remotestore: could not put %s to remote store %s') @@ -29,8 +28,8 @@ self.ui.debug( _('remotestore: put %s to remote store %s') % (source, self.url)) - def exists(self, hash): - return self._verify(hash) + def exists(self, hashes): + return self._verify(hashes) def sendfile(self, filename, hash): self.ui.debug('remotestore: sendfile(%s, %s)\n' % (filename, hash)) @@ -74,8 +73,8 @@ infile = lfutil.limitreader(infile, length) return lfutil.copyandhash(lfutil.blockstream(infile), tmpfile) - def _verify(self, hash): - return not self._stat(hash) + def _verify(self, hashes): + return self._stat(hashes) def _verifyfile(self, cctx, cset, contents, standin, verified): filename = lfutil.splitstandin(standin) @@ -104,3 +103,8 @@ else: raise RuntimeError('verify failed: unexpected response from ' 'statlfile (%r)' % stat) + + def batch(self): + '''Support for remote batching.''' + return remotebatch(self) +