Logo Search packages:      
Sourcecode: tailor version File versions  Download package

def vcpx::cvsps::CvspsWorkingDir::_checkoutUpstreamRevision (   self,
) [private]

Concretely do the checkout of the upstream sources. Use
`revision` as the name of the tag to get, or as a date if it
starts with a number.

Return the last applied changeset.

Definition at line 254 of file cvsps.py.

00254                                                  :
        Concretely do the checkout of the upstream sources. Use
        `revision` as the name of the tag to get, or as a date if it
        starts with a number.

        Return the last applied changeset.

        from os.path import join, exists, split
        from cvs import CvsEntries, compare_cvs_revs
        from time import sleep

        if not self.repository.module:
            raise InvocationError("Must specify a module name")

        timestamp = None
        if revision is not None:
            # If the revision contains a space, assume it really
            # specify a branch and a timestamp. If it starts with
            # a digit, assume it's a timestamp. Otherwise, it must
            # be a branch name
            if revision[0] in '0123456789' or revision == 'INITIAL':
                timestamp = revision
                revision = None
            elif ' ' in revision:
                revision, timestamp = revision.split(' ', 1)

        csets = self.getPendingChangesets(revision)
        if not csets:
            raise TargetInitializationFailure(
                "Something went wrong: there are no changesets since "
                "revision '%s'" % revision)
        if timestamp == 'INITIAL':
            initialcset = csets.next()
            timestamp = initialcset.date.isoformat(sep=' ')
            initialcset = None

        if not exists(join(self.basedir, 'CVS')):
            # CVS does not handle "checkout -d multi/level/subdir", so
            # split the basedir and use it's parentdir as cwd below.
            parentdir, subdir = split(self.basedir)
            cmd = self.repository.command("-q",
                                          "-d", self.repository.repository,
                                          "-d", subdir)
            if revision:
                cmd.extend(["-r", revision])
            if timestamp:
                cmd.extend(["-D", "%s UTC" % timestamp])

            checkout = ExternalCommand(cwd=parentdir, command=cmd)
            retry = 0
            while True:
                if checkout.exit_status:
                    retry += 1
                    if retry>3:
                    delay = 2**retry
                    self.log.warning("%s returned status %s, "
                                     "retrying in %d seconds...",
                                     str(checkout), checkout.exit_status,

            if checkout.exit_status:
                raise TargetInitializationFailure(
                    "%s returned status %s" % (str(checkout),
            self.log.info("Using existing %s", self.basedir)

        if self.repository.tag_entries:

        entries = CvsEntries(self.basedir)
        youngest_entry = entries.getYoungestEntry()
        if youngest_entry is None:
            raise EmptyRepositoriesFoolsMe("The working copy '%s' of the "
                                           "CVS repository seems empty, "
                                           "don't know how to deal with "
                                           "that." % self.basedir)

        # loop over the changesets and find the last applied, to find
        # out the actual cvsps revision

        found = False
        csets = self.state_file.reversed()

        def already_applied(cs, entries=entries):
            "Loop over changeset entries to determine if it's already applied."

            applied = False
            for m in cs.entries:
                info = entries.getFileInfo(m.name)
                if info:
                    odversion = info.cvs_version
                    applied = compare_cvs_revs(odversion, m.new_revision) >= 0
                    if not applied:
            return applied

        for cset in csets:
            found = already_applied(cset)
            if found:
                last = cset

        if not found and initialcset:
            found = already_applied(initialcset)
            if found:
                last = initialcset

        if not found:
            raise TargetInitializationFailure(
                "Something went wrong: unable to determine the exact upstream "
                "revision of the checked out tree in '%s'" % self.basedir)
            self.log.info("Working copy up to revision %s", last.revision)

        return last

    def _willApplyChangeset(self, changeset, applyable=None):

Generated by  Doxygen 1.6.0   Back to index