[Notes] [Git][BuildStream/buildstream][willsalmon/APIFix] 3 commits: Keep original flags for create in SafeHardlinks.



Title: GitLab

Will Salmon pushed to branch willsalmon/APIFix at BuildStream / buildstream

Commits:

5 changed files:

Changes:

  • buildstream/_fuse/fuse.py
    ... ... @@ -757,7 +757,11 @@ class FUSE(object):
    757 757
             if self.raw_fi:
    
    758 758
                 return self.operations('create', path, mode, fi)
    
    759 759
             else:
    
    760
    -            fi.fh = self.operations('create', path, mode)
    
    760
    +            # This line is different from upstream to fix issues
    
    761
    +            # reading file opened with O_CREAT|O_RDWR.
    
    762
    +            # See issue #143.
    
    763
    +            fi.fh = self.operations('create', path, mode, fi.flags)
    
    764
    +            # END OF MODIFICATION
    
    761 765
                 return 0
    
    762 766
     
    
    763 767
         def ftruncate(self, path, length, fip):
    

  • buildstream/_fuse/hardlinks.py
    ... ... @@ -185,12 +185,12 @@ class SafeHardlinkOps(Operations):
    185 185
     
    
    186 186
             return os.open(full_path, flags)
    
    187 187
     
    
    188
    -    def create(self, path, mode, fi=None):
    
    188
    +    def create(self, path, mode, flags):
    
    189 189
             full_path = self._full_path(path)
    
    190 190
     
    
    191 191
             # If it already exists, ensure it's a copy first
    
    192 192
             self._ensure_copy(full_path)
    
    193
    -        return os.open(full_path, os.O_WRONLY | os.O_CREAT, mode)
    
    193
    +        return os.open(full_path, flags, mode)
    
    194 194
     
    
    195 195
         def read(self, path, length, offset, fh):
    
    196 196
             os.lseek(fh, offset, os.SEEK_SET)
    

  • buildstream/_pipeline.py
    ... ... @@ -360,22 +360,13 @@ class Pipeline():
    360 360
             if inconsistent:
    
    361 361
                 detail = "Exact versions are missing for the following elements:\n\n"
    
    362 362
     
    
    363
    -            missingTrack = 0
    
    364 363
                 for element in inconsistent:
    
    365 364
                     detail += "  " + element._get_full_name()
    
    366 365
                     for source in element.sources():
    
    367 366
                         if not source._get_consistency() and not source.get_ref():
    
    368
    -                        if hasattr(source, 'tracking') and source.tracking is None:
    
    369
    -                            detail += ": Source {} is missing ref and track. ".format(source._get_full_name()) + \
    
    370
    -                                      "Please specify a ref or branch/tag to track."
    
    371
    -                            missingTrack = 1
    
    367
    +                        detail += ": Source {} is missing ref\n".format(source)
    
    368
    +            detail += "\nTry tracking these elements first with `bst track`\n"
    
    372 369
     
    
    373
    -                detail += "\n"
    
    374
    -
    
    375
    -            if missingTrack:
    
    376
    -                detail += "\nThen track these elements with `bst track`\n"
    
    377
    -            else:
    
    378
    -                detail += "\nTry tracking these elements first with `bst track`\n"
    
    379 370
                 raise PipelineError("Inconsistent pipeline", detail=detail, reason="inconsistent-pipeline")
    
    380 371
     
    
    381 372
         #############################################################
    

  • buildstream/plugins/sources/git.py
    ... ... @@ -81,6 +81,7 @@ from configparser import RawConfigParser
    81 81
     
    
    82 82
     from buildstream import Source, SourceError, Consistency, SourceFetcher
    
    83 83
     from buildstream import utils
    
    84
    +from buildstream._exceptions import LoadError, LoadErrorReason
    
    84 85
     
    
    85 86
     GIT_MODULES = '.gitmodules'
    
    86 87
     
    
    ... ... @@ -300,6 +301,12 @@ class GitSource(Source):
    300 301
             self.original_url = self.node_get_member(node, str, 'url')
    
    301 302
             self.mirror = GitMirror(self, '', self.original_url, ref)
    
    302 303
             self.tracking = self.node_get_member(node, str, 'track', None)
    
    304
    +
    
    305
    +        # At this point we now know if the source has a ref and/or a track.
    
    306
    +        # If it is missing both then we will be unable to track or build.
    
    307
    +        if self.mirror.ref is None and self.tracking is None:
    
    308
    +            raise LoadError(LoadErrorReason.INVALID_DATA, "{}: Git sources require a ref and/or track".format(self))
    
    309
    +
    
    303 310
             self.checkout_submodules = self.node_get_member(node, bool, 'checkout-submodules', True)
    
    304 311
             self.submodules = []
    
    305 312
     
    

  • tests/sources/git.py
    1 1
     import os
    
    2 2
     import pytest
    
    3 3
     
    
    4
    -from buildstream._exceptions import ErrorDomain
    
    4
    +from buildstream._exceptions import ErrorDomain, LoadErrorReason
    
    5 5
     from buildstream import _yaml
    
    6 6
     
    
    7 7
     from tests.testutils import cli, create_repo
    
    ... ... @@ -384,20 +384,16 @@ def test_submodule_track_no_ref_or_track(cli, tmpdir, datafiles):
    384 384
     
    
    385 385
         # Track will encounter an inconsistent submodule without any ref
    
    386 386
         result = cli.run(project=project, args=['track', 'target.bst'])
    
    387
    -    result.assert_main_error(ErrorDomain.STREAM, None)
    
    388
    -    result.assert_task_error(ErrorDomain.SOURCE, 'track-attempt-no-track')
    
    387
    +    result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.INVALID_DATA)
    
    388
    +    result.assert_task_error(None, None)
    
    389 389
     
    
    390 390
         # Assert that we are just fine without it, and emit a warning to the user.
    
    391
    -    assert "FAILURE git source at" in result.stderr
    
    392
    -    assert "Without a tracking branch ref can not be updated. Please " + \
    
    393
    -        "provide a ref or a track." in result.stderr
    
    391
    +    assert "Git sources require a ref and/or track" in result.stderr
    
    394 392
     
    
    395 393
         # Track will encounter an inconsistent submodule without any ref
    
    396 394
         result = cli.run(project=project, args=['build', 'target.bst'])
    
    397
    -    result.assert_main_error(ErrorDomain.PIPELINE, 'inconsistent-pipeline')
    
    395
    +    result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.INVALID_DATA)
    
    398 396
         result.assert_task_error(None, None)
    
    399 397
     
    
    400 398
         # Assert that we are just fine without it, and emit a warning to the user.
    
    401
    -    assert "Exact versions are missing for the following elements" in result.stderr
    
    402
    -    assert "is missing ref and track." in result.stderr
    
    403
    -    assert "Then track these elements with `bst track`" in result.stderr
    399
    +    assert "Git sources require a ref and/or track" in result.stderr



  • [Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]