From 96a8b44c8a1fddfa82424ad3c86b6a380ad863a2 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Tue, 6 Dec 2011 10:52:50 -0800 Subject: [PATCH] action_sync: fix git_sync_timestamps KeyError This fixes the case where $PORTDIR doesn't exist prior to sync. --- pym/_emerge/actions.py | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/pym/_emerge/actions.py b/pym/_emerge/actions.py index a62b30510..87610a693 100644 --- a/pym/_emerge/actions.py +++ b/pym/_emerge/actions.py @@ -1971,6 +1971,7 @@ def action_sync(settings, trees, mtimedb, myopts, myaction): os.umask(0o022) dosyncuri = syncuri updatecache_flg = False + git = False if myaction == "metadata": print("skipping sync") updatecache_flg = True @@ -1999,9 +2000,7 @@ def action_sync(settings, trees, mtimedb, myopts, myaction): msg = ">>> Git pull in %s successful" % myportdir emergelog(xterm_titles, msg) writemsg_level(msg + "\n") - exitcode = git_sync_timestamps(portdb, myportdir) - if exitcode == os.EX_OK: - updatecache_flg = True + git = True elif syncuri[:8]=="rsync://" or syncuri[:6]=="ssh://": for vcs_dir in vcs_dirs: writemsg_level(("!!! %s appears to be under revision " + \ @@ -2443,17 +2442,25 @@ def action_sync(settings, trees, mtimedb, myopts, myaction): noiselevel=-1, level=logging.ERROR) return 1 - if updatecache_flg and \ - myaction != "metadata" and \ - "metadata-transfer" not in settings.features: - updatecache_flg = False - # Reload the whole config from scratch. settings, trees, mtimedb = load_emerge_config(trees=trees) adjust_configs(myopts, trees) root_config = trees[settings['EROOT']]['root_config'] portdb = trees[settings['EROOT']]['porttree'].dbapi + if git: + # NOTE: Do this after reloading the config, in case + # it did not exist prior to sync, so that the config + # and portdb properly account for its existence. + exitcode = git_sync_timestamps(portdb, myportdir) + if exitcode == os.EX_OK: + updatecache_flg = True + + if updatecache_flg and \ + myaction != "metadata" and \ + "metadata-transfer" not in settings.features: + updatecache_flg = False + if updatecache_flg and \ os.path.exists(os.path.join(myportdir, 'metadata', 'cache')): -- 2.26.2