Example #1
0
 def testGetStageNameFromDirectory(self):
     self._prepProductStore()
     stageName = dirstore.getStageNameFromDirectory('foo/stable')
     assert stageName == 'stable'
     os.chdir('foo/stable')
     stageName = dirstore.getStageNameFromDirectory('.')
     assert stageName == 'stable'
     stageName = dirstore.getStageNameFromDirectory()
     assert stageName == 'stable'
Example #2
0
 def testGetStageNameFromDirectory(self):
     self._prepProductStore()
     stageName = dirstore.getStageNameFromDirectory('foo/stable')
     assert stageName == 'stable'
     os.chdir('foo/stable')
     stageName = dirstore.getStageNameFromDirectory('.')
     assert stageName == 'stable'
     stageName = dirstore.getStageNameFromDirectory()
     assert stageName == 'stable'
Example #3
0
    def _printOneDirectoryStatus(self, dirName, displayName,
            verbosity, pendingAnnounce=None, proddef=False,
            local=True, repository=True):
        #pylint: disable-msg=R0912,R0913,R0914
        # branches are required by spec
        # conflating arguments would just make this harder to understand
        # not amenable to refactoring to split up local variables
        '''
        Prints directory status, if any, for a directory that is a
        checkout or stage.  For a directory that is neither a checkout
        not a stage, do nothing.
        @param dirName: Path to directory
        @param displayName: Name to display
        @param verbosity: Level of verbosity
        @param pendingAnnounce: Stage name not yet announced
        @param proddef: Whether this is the product definition
        @param local: Display local filesystem changes not yet committed
        @param repository: Display changes committed to the repository
        but not yet applied locally
        @return: current stage name pendingAnnounce for next iteration
        '''

        conaryfacade = self.handle.facade.conary
        if conaryfacade.isConaryCheckoutDirectory(dirName):
            ui = self.handle.ui

            repositoryChanges = False
            if repository:
                newerVersions = [x for x in
                    conaryfacade._getNewerRepositoryVersions(dirName)]
                repositoryChanges = newerVersions and True or False

            localChanges = False
            if local:
                status = conaryfacade.getCheckoutStatus(dirName)
                if status:
                    localChanges = True

            def writeHeader(header):
                ui.write('%s\n%s', header, '='*len(header))
                
            thisStage = dirstore.getStageNameFromDirectory(dirName)
            if localChanges or repositoryChanges:
                if pendingAnnounce is not None and pendingAnnounce != thisStage:
                    ui.write('\n')
                    writeHeader('%s stage status:' %thisStage)
                    pendingAnnounce = thisStage
                elif proddef:
                    writeHeader('Product %s-%s status:' %(
                                self.handle.product.getProductName(),
                                self.handle.product.getProductVersion()))

                ui.write('%s%s  %s', localChanges and 'L' or '-',
                                     repositoryChanges and 'R' or '-',
                                     displayName)
                
                if verbosity >= DEFAULT:
                    if localChanges and status:
                        ui.write('  * Local changes not committed'
                                    ' to repository:')
                        for x, y in status:
                            ui.write('L-  %s   %s/%s' % (x, displayName, y))
                        if verbosity >= VERBOSE:
                            for line in conaryfacade.iterCheckoutDiff(dirName):
                                ui.write(line)
                    if repositoryChanges:
                        ui.write('  * Remote repository commit messages'
                                    ' for newer versions:')
                        for line in conaryfacade.getCheckoutLog(
                                dirName, versionList=newerVersions):
                            ui.write('-R  %s', line)
                        if verbosity >= VERBOSE:
                            for line in conaryfacade.iterRepositoryDiff(
                                dirName, newerVersions[-1]):
                                ui.write(line)

        return pendingAnnounce
Example #4
0
    def _printOneDirectoryStatus(self,
                                 dirName,
                                 displayName,
                                 verbosity,
                                 pendingAnnounce=None,
                                 proddef=False,
                                 local=True,
                                 repository=True):
        #pylint: disable-msg=R0912,R0913,R0914
        # branches are required by spec
        # conflating arguments would just make this harder to understand
        # not amenable to refactoring to split up local variables
        '''
        Prints directory status, if any, for a directory that is a
        checkout or stage.  For a directory that is neither a checkout
        not a stage, do nothing.
        @param dirName: Path to directory
        @param displayName: Name to display
        @param verbosity: Level of verbosity
        @param pendingAnnounce: Stage name not yet announced
        @param proddef: Whether this is the product definition
        @param local: Display local filesystem changes not yet committed
        @param repository: Display changes committed to the repository
        but not yet applied locally
        @return: current stage name pendingAnnounce for next iteration
        '''

        conaryfacade = self.handle.facade.conary
        if conaryfacade.isConaryCheckoutDirectory(dirName):
            ui = self.handle.ui

            repositoryChanges = False
            if repository:
                newerVersions = [
                    x
                    for x in conaryfacade._getNewerRepositoryVersions(dirName)
                ]
                repositoryChanges = newerVersions and True or False

            localChanges = False
            if local:
                status = conaryfacade.getCheckoutStatus(dirName)
                if status:
                    localChanges = True

            def writeHeader(header):
                ui.write('%s\n%s', header, '=' * len(header))

            thisStage = dirstore.getStageNameFromDirectory(dirName)
            if localChanges or repositoryChanges:
                if pendingAnnounce is not None and pendingAnnounce != thisStage:
                    ui.write('\n')
                    writeHeader('%s stage status:' % thisStage)
                    pendingAnnounce = thisStage
                elif proddef:
                    writeHeader('Product %s-%s status:' %
                                (self.handle.product.getProductName(),
                                 self.handle.product.getProductVersion()))

                ui.write('%s%s  %s', localChanges and 'L' or '-',
                         repositoryChanges and 'R' or '-', displayName)

                if verbosity >= DEFAULT:
                    if localChanges and status:
                        ui.write('  * Local changes not committed'
                                 ' to repository:')
                        for x, y in status:
                            ui.write('L-  %s   %s/%s' % (x, displayName, y))
                        if verbosity >= VERBOSE:
                            for line in conaryfacade.iterCheckoutDiff(dirName):
                                ui.write(line)
                    if repositoryChanges:
                        ui.write('  * Remote repository commit messages'
                                 ' for newer versions:')
                        for line in conaryfacade.getCheckoutLog(
                                dirName, versionList=newerVersions):
                            ui.write('-R  %s', line)
                        if verbosity >= VERBOSE:
                            for line in conaryfacade.iterRepositoryDiff(
                                    dirName, newerVersions[-1]):
                                ui.write(line)

        return pendingAnnounce