~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to patches/cache-remote-revisions.diff

  • Committer: mbp at sourcefrog
  • Date: 2005-03-19 01:41:44 UTC
  • Revision ID: mbp@sourcefrog.net-20050319014144-5298a74caebaf378
fix local-time-offset calculation

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
***************
2
 
*** 738,777 ****
3
 
          revisions = []
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)
9
 
-         pb.clear()
10
 
-         
11
 
-         needed_texts = sets.Set()
12
 
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:
18
 
-                     continue
19
 
-                 if entry.text_id not in self.text_store:
20
 
-                     needed_texts.add(entry.text_id)
21
 
-         pb.clear()
22
 
-         count = self.text_store.copy_multi(other.text_store, needed_texts, pb,
23
 
-                                            "Copying file contents")
24
 
-         pb.clear()
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, 
28
 
-                                                 inventory_ids, pb,
29
 
-                                                 "Copying inventories")
30
 
-         pb.clear()
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, 
34
 
-                                                revision_ids, pb, 
35
 
-                                                "Copying revisions")
36
 
-         pb.clear()
37
 
-         for revision_id in revision_ids:
38
 
-             self.append_revision(revision_id)
39
 
-         print "Added %d revisions." % count
40
 
                      
41
 
          
42
 
      def commit(self, *args, **kw):
43
 
--- 738,799 ----
44
 
          revisions = []
45
 
          pb = ProgressBar(show_spinner=True)
46
 
          total = len(revision_ids)
47
 
+         tmp_dir = tempfile.mkdtemp(prefix = "temp-stores-")
48
 
+         try:
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
56
 
+             #a remote store. 
57
 
+             other.revision_store = tmp_revs
58
 
+             pb.clear()
59
 
60
 
+             for i,f in enumerate(revision_ids):
61
 
+                 revisions.append(other.get_revision(f))
62
 
+                 pb.update("Parsing revisions", i, len(revision_ids))
63
 
+             
64
 
+             needed_texts = sets.Set()
65
 
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
74
 
+             pb.clear()
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:
80
 
+                         continue
81
 
+                     if entry.text_id not in self.text_store:
82
 
+                         needed_texts.add(entry.text_id)
83
 
+             pb.clear()
84
 
+             count = self.text_store.copy_multi(other.text_store, needed_texts, pb,
85
 
+                                                "Copying file contents")
86
 
+             pb.clear()
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, 
90
 
+                                                     inventory_ids, pb,
91
 
+                                                     "Copying inventories")
92
 
+             pb.clear()
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, 
96
 
+                                                    revision_ids)
97
 
+             pb.clear()
98
 
+             for revision_id in revision_ids:
99
 
+                 self.append_revision(revision_id)
100
 
+             print "Added %d revisions." % count
101
 
+         finally:
102
 
+             shutil.rmtree(tmp_dir)
103
 
                      
104
 
          
105
 
      def commit(self, *args, **kw):