diff options
author | Robert Yang <liezhi.yang@windriver.com> | 2017-06-01 00:28:03 -0700 |
---|---|---|
committer | Paul Eggleton <paul.eggleton@linux.intel.com> | 2017-07-21 08:15:53 +0200 |
commit | b478ff069e6d5e57ae6ae8bfd69ef7b476bf7ffb (patch) | |
tree | 9e2c26138925b271f532847d3a04298344e5d044 /layerindex/update_layer.py | |
parent | de4400674da95d7dea90819cf7b5bebe643e4c6f (diff) | |
download | openembedded-core-contrib-b478ff069e6d5e57ae6ae8bfd69ef7b476bf7ffb.tar.gz |
update_layer.py: move the location of transaction.atomic()
It doesn't need to be so ahead since we only need it when writing database, and
a following patch will remove layerbranch from database when the branch had
been removed from the repo, it's not easy to do the work in
transaction.atomic() block.
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Diffstat (limited to 'layerindex/update_layer.py')
-rw-r--r-- | layerindex/update_layer.py | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/layerindex/update_layer.py b/layerindex/update_layer.py index 1c33c783fb..b6c2f4acdb 100644 --- a/layerindex/update_layer.py +++ b/layerindex/update_layer.py @@ -238,36 +238,36 @@ def main(): # why won't they just fix that?!) tinfoil.config_data.setVar('LICENSE', '') + layer = utils.get_layer(options.layer) + urldir = layer.get_fetch_dir() + repodir = os.path.join(fetchdir, urldir) + + layerbranch = layer.get_layerbranch(options.branch) + + branchname = options.branch + branchdesc = options.branch + if layerbranch: + if layerbranch.actual_branch: + branchname = layerbranch.actual_branch + branchdesc = "%s (%s)" % (options.branch, branchname) + + # Collect repo info + repo = git.Repo(repodir) + assert repo.bare == False try: - with transaction.atomic(): - layer = utils.get_layer(options.layer) - urldir = layer.get_fetch_dir() - repodir = os.path.join(fetchdir, urldir) - - layerbranch = layer.get_layerbranch(options.branch) - - branchname = options.branch - branchdesc = options.branch - if layerbranch: - if layerbranch.actual_branch: - branchname = layerbranch.actual_branch - branchdesc = "%s (%s)" % (options.branch, branchname) - - # Collect repo info - repo = git.Repo(repodir) - assert repo.bare == False - try: - if options.nocheckout: - topcommit = repo.commit('HEAD') - else: - topcommit = repo.commit('origin/%s' % branchname) - except: - if layerbranch: - logger.error("Failed update of layer %s - branch %s no longer exists" % (layer.name, branchdesc)) - else: - logger.info("Skipping update of layer %s - branch %s doesn't exist" % (layer.name, branchdesc)) - sys.exit(1) + if options.nocheckout: + topcommit = repo.commit('HEAD') + else: + topcommit = repo.commit('origin/%s' % branchname) + except: + if layerbranch: + logger.error("Failed update of layer %s - branch %s no longer exists" % (layer.name, branchdesc)) + else: + logger.info("Skipping update of layer %s - branch %s doesn't exist" % (layer.name, branchdesc)) + sys.exit(1) + try: + with transaction.atomic(): newbranch = False if not layerbranch: # LayerBranch doesn't exist for this branch, create it |