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

Robert Collins robertc at robertcollins.net
Mon Oct 29 04:05:30 GMT 2007


At http://people.ubuntu.com/~robertc/baz2.0/pack-progress

------------------------------------------------------------
revno: 2951
revision-id:robertc at robertcollins.net-20071029040513-b1f6b3xkhslgkt2s
parent: robertc at robertcollins.net-20071029040019-3x9as04a7s29motr
committer: Robert Collins <robertc at robertcollins.net>
branch nick: pack-progress
timestamp: Mon 2007-10-29 15:05:13 +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-26 08:56:09 +0000
+++ b/NEWS	2007-10-29 04:05:13 +0000
@@ -114,6 +114,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 04:05:13 +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-29 04:00:19 +0000
+++ b/bzrlib/repofmt/pack_repo.py	2007-10-29 04:05:13 +0000
@@ -623,6 +623,16 @@
                 return None
             else:
                 revision_ids = frozenset(revision_ids)
+        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)
         # buffer data - we won't be reading-back during the pack creation and
@@ -650,6 +660,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:
@@ -668,6 +679,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:
@@ -707,6 +719,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:
@@ -721,6 +734,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:
@@ -731,6 +745,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
@@ -866,6 +881,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)
@@ -879,6 +903,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] = []
@@ -914,6 +940,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