summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2009-09-05 22:25:05 +0000
committerZac Medico <zmedico@gentoo.org>2009-09-05 22:25:05 +0000
commitcc8204e586b20c4c4b45dba9bd5688aa911d1a3b (patch)
tree380b4bcb85f4d3f785fab9a41e8fd0c297ba8d98
parent8c042c0203c4635ab15061e002b108227f1d3fdd (diff)
downloadportage-cc8204e586b20c4c4b45dba9bd5688aa911d1a3b.tar.gz
portage-cc8204e586b20c4c4b45dba9bd5688aa911d1a3b.tar.bz2
portage-cc8204e586b20c4c4b45dba9bd5688aa911d1a3b.zip
Add a vardbapi._pkgs_changed attribute to use instead of PORTAGE_COUNTER_HASH
for emerge to check whether any packages have been added/removed. This is an optimization, since vardbapi._counter_hash() can be somewhat slow on embedded systems. Thanks to Marat Radchenko <slonopotamusorama@gmail.com> for reporting. svn path=/main/trunk/; revision=14203
-rw-r--r--pym/_emerge/main.py9
-rw-r--r--pym/portage/__init__.py1
-rw-r--r--pym/portage/dbapi/vartree.py6
3 files changed, 7 insertions, 9 deletions
diff --git a/pym/_emerge/main.py b/pym/_emerge/main.py
index 57277ecfb..6307904b7 100644
--- a/pym/_emerge/main.py
+++ b/pym/_emerge/main.py
@@ -314,9 +314,7 @@ def post_emerge(root_config, myopts, mtimedb, retval):
_flush_elog_mod_echo()
- counter_hash = settings.get("PORTAGE_COUNTER_HASH")
- if "--pretend" in myopts or (counter_hash is not None and \
- counter_hash == vardbapi._counter_hash()):
+ if not vardbapi._pkgs_changed:
display_news_notification(root_config, myopts)
# If vdb state has not changed then there's nothing else to do.
sys.exit(retval)
@@ -1075,11 +1073,6 @@ def emerge_main():
mysettings = trees[myroot]["vartree"].settings
mysettings.unlock()
adjust_config(myopts, mysettings)
- if '--pretend' not in myopts and myaction in \
- (None, 'clean', 'depclean', 'prune', 'unmerge'):
- mysettings["PORTAGE_COUNTER_HASH"] = \
- trees[myroot]["vartree"].dbapi._counter_hash()
- mysettings.backup_changes("PORTAGE_COUNTER_HASH")
mysettings.lock()
del myroot, mysettings
diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index f6cf25f53..255b005bf 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -1438,7 +1438,6 @@ class config(object):
"GENTOO_MIRRORS", "NOCONFMEM", "O",
"PORTAGE_BACKGROUND",
"PORTAGE_BINHOST_CHUNKSIZE", "PORTAGE_CALLER",
- "PORTAGE_COUNTER_HASH",
"PORTAGE_ELOG_CLASSES",
"PORTAGE_ELOG_MAILFROM", "PORTAGE_ELOG_MAILSUBJECT",
"PORTAGE_ELOG_MAILURI", "PORTAGE_ELOG_SYSTEM",
diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py
index 15ec5b798..b60316ee5 100644
--- a/pym/portage/dbapi/vartree.py
+++ b/pym/portage/dbapi/vartree.py
@@ -790,6 +790,10 @@ class vardbapi(dbapi):
self.root = _unicode_decode(root,
encoding=_encodings['content'], errors='strict')
+ # Used by emerge to check whether any packages
+ # have been added or removed.
+ self._pkgs_changed = False
+
#cache for category directory mtimes
self.mtdircache = {}
@@ -1041,9 +1045,11 @@ class vardbapi(dbapi):
self._aux_cache_obj = None
def _add(self, pkg_dblink):
+ self._pkgs_changed = True
self._clear_pkg_cache(pkg_dblink)
def _remove(self, pkg_dblink):
+ self._pkgs_changed = True
self._clear_pkg_cache(pkg_dblink)
def _clear_pkg_cache(self, pkg_dblink):