4
pb = ProgressBar(show_spinner=True)
5
total = len(revision_ids)
6
- for i,f in enumerate(revision_ids):
7
- revisions.append(other.get_revision(f))
8
- pb.update('retrieving revisions', i+1, total)
11
- needed_texts = sets.Set()
13
- for index, rev in enumerate(revisions):
14
- pb.update('Scanning revisions for file contents', index, total)
15
- inv = other.get_inventory(str(rev.inventory_id))
16
- for key, entry in inv.iter_entries():
17
- if entry.text_id is None:
19
- if entry.text_id not in self.text_store:
20
- needed_texts.add(entry.text_id)
22
- count = self.text_store.copy_multi(other.text_store, needed_texts, pb,
23
- "Copying file contents")
25
- print "Added %d file contents." % count
26
- inventory_ids = [ f.inventory_id for f in revisions ]
27
- count = self.inventory_store.copy_multi(other.inventory_store,
29
- "Copying inventories")
31
- print "Added %d inventories." % count
32
- revision_ids = [ f.revision_id for f in revisions]
33
- count = self.revision_store.copy_multi(other.revision_store,
35
- "Copying revisions")
37
- for revision_id in revision_ids:
38
- self.append_revision(revision_id)
39
- print "Added %d revisions." % count
42
def commit(self, *args, **kw):
45
pb = ProgressBar(show_spinner=True)
46
total = len(revision_ids)
47
+ tmp_dir = tempfile.mkdtemp(prefix = "temp-stores-")
49
+ tmp_rev_dir = os.path.join(tmp_dir, "revisions")
50
+ os.mkdir(tmp_rev_dir)
51
+ tmp_revs = ImmutableStore(tmp_rev_dir)
52
+ count = tmp_revs.copy_multi(other.revision_store, revision_ids, pb,
53
+ "Caching revisions")
54
+ #EVIL! Substituting a local partial store for a complete one
55
+ #This is a significant performance boost when complete one is
57
+ other.revision_store = tmp_revs
60
+ for i,f in enumerate(revision_ids):
61
+ revisions.append(other.get_revision(f))
62
+ pb.update("Parsing revisions", i, len(revision_ids))
64
+ needed_texts = sets.Set()
66
+ #Again with the EVIL.
67
+ tmp_rev_dir = os.path.join(tmp_dir, "inventories")
68
+ os.mkdir(tmp_rev_dir)
69
+ inv_ids = [r.inventory_id for r in revisions]
70
+ tmp_revs = ImmutableStore(tmp_rev_dir)
71
+ count = tmp_revs.copy_multi(other.inventory_store, inv_ids, pb,
72
+ "Caching inventories")
73
+ other.inventory_store = tmp_revs
75
+ for index, rev in enumerate(revisions):
76
+ pb.update('Scanning revisions for file contents', index, total)
77
+ inv = other.get_inventory(str(rev.inventory_id))
78
+ for key, entry in inv.iter_entries():
79
+ if entry.text_id is None:
81
+ if entry.text_id not in self.text_store:
82
+ needed_texts.add(entry.text_id)
84
+ count = self.text_store.copy_multi(other.text_store, needed_texts, pb,
85
+ "Copying file contents")
87
+ print "Added %d file contents." % count
88
+ inventory_ids = [ f.inventory_id for f in revisions ]
89
+ count = self.inventory_store.copy_multi(other.inventory_store,
91
+ "Copying inventories")
93
+ print "Added %d inventories." % count
94
+ revision_ids = [ f.revision_id for f in revisions]
95
+ count = self.revision_store.copy_multi(other.revision_store,
98
+ for revision_id in revision_ids:
99
+ self.append_revision(revision_id)
100
+ print "Added %d revisions." % count
102
+ shutil.rmtree(tmp_dir)
105
def commit(self, *args, **kw):