Rev 9: Find the needed keys before starting the stream. in http://bzr.arbash-meinel.com/plugins/DEACTIVATED/bzr-repodebug
John Arbash Meinel
john at arbash-meinel.com
Mon Aug 8 13:28:35 UTC 2011
At http://bzr.arbash-meinel.com/plugins/DEACTIVATED/bzr-repodebug
------------------------------------------------------------
revno: 9
revision-id: john at arbash-meinel.com-20110808132826-q7sgov9tspbw3vr6
parent: andrew.bennetts at canonical.com-20110503081626-8godp1n78dgf09af
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: bzr-repodebug
timestamp: Mon 2011-08-08 15:28:26 +0200
message:
Find the needed keys before starting the stream.
This allows the 'target' to be a RemoteRepository without trying to
query data from a repository that we are actively streaming data into.
-------------- next part --------------
=== modified file 'fetch_all_records.py'
--- a/fetch_all_records.py 2011-05-03 02:23:24 +0000
+++ b/fetch_all_records.py 2011-08-08 13:28:26 +0000
@@ -16,7 +16,7 @@
from bzrlib.bzrdir import BzrDir
from bzrlib.commands import Command, Option
-from bzrlib import errors
+from bzrlib import errors, trace
class cmd_fetch_all_records(Command):
@@ -51,14 +51,25 @@
self.add_cleanup(source.lock_read().unlock)
self.add_cleanup(target.lock_write().unlock)
-
+
+ # We need to find the keys to insert before we start the stream.
+ # Otherwise we'll be querying the target repo while we're trying to
+ # insert into it.
+ needed = []
+ for vf_name in ['signatures', 'texts', 'chk_bytes', 'inventories',
+ 'revisions']:
+ vf = getattr(source, vf_name)
+ target_vf = getattr(target, vf_name)
+ source_keys = vf.keys()
+ target_keys = target_vf.keys()
+ keys = source_keys.difference(target_keys)
+ needed.append((vf_name, keys))
+
def source_stream():
- for vf_name in ['signatures', 'texts', 'chk_bytes', 'inventories',
- 'revisions']:
+ for vf_name, keys in needed:
vf = getattr(source, vf_name)
- keys = set(vf.keys()).difference(getattr(target,vf_name).keys())
yield (vf_name, vf.get_record_stream(keys, 'unordered', True))
-
+
resume_tokens, missing_keys = target._get_sink().insert_stream(
source_stream(), source._format, [])
More information about the bazaar-commits
mailing list