示例#1
0
    def checkValid(self, updating):

        #
        # Make sure the local represenation exists and has the correct URL (terminal error),
        # and check if working copy has same revision as rspec specifies (warning).
        #

        # Check if working copy exists at all
        if not self.isLocal() and not updating:
            errorMessage(
                "Local representation of repository '%s' (%s) doesn't exist. The view needs to be updated."
                % (self.getID(), self.getAbsLocalPath())
            )
            return False

        # Check if repository URLs match
        if self.isLocal():
            url = self.client.getURLFromWorkingCopy(self.getAbsLocalPath())
            if not ctx_common.areURLsEqual(url, self.getHref()):
                errorMessage(
                    "Inconsistent repository.\nWorking copy of repository '%s' originates from '%s', but the RSpec specifies '%s'"
                    % (self.getID(), url, self.getHref())
                )
                return False

        # Check revision
        if not updating:
            return self.checkValidRevision()

        return True
示例#2
0
 def checkMissmatchedRepo(self):
     if self.isLocal():
         url = self.client.getURLFromWorkingCopy(self.getAbsLocalPath())
         if not ctx_common.areURLsEqual(url, self.getHref()):
             path = self.getAbsLocalPath()
             infoMessage("Removing missmatched repository: %s" % (path), 1)
             for root, dirs, files in os.walk(path, topdown=False):
                 for name in files:
                     filename = os.path.join(root, name)
                     os.chmod(filename, stat.S_IWRITE)
                     os.remove(filename)
                 for name in dirs:
                     os.rmdir(os.path.join(root, name))