Rev 4995: Add comments and update HACKING.txt about which units should be used. in file:///home/vila/src/bzr/reviews/514399/

Vincent Ladeuil v.ladeuil+lp at free.fr
Thu Feb 4 10:01:41 GMT 2010


At file:///home/vila/src/bzr/reviews/514399/

------------------------------------------------------------
revno: 4995
revision-id: v.ladeuil+lp at free.fr-20100204100141-aviyyic1im5neuu7
parent: gordon at doxxx.net-20100129184220-b92j89y758zq1fi4
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: 514399
timestamp: Thu 2010-02-04 11:01:41 +0100
message:
  Add comments and update HACKING.txt about which units should be used.
-------------- next part --------------
=== modified file 'bzrlib/tests/per_uifactory/__init__.py'
--- a/bzrlib/tests/per_uifactory/__init__.py	2010-01-29 18:18:08 +0000
+++ b/bzrlib/tests/per_uifactory/__init__.py	2010-02-04 10:01:41 +0000
@@ -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,7 +181,8 @@
 
     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: 7kB'
             r' \(\d+\.\dkB/s r:2kB w:1kB u:4kB\)')

=== modified file 'bzrlib/transport/log.py'
--- a/bzrlib/transport/log.py	2010-01-29 18:17:41 +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/1000))
+                # 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-29 17:59:57 +0000
+++ b/bzrlib/ui/text.py	2010-02-04 10:01:41 +0000
@@ -417,7 +417,9 @@
         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)
+            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
@@ -435,6 +437,7 @@
                 transfer_time = 0.001
             bps = self._total_byte_count / transfer_time
 
+        # using base-10 units (see HACKING.txt).
         msg = ('Transferred: %.0fkB'
                ' (%.1fkB/s r:%.0fkB w:%.0fkB'
                % (self._total_byte_count / 1000.,

=== modified file 'bzrlib/win32utils.py'
--- a/bzrlib/win32utils.py	2010-01-29 18:17:13 +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,6 +153,7 @@
                    ' or win32process')
         return
     if short:
+        # using base-2 units (see HACKING.txt).
         trace.note('WorkingSize %7dKiB'
                    '\tPeakWorking %7dKiB\t%s',
                    info['WorkingSetSize'] / 1024,
@@ -163,7 +165,8 @@
     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('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 10:01:41 +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