From: Rob Browning Date: Sat, 31 Mar 2018 20:32:52 +0000 (-0500) Subject: repo: avoid cyclic dependency with is_remote method X-Git-Tag: 0.30~34 X-Git-Url: https://arthur.barton.de/gitweb/?p=bup.git;a=commitdiff_plain;h=1c456b804743da1ae3caa62937c6984d1af450b4 repo: avoid cyclic dependency with is_remote method The current VFS operations (like resolve()) require a repo object, but we're about to add a VFS resolve() method to the repos. In and of itself, that isn't necessarily a problem, but as an optimization, we want the VFS resolve() to be able to detect when the repo it's been given is a RemoteRepo and redirect the call to remote_repo.resolve(). Doing so pushes the one single resolve() call to the remote instead of executing the resolve() locally with a lot of individual calls to the remote_repo's other methods. Adding is_remote() makes that possible without having to 'import repo' in the VFS (repo already imports vfs). Perhaps we'll rework it later, but this will do for now. Signed-off-by: Rob Browning Tested-by: Rob Browning --- diff --git a/lib/bup/repo.py b/lib/bup/repo.py index cc8a3fd..0bfccc3 100644 --- a/lib/bup/repo.py +++ b/lib/bup/repo.py @@ -43,6 +43,9 @@ class LocalRepo: (e.g. refs, tags, etc.).""" return self._id + def is_remote(self): + return False + def cat(self, ref): """If ref does not exist, yield (None, None, None). Otherwise yield (oidx, type, size), and then all of the data associated with @@ -94,6 +97,9 @@ class RemoteRepo: (e.g. refs, tags, etc.).""" return self._id + def is_remote(self): + return True + def cat(self, ref): """If ref does not exist, yield (None, None, None). Otherwise yield (oidx, type, size), and then all of the data associated with