Rev 5006: (doxxx) Change the units displayed for transport activity and debug in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Thu Feb 4 14:01:02 GMT 2010


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 5006 [merge]
revision-id: pqm at pqm.ubuntu.com-20100204140100-xiij51gtzay09vgi
parent: pqm at pqm.ubuntu.com-20100204110201-g15a9s2y2hl6ciff
parent: v.ladeuil+lp at free.fr-20100204132343-d1ak5hj5vhc9ao7b
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Thu 2010-02-04 14:01:00 +0000
message:
  (doxxx) Change the units displayed for transport activity and debug
  	memory
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/tests/per_uifactory/__init__.py __init__.py-20090923045301-o12zypjwsidxn2hy-1
  bzrlib/transport/log.py        log.py-20080902041816-vh8x5yt5nvdzvew3-5
  bzrlib/ui/text.py              text.py-20051130153916-2e438cffc8afc478
  bzrlib/win32utils.py           win32console.py-20051021033308-123c6c929d04973d
  doc/developers/HACKING.txt     HACKING-20050805200004-2a5dc975d870f78c
=== modified file 'NEWS'
--- a/NEWS	2010-02-04 11:02:01 +0000
+++ b/NEWS	2010-02-04 14:01:00 +0000
@@ -39,6 +39,9 @@
 
 Bug Fixes
 *********
