def test_dict_render(self):
     d = dict(test=WithProperties("repourl%(foo)s"))
     url = _ComputeRepositoryURL(d)
     self.assertEquals(self.build.render(url), "repourlbar")
 def test_callable(self):
     func = lambda x: x[::-1]
     url = _ComputeRepositoryURL(func)
     self.assertEquals(self.build.render(url), "tset")
 def test_backward_compatibility_render(self):
     url = _ComputeRepositoryURL(WithProperties("repourl%(foo)s"))
     self.assertEquals(self.build.render(url), "repourlbar")
 def test_format_string(self):
     url = _ComputeRepositoryURL("http://server/%s")
     self.assertEquals(self.build.render(url), "http://server/test")
 def test_dict(self):
     dict = {}
     dict['test'] = "ssh://server/testrepository"
     url = _ComputeRepositoryURL(dict)
     self.assertEquals(self.build.render(url), "ssh://server/testrepository")
Ejemplo n.º 6
0
 def test_backward_compatibility(self):
     url = _ComputeRepositoryURL("repourl")
     self.assertEqual(self.build.render(url), "repourl")
 def test_backward_compatibility(self):
     url = _ComputeRepositoryURL("repourl")
     self.assertEqual(self.build.render(url), "repourl")
Ejemplo n.º 8
0
 def test_callable_render(self):
     func = lambda x: WithProperties(x + "%(foo)s")
     url = _ComputeRepositoryURL(func)
     self.assertEquals(self.build.render(url), "testbar")
Ejemplo n.º 9
0
    def __init__(
        self,
        repourl=None,
        baseURL=None,
        mode="incremental",
        method=None,
        defaultBranch=None,
        branchType="dirname",
        clobberOnBranchChange=True,
        **kwargs
    ):

        """
        @type  repourl: string
        @param repourl: the URL which points at the Mercurial repository.
                        This uses the 'default' branch unless defaultBranch is
                        specified below and the C{branchType} is set to
                        'inrepo'.  It is an error to specify a branch without
                        setting the C{branchType} to 'inrepo'.

        @param baseURL: if 'dirname' branches are enabled, this is the base URL
                        to which a branch name will be appended. It should
                        probably end in a slash.  Use exactly one of C{repourl}
                        and C{baseURL}.

        @param defaultBranch: if branches are enabled, this is the branch
                              to use if the Build does not specify one
                              explicitly.
                              For 'dirname' branches, It will simply be
                              appended to C{baseURL} and the result handed to
                              the 'hg update' command.
                              For 'inrepo' branches, this specifies the named
                              revision to which the tree will update after a
                              clone.

        @param branchType: either 'dirname' or 'inrepo' depending on whether
                           the branch name should be appended to the C{baseURL}
                           or the branch is a mercurial named branch and can be
                           found within the C{repourl}

        @param clobberOnBranchChange: boolean, defaults to True. If set and
                                      using inrepos branches, clobber the tree
                                      at each branch change. Otherwise, just
                                      update to the branch.
        """

        self.repourl = repourl
        self.baseURL = baseURL
        self.defaultBranch = self.branch = defaultBranch
        self.branchType = branchType
        self.method = method
        self.clobberOnBranchChange = clobberOnBranchChange
        Source.__init__(self, **kwargs)
        self.mode = mode
        self.addFactoryArguments(
            repourl=repourl,
            baseURL=baseURL,
            mode=mode,
            method=method,
            defaultBranch=defaultBranch,
            branchType=branchType,
            clobberOnBranchChange=clobberOnBranchChange,
        )

        assert self.mode in ["incremental", "full"]

        if repourl and baseURL:
            raise ValueError("you must provide exactly one of repourl and" " baseURL")

        if repourl is None and baseURL is None:
            raise ValueError("you must privide at least one of repourl and" " baseURL")

        self.repourl = self.repourl and _ComputeRepositoryURL(self.repourl)
        self.baseURL = self.baseURL and _ComputeRepositoryURL(self.baseURL)
