]> arthur.barton.de Git - bup.git/commitdiff
repo: avoid cyclic dependency with is_remote method
authorRob Browning <rlb@defaultvalue.org>
Sat, 31 Mar 2018 20:32:52 +0000 (15:32 -0500)
committerRob Browning <rlb@defaultvalue.org>
Sun, 13 Jan 2019 18:09:13 +0000 (12:09 -0600)
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 <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
lib/bup/repo.py

index cc8a3fd2e7161043b2bb158b0c2d25b55081a28a..0bfccc37745fe11ae35e3b54b1e9ae721f342ea4 100644 (file)
@@ -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