+* Network transfer amounts and rates are now displayed in SI units according
+  to the Ubuntu Units Policy, https://wiki.ubuntu.com/UnitsPolicy.
+  (Gordon Tyler, #514399)
 
 * Fix "AttributeError in Inter1and2Helper" during fetch.
   (Martin Pool, #513432)

=== modified file 'bzrlib/tests/per_uifactory/__init__.py'
--- a/bzrlib/tests/per_uifactory/__init__.py	2010-01-15 07:45:10 +0000
+++ b/bzrlib/tests/per_uifactory/__init__.py	2010-02-04 10:01:41 +0000
@@ -137,7 +137,7 @@
 
     def _check_log_transport_activity_noarg(self):
         self.assertEqual('', self.stdout.getvalue())
-        self.assertContainsRe(self.stderr.getvalue(), r'\d+KB\s+\dKB/s |')
+        self.assertContainsRe(self.stderr.getvalue(), r'\d+kB\s+\dkB/s |')
         self.assertNotContainsRe(self.stderr.getvalue(), r'Transferred:')
 
     def _check_log_transport_activity_display(self):
@@ -170,7 +170,7 @@
 
             def __setattr__(self, name, value):
                 return setattr(self._sio, name, value)
-                
+
         # Remove 'TERM' == 'dumb' which causes us to *not* treat output as a
         # real terminal, even though isatty returns True
         self._captureVar('TERM', None)
@@ -181,10 +181,11 @@
 
     def _check_log_transport_activity_display(self):
         self.assertEqual('', self.stdout.getvalue())
-        # Displaying the result should write to the progress stream
+        # Displaying the result should write to the progress stream using
+        # base-10 units (see HACKING.txt).
         self.assertContainsRe(self.stderr.getvalue(),
-            r'Transferred: 7KiB'
-            r' \(\d+\.\dK/s r:2K w:1K u:4K\)')
+            r'Transferred: 7kB'
+            r' \(\d+\.\dkB/s r:2kB w:1kB u:4kB\)')
 
     def _check_log_transport_activity_display_no_bytes(self):
         self.assertEqual('', self.stdout.getvalue())

=== modified file 'bzrlib/transport/log.py'
--- a/bzrlib/transport/log.py	2009-07-01 07:29:37 +0000
+++ b/bzrlib/transport/log.py	2010-02-04 10:01:41 +0000
@@ -136,8 +136,10 @@
         if False:
             elapsed = time.time() - before
             if result_len and elapsed > 0:
-                # this is the rate of higher-level data, not the raw network speed
-                mutter("      %9.03fs %8dKB/s" % (elapsed, result_len/elapsed/1024))
+                # this is the rate of higher-level data, not the raw network
+                # speed using base-10 units (see HACKING.txt).
+                mutter("      %9.03fs %8dkB/s"
+                       % (elapsed, result_len/elapsed/1000))
             else:
                 mutter("      %9.03fs" % (elapsed))
         return return_result

=== modified file 'bzrlib/ui/text.py'
--- a/bzrlib/ui/text.py	2010-01-15 03:29:33 +0000
+++ b/bzrlib/ui/text.py	2010-02-04 10:01:41 +0000
@@ -417,9 +417,11 @@
         elif now >= (self._transport_update_time + 0.5):
             # guard against clock stepping backwards, and don't update too
             # often
-            rate = self._bytes_since_update / (now - self._transport_update_time)
-            msg = ("%6dKB %5dKB/s" %
-                    (self._total_byte_count>>10, int(rate)>>10,))
+            rate = (self._bytes_since_update
+                    / (now - self._transport_update_time))
+            # using base-10 units (see HACKING.txt).
+            msg = ("%6dkB %5dkB/s" %
+                    (self._total_byte_count / 1000, int(rate) / 1000,))
             self._transport_update_time = now
             self._last_repaint = now
             self._bytes_since_update = 0
@@ -435,16 +437,17 @@
                 transfer_time = 0.001
             bps = self._total_byte_count / transfer_time
 
-        msg = ('Transferred: %.0fKiB'
-               ' (%.1fK/s r:%.0fK w:%.0fK'
-               % (self._total_byte_count / 1024.,
-                  bps / 1024.,
-                  self._bytes_by_direction['read'] / 1024.,
-                  self._bytes_by_direction['write'] / 1024.,
+        # using base-10 units (see HACKING.txt).
+        msg = ('Transferred: %.0fkB'
+               ' (%.1fkB/s r:%.0fkB w:%.0fkB'
+               % (self._total_byte_count / 1000.,
+                  bps / 1000.,
+                  self._bytes_by_direction['read'] / 1000.,
+                  self._bytes_by_direction['write'] / 1000.,
                  ))
         if self._bytes_by_direction['unknown'] > 0:
-            msg += ' u:%.0fK)' % (
-                self._bytes_by_direction['unknown'] / 1024.
+            msg += ' u:%.0fkB)' % (
+                self._bytes_by_direction['unknown'] / 1000.
                 )
         else:
             msg += ')'

=== modified file 'bzrlib/win32utils.py'
--- a/bzrlib/win32utils.py	2009-12-16 06:38:15 +0000
+++ b/bzrlib/win32utils.py	2010-02-04 10:01:41 +0000
@@ -135,7 +135,8 @@
                 'WorkingSetSize': mem_struct.WorkingSetSize,
                 'QuotaPeakPagedPoolUsage': mem_struct.QuotaPeakPagedPoolUsage,
                 'QuotaPagedPoolUsage': mem_struct.QuotaPagedPoolUsage,
-                'QuotaPeakNonPagedPoolUsage': mem_struct.QuotaPeakNonPagedPoolUsage,
+                'QuotaPeakNonPagedPoolUsage':
+                    mem_struct.QuotaPeakNonPagedPoolUsage,
                 'QuotaNonPagedPoolUsage': mem_struct.QuotaNonPagedPoolUsage,
                 'PagefileUsage': mem_struct.PagefileUsage,
                 'PeakPagefileUsage': mem_struct.PeakPagefileUsage,
@@ -152,19 +153,21 @@
                    ' or win32process')
         return
     if short:
-        trace.note('WorkingSize %7dKB'
-                   '\tPeakWorking %7dKB\t%s',
+        # using base-2 units (see HACKING.txt).
+        trace.note('WorkingSize %7dKiB'
+                   '\tPeakWorking %7dKiB\t%s',
                    info['WorkingSetSize'] / 1024,
                    info['PeakWorkingSetSize'] / 1024,
                    message)
         return
     if message:
         trace.note('%s', message)
-    trace.note('WorkingSize       %8d KB', info['WorkingSetSize'] / 1024)
-    trace.note('PeakWorking       %8d KB', info['PeakWorkingSetSize'] / 1024)
-    trace.note('PagefileUsage     %8d KB', info.get('PagefileUsage', 0) / 1024)
-    trace.note('PeakPagefileUsage %8d KB', info.get('PeakPagefileUsage', 0) / 1024)
-    trace.note('PrivateUsage      %8d KB', info.get('PrivateUsage', 0) / 1024)
+    trace.note('WorkingSize       %8d KiB', info['WorkingSetSize'] / 1024)
+    trace.note('PeakWorking       %8d KiB', info['PeakWorkingSetSize'] / 1024)
+    trace.note('PagefileUsage     %8d KiB', info.get('PagefileUsage', 0) / 1024)
+    trace.note('PeakPagefileUsage %8d KiB',
+               info.get('PeakPagefileUsage', 0) / 1024)
+    trace.note('PrivateUsage      %8d KiB', info.get('PrivateUsage', 0) / 1024)
     trace.note('PageFaultCount    %8d', info.get('PageFaultCount', 0))
 
 
@@ -187,7 +190,8 @@
 
     if res:
         (bufx, bufy, curx, cury, wattr,
-        left, top, right, bottom, maxx, maxy) = struct.unpack("hhhhHhhhhhh", csbi.raw)
+        left, top, right, bottom, maxx, maxy) = struct.unpack(
+            "hhhhHhhhhhh", csbi.raw)
         sizex = right - left + 1
         sizey = bottom - top + 1
         return (sizex, sizey)
@@ -410,7 +414,8 @@
 
 
 def _ensure_with_dir(path):
-    if not os.path.split(path)[0] or path.startswith(u'*') or path.startswith(u'?'):
+    if (not os.path.split(path)[0] or path.startswith(u'*')
+        or path.startswith(u'?')):
         return u'./' + path, True
     else:
         return path, False

=== modified file 'doc/developers/HACKING.txt'
--- a/doc/developers/HACKING.txt	2010-01-21 22:45:35 +0000
+++ b/doc/developers/HACKING.txt	2010-02-04 13:23:43 +0000
@@ -1010,6 +1010,12 @@
 finish the progress task when it exits, because it may otherwise be a long
 time until the finally block runs.
 
+https://wiki.ubuntu.com/UnitsPolicy provides a good explanation about
+which unit should be used when. Roughly speaking, IEC standard applies
+for base-2 units and SI standard applies for base-10 units::
+* for network bandwidth an disk sizes, use base-10 (Mbits/s, kB/s, GB),
+* for RAM sizes, use base-2 (GiB, TiB).
+
 
 Displaying help
 ===============




More information about the bazaar-commits mailing list