Ejemplo n.º 10
0
 def test_backward_compatibility_render(self):
     url = _ComputeRepositoryURL(WithProperties("repourl%(foo)s"))
     self.assertEquals(self.build.render(url), "repourlbar")
Ejemplo n.º 11
0
 def test_dict_render(self):
     d = dict(test=WithProperties("repourl%(foo)s"))
     url = _ComputeRepositoryURL(d)
     self.assertEquals(self.build.render(url), "repourlbar")
Ejemplo n.º 12
0
 def test_callable(self):
     func = lambda x: x[::-1]
     url = _ComputeRepositoryURL(func)
     self.assertEquals(self.build.render(url), "tset")
Ejemplo n.º 13
0
 def test_dict(self):
     dict = {}
     dict['test'] = "ssh://server/testrepository"
     url = _ComputeRepositoryURL(dict)
     self.assertEquals(self.build.render(url),
                       "ssh://server/testrepository")
Ejemplo n.º 14
0
 def test_format_string(self):
     url = _ComputeRepositoryURL("http://server/%s")
     self.assertEquals(self.build.render(url), "http://server/test")
 def test_callable_render(self):
     func = lambda x: WithProperties(x+"%(foo)s")
     url = _ComputeRepositoryURL(func)
     self.assertEquals(self.build.render(url), "testbar")
Ejemplo n.º 16
0
    def __init__(self, repourl=None, branch='master', mode='incremental',
                 method=None, submodule=False, shallow=False, progress=False,
                 retryFetch=False, clobberOnFailure=False, **kwargs):
        """
        @type  repourl: string
        @param repourl: the URL which points at the git repository

        @type  branch: string
        @param branch: The branch or tag to check out by default. If
                       a build specifies a different branch, it will
                       be used instead of this.

        @type  submodules: boolean
        @param submodules: Whether or not to update (and initialize)
                       git submodules.

        @type  mode: string
        @param mode: Type of checkout. Described in docs.

        @type  method: string
        @param method: Full builds can be done is different ways. This parameter
                       specifies which method to use.

        @type  progress: boolean
        @param progress: Pass the --progress option when fetching. This
                         can solve long fetches getting killed due to
                         lack of output, but requires Git 1.7.2+.
        @type  shallow: boolean
        @param shallow: Use a shallow or clone, if possible

        @type  retryFetch: boolean
        @param retryFetch: Retry fetching before failing source checkout.
        """

        self.branch    = branch
        self.method    = method
        self.prog  = progress
        self.repourl   = repourl
        self.retryFetch = retryFetch
        self.submodule = submodule
        self.shallow   = shallow
        self.fetchcount = 0
        self.clobberOnFailure = clobberOnFailure
        Source.__init__(self, **kwargs)
        self.addFactoryArguments(branch=branch,
                                 mode=mode,
                                 method=method,
                                 progress=progress,
                                 repourl=repourl,
                                 submodule=submodule,
                                 shallow=shallow,
                                 retryFetch=retryFetch,
                                 clobberOnFailure=
                                 clobberOnFailure,
                                 )

        self.mode = mode
        assert self.mode in ['incremental', 'full']
        assert self.repourl is not None
        if self.mode == 'full':
            assert self.method in ['clean', 'fresh', 'clobber', 'copy', None]
        self.repourl = self.repourl and _ComputeRepositoryURL(self.repourl)
