commit:     e2fe77b0831451db82d025538228cf54d5f898ea
Author:     Magnus Granberg <zorry <AT> gentoo <DOT> org>
AuthorDate: Fri May 15 19:00:20 2015 +0000
Commit:     Magnus Granberg <zorry <AT> gentoo <DOT> org>
CommitDate: Fri May 15 19:00:20 2015 +0000
URL:        
https://gitweb.gentoo.org/proj/tinderbox-cluster.git/commit/?id=e2fe77b0

Add text to sync.py and fix some small things in it

 tbc/pym/sync.py | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/tbc/pym/sync.py b/tbc/pym/sync.py
index 2622b25..f9e4cda 100644
--- a/tbc/pym/sync.py
+++ b/tbc/pym/sync.py
@@ -14,19 +14,23 @@ from tbc.sqlquerys import get_config_id, add_tbc_logs, 
get_config_all_info, get_
 from tbc.readconf import read_config_settings
 
 def git_repos_list(session, myportdb):
+       # get repo tree from portage
        repo_trees_list = myportdb.porttrees
+       repo_dir_list = []
+       # append repo dirs to a list
        for repo_dir in repo_trees_list:
-               repo_dir_list = []
                repo_dir_list.append(repo_dir)
        return repo_dir_list
 
 def git_fetch(session, git_repo, config_id):
+       # setup repo, fetch it and return repo 
        repo = Repository(git_repo)
        remote = repo.remotes["origin"]
        remote.fetch()
        return repo
 
 def git_merge(session, repo, config_id):
+       # check what of type merge we need to do and do it
        remote_master_id = 
repo.lookup_reference('refs/remotes/origin/master').target
        merge_result, _ = repo.merge_analysis(remote_master_id)
        if merge_result & GIT_MERGE_ANALYSIS_UP_TO_DATE:
@@ -65,6 +69,7 @@ def git_sync_main(session):
        log_msg = "Waiting for Guest to be idel"
        add_tbc_logs(session, log_msg, "info", config_id)
        guestid_list = []
+       # check if the guests is idel
        for config in get_config_all_info(session):
                if not config.Host:
                        guestid_list.append(config.ConfigId)
@@ -77,12 +82,15 @@ def git_sync_main(session):
                        GuestBusy = False
                else:
                        time.sleep(30)
+       #remove the needed base profile clone
        try:
                os.remove(mysettings['PORTDIR'] + "/profiles/config/parent")
                os.rmdir(mysettings['PORTDIR'] + "/profiles/config")
        except:
                pass
 
+       # check git diffs witch Manifests get updated and pass that to a dict
+       # fetch and merge the repo
        repo_cp_dict = {}
        for repo_dir in git_repos_list(session, myportdb):
                attr = {}
@@ -91,11 +99,10 @@ def git_sync_main(session):
                merge_result, _ = repo.merge_analysis(remote_master_id)
                if not merge_result & GIT_MERGE_ANALYSIS_UP_TO_DATE:
                        git_merge(session, repo, config_id)
-                       out = repo.diff('HEAD', 'HEAD^')
-                       repo_diff = out.patch
+                       repo_diff = repo.diff('HEAD', 'HEAD^')
                        cp_list = []
                        reponame = myportdb.getRepositoryName(repo_dir)
-                       for diff_line in repo_diff.splitlines():
+                       for diff_line in repo_diff.patch.splitlines():
                                if re.search("Manifest", diff_line) and 
re.search("^diff --git", diff_line):
                                        diff_line2 = re.split(' ', 
re.sub('[a-b]/', '', re.sub('diff --git ', '', diff_line)))
                                        if diff_line2[0] == diff_line2[1] or 
"Manifest" in diff_line2[0]:
@@ -110,8 +117,7 @@ def git_sync_main(session):
                        log_msg = "Repo is up to date"
                        add_tbc_logs(session, log_msg, "info", config_id)
        
-       # Need to add a config dir so we can use profiles/base for reading the 
tree.
-       # We may allready have the dir on local repo when we sync.
+       # Need to add a clone of profiles/base for reading the tree
        try:
                os.mkdir(mysettings['PORTDIR'] + "/profiles/config", 0o777)
                with open(mysettings['PORTDIR'] + "/profiles/config/parent", 
"w") as f:
@@ -119,14 +125,16 @@ def git_sync_main(session):
                        f.close()
        except:
                pass
+
        log_msg = "Repo sync ... Done."
        add_tbc_logs(session, log_msg, "info", config_id)
        return  repo_cp_dict
 
 def git_pull(session, git_repo, config_id):
+       # do a gitt pull
        log_msg = "Git pull"
        add_tbc_logs(session, log_msg, "info", config_id)
-       reop = git_fetch(session, git_repo, config_id)
+       repo = git_fetch(session, git_repo, config_id)
        git_merge(session, repo, config_id)
        log_msg = "Git pull ... Done"
        add_tbc_logs(session, log_msg, "info", config_id)

Reply via email to