Rev 2860: * A progress bar has been added for knitpack -> knitpack fetching. in http://people.ubuntu.com/~robertc/baz2.0/repository

Robert Collins robertc at robertcollins.net
Mon Oct 29 03:47:40 GMT 2007


At http://people.ubuntu.com/~robertc/baz2.0/repository

------------------------------------------------------------
revno: 2860
revision-id:robertc at robertcollins.net-20071029034721-cdbsecglq7q5qsvz
parent: robertc at robertcollins.net-20071028191630-5rwo6sy9dguob5r6
committer: Robert Collins <robertc at robertcollins.net>
branch nick: repository
timestamp: Mon 2007-10-29 14:47:21 +1100
message:
  * A progress bar has been added for knitpack -> knitpack fetching.
    (Robert Collins, #157789)
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/progress.py             progress.py-20050610070202-df9faaab791964c0
  bzrlib/repofmt/pack_repo.py    pack_repo.py-20070813041115-gjv5ma7ktfqwsjgn-1
=== modified file 'NEWS'
--- a/NEWS	2007-10-28 17:32:45 +0000
+++ b/NEWS	2007-10-29 03:47:21 +0000
@@ -124,6 +124,9 @@
 
   BUG FIXES:
 
+   * A progress bar has been added for knitpack -> knitpack fetching.
+     (Robert Collins, #157789)
+
    * Connection error reporting for the smart server has been fixed to
      display a user friendly message instead of a traceback.
      (Ian Clatworthy, #115601)

=== modified file 'bzrlib/progress.py'
--- a/bzrlib/progress.py	2007-10-05 02:18:53 +0000
+++ b/bzrlib/progress.py	2007-10-29 03:47:21 +0000
@@ -461,7 +461,8 @@
 
     def update(self, msg, current_cnt=None, total_cnt=None):
         self.current = current_cnt
-        self.total = total_cnt
+        if total_cnt is not None:
+            self.total = total_cnt
         self.message = msg
         self.child_fraction = 0
         self.tick()
@@ -548,7 +549,7 @@
             self.cur_phase = 0
         else:
             self.cur_phase += 1
-        assert self.cur_phase < self.total 
+        assert self.cur_phase < self.total
         self.pb.update(self.message, self.cur_phase, self.total)
 
 

=== modified file 'bzrlib/repofmt/pack_repo.py'
--- a/bzrlib/repofmt/pack_repo.py	2007-10-28 19:02:05 +0000
+++ b/bzrlib/repofmt/pack_repo.py	2007-10-29 03:47:21 +0000
@@ -620,6 +620,15 @@
         if revision_ids is not None and len(revision_ids) == 0:
             # silly fetch request.
             return None
+        pb = ui.ui_factory.nested_progress_bar()
+        try:
+            return self._create_pack_from_packs(packs, suffix, revision_ids,
+                pb)
+        finally:
+            pb.finished()
+
+    def _create_pack_from_packs(self, packs, suffix, revision_ids, pb):
+        pb.update("Opening pack", 0, 5)
         revision_ids = frozenset(revision_ids)
         new_pack = NewPack(self._upload_transport, self._index_transport,
             self._pack_transport, upload_suffix=suffix)
@@ -648,6 +657,7 @@
             packs, 'revision_index')[0]
         revision_nodes = self._index_contents(revision_index_map, revision_keys)
         # copy revision keys and adjust values
+        pb.update("Copying revision texts.", 1)
         list(self._copy_nodes_graph(revision_nodes, revision_index_map,
             new_pack._writer, new_pack.revision_index))
         if 'pack' in debug.debug_flags:
@@ -666,6 +676,7 @@
         # copy inventory keys and adjust values
         # XXX: Should be a helper function to allow different inv representation
         # at this point.
+        pb.update("Copying inventory texts.", 2)
         inv_lines = self._copy_nodes_graph(inv_nodes, inventory_index_map,
             new_pack._writer, new_pack.inventory_index, output_lines=True)
         if revision_ids:
@@ -705,6 +716,7 @@
                 raise errors.RevisionNotPresent(a_missing_key[1],
                     a_missing_key[0])
         # copy text keys and adjust values
+        pb.update("Copying content texts.", 3)
         list(self._copy_nodes_graph(text_nodes, text_index_map,
             new_pack._writer, new_pack.text_index))
         if 'pack' in debug.debug_flags:
@@ -719,6 +731,7 @@
         signature_nodes = self._index_contents(signature_index_map,
             signature_filter)
         # copy signature keys and adjust values
+        pb.update("Copying signature texts.", 4)
         self._copy_nodes(signature_nodes, signature_index_map, new_pack._writer,
             new_pack.signature_index)
         if 'pack' in debug.debug_flags:
@@ -729,6 +742,7 @@
         if not new_pack.data_inserted():
             new_pack.abort()
             return None
+        pb.update("Finishing pack.", 5)
         new_pack.finish()
         self.allocate(new_pack)
         return new_pack
@@ -864,6 +878,15 @@
         :param output_lines: Return lines present in the copied data as
             an iterator.
         """
+        pb = ui.ui_factory.nested_progress_bar()
+        try:
+            return self._do_copy_nodes_graph(nodes, index_map, writer,
+                write_index, output_lines, pb)
+        finally:
+            pb.finished()
+
+    def _do_copy_nodes_graph(self, nodes, index_map, writer, write_index,
+        output_lines, pb):
         # for record verification
         knit_data = _KnitData(None)
         # for line extraction when requested (inventories only)
@@ -877,6 +900,8 @@
         # at this point - perhaps a helper library for the following code 
         # duplication points?
         request_groups = {}
+        record_index = 0
+        pb.update("Copied record", record_index, len(nodes))
         for index, key, value, references in nodes:
             if index not in request_groups:
                 request_groups[index] = []
@@ -912,6 +937,8 @@
                     df.close()
                 pos, size = writer.add_bytes_record(raw_data, names)
                 write_index.add_node(key, eol_flag + "%d %d" % (pos, size), references)
+                pb.update("Copied record", record_index)
+                record_index += 1
 
     def ensure_loaded(self):
         # NB: if you see an assertion error here, its probably access against




More information about the bazaar-commits mailing list