Ejemplo n.º 17
0
    def __init__(self,
                 repourl=None,
                 baseURL=None,
                 mode='incremental',
                 method=None,
                 defaultBranch=None,
                 branchType='dirname',
                 clobberOnBranchChange=True,
                 **kwargs):
        """
        @type  repourl: string
        @param repourl: the URL which points at the Mercurial repository.
                        This uses the 'default' branch unless defaultBranch is
                        specified below and the C{branchType} is set to
                        'inrepo'.  It is an error to specify a branch without
                        setting the C{branchType} to 'inrepo'.

        @param baseURL: if 'dirname' branches are enabled, this is the base URL
                        to which a branch name will be appended. It should
                        probably end in a slash.  Use exactly one of C{repourl}
                        and C{baseURL}.

        @param defaultBranch: if branches are enabled, this is the branch
                              to use if the Build does not specify one
                              explicitly.
                              For 'dirname' branches, It will simply be
                              appended to C{baseURL} and the result handed to
                              the 'hg update' command.
                              For 'inrepo' branches, this specifies the named
                              revision to which the tree will update after a
                              clone.

        @param branchType: either 'dirname' or 'inrepo' depending on whether
                           the branch name should be appended to the C{baseURL}
                           or the branch is a mercurial named branch and can be
                           found within the C{repourl}

        @param clobberOnBranchChange: boolean, defaults to True. If set and
                                      using inrepos branches, clobber the tree
                                      at each branch change. Otherwise, just
                                      update to the branch.
        """

        self.repourl = repourl
        self.baseURL = baseURL
        self.defaultBranch = self.branch = defaultBranch
        self.branchType = branchType
        self.method = method
        self.clobberOnBranchChange = clobberOnBranchChange
        Source.__init__(self, **kwargs)
        self.mode = mode
        self.addFactoryArguments(
            repourl=repourl,
            baseURL=baseURL,
            mode=mode,
            method=method,
            defaultBranch=defaultBranch,
            branchType=branchType,
            clobberOnBranchChange=clobberOnBranchChange,
        )

        assert self.mode in ['incremental', 'full']

        if repourl and baseURL:
            raise ValueError("you must provide exactly one of repourl and"
                             " baseURL")

        if repourl is None and baseURL is None:
            raise ValueError("you must privide at least one of repourl and"
                             " baseURL")

        self.repourl = self.repourl and _ComputeRepositoryURL(self.repourl)
        self.baseURL = self.baseURL and _ComputeRepositoryURL(self.baseURL)
Ejemplo n.º 18
0
    def __init__(self,
                 repourl=None,
                 branch='master',
                 mode='incremental',
                 method=None,
                 submodule=False,
                 shallow=False,
                 progress=False,
                 retryFetch=False,
                 clobberOnFailure=False,
                 **kwargs):
        """
        @type  repourl: string
        @param repourl: the URL which points at the git repository

        @type  branch: string
        @param branch: The branch or tag to check out by default. If
                       a build specifies a different branch, it will
                       be used instead of this.

        @type  submodules: boolean
        @param submodules: Whether or not to update (and initialize)
                       git submodules.

        @type  mode: string
        @param mode: Type of checkout. Described in docs.

        @type  method: string
        @param method: Full builds can be done is different ways. This parameter
                       specifies which method to use.

        @type  progress: boolean
        @param progress: Pass the --progress option when fetching. This
                         can solve long fetches getting killed due to
                         lack of output, but requires Git 1.7.2+.
        @type  shallow: boolean
        @param shallow: Use a shallow or clone, if possible

        @type  retryFetch: boolean
        @param retryFetch: Retry fetching before failing source checkout.
        """

        self.branch = branch
        self.method = method
        self.prog = progress
        self.repourl = repourl
        self.retryFetch = retryFetch
        self.submodule = submodule
        self.shallow = shallow
        self.fetchcount = 0
        self.clobberOnFailure = clobberOnFailure
        Source.__init__(self, **kwargs)
        self.addFactoryArguments(
            branch=branch,
            mode=mode,
            method=method,
            progress=progress,
            repourl=repourl,
            submodule=submodule,
            shallow=shallow,
            retryFetch=retryFetch,
            clobberOnFailure=clobberOnFailure,
        )

        self.mode = mode
        assert self.mode in ['incremental', 'full']
        assert self.repourl is not None
        if self.mode == 'full':
            assert self.method in ['clean', 'fresh', 'clobber', 'copy', None]
        self.repourl = self.repourl and _ComputeRepositoryURL(self.repourl)