[MERGE][#248153] Add autopack RPC
Martin Pool
mbp at canonical.com
Thu Oct 30 03:33:41 GMT 2008
Martin Pool has voted comment.
Status is now: Semi-approved
Comment:
This definitely deserves a mention in NEWS, including some kind of
quantification of what improvement it will give you, and a description
of
what will happen if the server is too old.
+ def autopack(self):
+ path = self.bzrdir._path_for_remote_call(self._client)
+ try:
+ response = self._client.call('PackRepository.autopack',
path)
+ except errors.ErrorFromSmartServer, err:
+ self._translate_error(err)
+ except errors.UnknownSmartMethod:
+ self._ensure_real()
+ self._real_repository._pack_collection.autopack()
+ return
+ if self._real_repository is not None:
+ # Reset the real repository's cache of pack names.
+ self._real_repository._pack_collection.reload_pack_names()
+ if response != ('ok',):
+ raise errors.UnexpectedSmartServerResponse(response)
+
While we're here, it seems like an obvious opportunity to have the
PackRepository.autopack command return the pack names data, so that we
don't need to do another roundtrip. I can see two counterarguments
though, one being that it might not be trivial to inject it into the
_real_repository, and the other that if we can often get away without
vfs-based operations it may be unnecessary. But at least the second
does
not seem to be true in the near future.
@@ -1796,4 +1813,11 @@
raise errors.UnstackableRepositoryFormat(*err.error_args)
elif err.error_verb == 'NotStacked':
raise errors.NotStacked(branch=find('branch'))
+ elif err.error_verb == 'NotPackRepository':
+ # There's no specific exception to raise for this, because it
shouldn't
+ # happen unless something has changed the remote repo's format
between
+ # smart requests.
+ raise errors.InternalBzrError(
+ 'Tried to use PackRepository verb, but remote side says '
+ '%s is not a pack repository.' % (find('repository')))
raise errors.UnknownErrorFromSmartServer(err)
This seems a bit specific. Should we just have a generic error for all
rpcs meaning "this operation is not supported on this repository".
For details, see:
http://bundlebuggy.aaronbentley.com/project/bzr/request/%3C20081029215708.GA3904%40steerpike.home.puzzling.org%3E
Project: Bazaar
More information about the bazaar
mailing list