diff options
author | Raoul Hidalgo Charman <raoul.hidalgocharman@codethink.co.uk> | 2019-05-02 16:01:13 +0100 |
---|---|---|
committer | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2019-07-16 13:03:39 +0900 |
commit | cec4676346f9f77585110bac1160130eb32ad9f9 (patch) | |
tree | cd5dbb5f418c4aa967301a9f3e010b00b5af8730 /buildstream/source.py | |
parent | a0469043b14b9ab29dce8ad3dcae21c704d81718 (diff) | |
download | buildstream-cec4676346f9f77585110bac1160130eb32ad9f9.tar.gz |
source.py: ensure previous track refs are updatedtristan/backport-previous-sources
Updates the refs in the job process (but doesn't write), to ensure
following sources can see consistency of previous sourcse has been
updated. `_save_ref` is renamed `_set_ref` with writing to file now
optional.
This also changes the previous_source_access test to use a remote, so
that it actually tests this cornercase.
Fixes #1010
Diffstat (limited to 'buildstream/source.py')
-rw-r--r-- | buildstream/source.py | 38 |
1 files changed, 17 insertions, 21 deletions
diff --git a/buildstream/source.py b/buildstream/source.py index 2a3218cfc..ed4dd9617 100644 --- a/buildstream/source.py +++ b/buildstream/source.py @@ -701,24 +701,6 @@ class Source(Plugin): return key - # Wrapper for set_ref(), also returns whether it changed. - # - def _set_ref(self, ref, node): - current_ref = self.get_ref() - changed = False - - # This comparison should work even for tuples and lists, - # but we're mostly concerned about simple strings anyway. - if current_ref != ref: - changed = True - - # Set the ref regardless of whether it changed, the - # TrackQueue() will want to update a specific node with - # the ref, regardless of whether the original has changed. - self.set_ref(ref, node) - - return changed - # _project_refs(): # # Gets the appropriate ProjectRefs object for this source, @@ -795,7 +777,7 @@ class Source(Plugin): return redundant_ref - # _save_ref() + # _set_ref() # # Persists the ref for this source. This will decide where to save the # ref, or refuse to persist it, depending on active ref-storage project @@ -803,6 +785,7 @@ class Source(Plugin): # # Args: # new_ref (smth): The new reference to save + # save (bool): Whether to write the new reference to file or not # # Returns: # (bool): Whether the ref has changed @@ -810,7 +793,7 @@ class Source(Plugin): # Raises: # (SourceError): In the case we encounter errors saving a file to disk # - def _save_ref(self, new_ref): + def _set_ref(self, new_ref, *, save): context = self._get_context() project = self._get_project() @@ -838,7 +821,17 @@ class Source(Plugin): # # Step 2 - Set the ref in memory, and determine changed state # - if not self._set_ref(new_ref, node): + current_ref = self.get_ref() # pylint: disable=assignment-from-no-return + + # Set the ref regardless of whether it changed, the + # TrackQueue() will want to update a specific node with + # the ref, regardless of whether the original has changed. + self.set_ref(new_ref, node) + + if current_ref == new_ref or not save: + # Note: We do not look for and propagate changes at this point + # which might result in desync depending if something changes about + # tracking in the future. For now, this is quite safe. return False def do_save_refs(refs): @@ -902,6 +895,9 @@ class Source(Plugin): if current_ref != new_ref: self.info("Found new revision: {}".format(new_ref)) + # Save ref in local process for subsequent sources + self._set_ref(new_ref, save=False) + return new_ref # _requires_previous_sources() |