Suppress counter initialization warning messages in
authorZac Medico <zmedico@gentoo.org>
Fri, 18 Jul 2008 07:47:12 +0000 (07:47 -0000)
committerZac Medico <zmedico@gentoo.org>
Fri, 18 Jul 2008 07:47:12 +0000 (07:47 -0000)
vardbapi.get_counter_tick_core() in cases when the vdb is empty. This
avoids pointless error messages when merging packages into a new root,
like when building stage 1.

svn path=/main/trunk/; revision=11123

pym/portage/dbapi/vartree.py

index b6b2dbf1a5220272a420e73dccea4798bb0207d3..f9e3fc9ed4aa92f298d4d3f3617a7a89e0ee8e66 100644 (file)
@@ -846,13 +846,16 @@ class vardbapi(dbapi):
                                if counter > max_counter:
                                        max_counter = counter
 
+               new_vdb = False
                counter = -1
                try:
                        cfile = open(self._counter_path, "r")
                except EnvironmentError, e:
-                       writemsg("!!! Unable to read COUNTER file: '%s'\n" % \
-                               self._counter_path, noiselevel=-1)
-                       writemsg("!!! %s\n" % str(e), noiselevel=-1)
+                       new_vdb = not bool(self.cpv_all())
+                       if not new_vdb:
+                               writemsg("!!! Unable to read COUNTER file: '%s'\n" % \
+                                       self._counter_path, noiselevel=-1)
+                               writemsg("!!! %s\n" % str(e), noiselevel=-1)
                        del e
                else:
                        try:
@@ -877,7 +880,7 @@ class vardbapi(dbapi):
                if counter > max_counter:
                        max_counter = counter
 
-               if counter < 0:
+               if counter < 0 and not new_vdb:
                        writemsg("!!! Initializing COUNTER to " + \
                                "value of %d\n" % max_counter, noiselevel=-1)