eggs/infrae.subversion-1.4.5-py2.6.egg/infrae/subversion/Py.py
changeset 69 c6bca38c1cbf
equal deleted inserted replaced
68:5ff1fc726848 69:c6bca38c1cbf
       
     1 # Copyright (c) 2007-2008 Infrae. All rights reserved.
       
     2 # $Id: Py.py 32775 2009-01-05 10:53:29Z sylvain $
       
     3 
       
     4 import os
       
     5 import py
       
     6 
       
     7 from Common import BaseRecipe, prepareURLs
       
     8 from Common import checkAddedPaths, checkExistPath, reportInvalidFiles
       
     9 
       
    10 
       
    11 class Recipe(BaseRecipe):
       
    12     """infrae.subversion recipe.
       
    13     """
       
    14 
       
    15     def __init__(self, buildout, name, options):
       
    16         super(Recipe, self).__init__(buildout, name, options)
       
    17         if self.verbose:
       
    18             print 'Using py implementation.'
       
    19         if not self.offline:    # Py is not able to do svn status
       
    20                                 # without asking something on a
       
    21                                 # server.
       
    22             self._updateAllRevisionInformation()
       
    23         self._exportInformationToOptions()
       
    24 
       
    25     def _updateRevisionInformation(self, link, path):
       
    26         """Update revision information on a path.
       
    27         """
       
    28         if isinstance(path, str):
       
    29             path = py.path.svnwc(path)
       
    30 
       
    31         revision = path.status().rev
       
    32         super(Recipe, self)._updateRevisionInformation(link, revision)
       
    33 
       
    34     def _updatePath(self, link, path):
       
    35         """Update a single path.
       
    36         """
       
    37         wc = py.path.svnwc(path)
       
    38         wc.update()
       
    39         self._updateRevisionInformation(link, wc)
       
    40 
       
    41     def _installPath(self, link, path):
       
    42         """Checkout a single entry.
       
    43         """
       
    44         if self.export:
       
    45             raise NotImplementedError
       
    46         wc = py.path.svnwc(path)
       
    47         wc.checkout(link)
       
    48         self._updateRevisionInformation(link, wc)
       
    49 
       
    50 
       
    51 def uninstall(name, options):
       
    52     r"""
       
    53     This is an uninstallation hook for the 'infrae.subversion' recipe.
       
    54 
       
    55     Its only job is to raise an exception when there are changes in a
       
    56     subversion tree that a user might not want to lose.  This function
       
    57     does *not* delete or otherwise touch any files.
       
    58 
       
    59     The location of the path is passed as options['location'].
       
    60     """
       
    61     if bool(options.get('export', False)):
       
    62         return                  # SVN Export, there is nothing to check.
       
    63 
       
    64     if bool(options.get('ignore_verification', False)):
       
    65         return                  # Verification disabled.
       
    66 
       
    67 
       
    68     # XXX This makes the assumption that we're in the buildout
       
    69     #     directory and that our part is in 'parts'.  We don't have
       
    70     #     options['buildout'] available so no
       
    71     #     'buildout:parts-directory'.
       
    72     location = options.get('location', os.path.join('.', 'parts', name))
       
    73     urls = prepareURLs(location, options['urls'])
       
    74 
       
    75     if not checkExistPath(location):
       
    76         return
       
    77 
       
    78     checkAddedPaths(location, urls)
       
    79 
       
    80     for path in urls.keys():
       
    81         if not checkExistPath(path):
       
    82             continue
       
    83 
       
    84         wc = py.path.svnwc(path)
       
    85         status = wc.status(rec=1)
       
    86         badfiles = [] + status.modified + status.incomplete + status.unknown
       
    87         reportInvalidFiles(path, name, [file.strpath for file in badfiles])