def verify(self): # Safety belt that we're acting on a clean repository. if self.environment.deployment.dirty: output.annotate( "You are running a dirty deployment. This can cause " "inconsistencies -- continuing on your own risk!", red=True) return try: status, _ = cmd('hg -q stat') except CmdExecutionError: output.error('Unable to check repository status. ' 'Is there an HG repository here?') raise else: status = status.strip() if status.strip(): output.error("Your repository has uncommitted changes.") output.annotate("""\ I am refusing to deploy in this situation as the results will be unpredictable. Please commit and push first. """, red=True) output.annotate(status, red=True) raise DeploymentError() try: cmd('hg -q outgoing -l 1', acceptable_returncodes=[1]) except CmdExecutionError: output.error("""\ Your repository has outgoing changes. I am refusing to deploy in this situation as the results will be unpredictable. Please push first. """) raise DeploymentError()
def call(*args, **kw): output.annotate("rpc {}: {}(*{}, **{})".format( self.host.fqdn, name, args, kw), debug=True) self.host.channel.send((name, args, kw)) while True: message = self.host.channel.receive() output.annotate("{}: message: {}".format( self.host.fqdn, message), debug=True) type = message[0] if type == "batou-result": return message[1] elif type == "batou-output": _, output_cmd, args, kw = message getattr(output, output_cmd)(*args, **kw) elif type == "batou-configuration-error": raise SilentConfigurationError() elif type == "batou-deployment-error": raise DeploymentError() elif type == "batou-unknown-error": output.error(message[1]) raise RuntimeError( "{}: Remote exception encountered.".format( self.host.fqdn)) elif type == "batou-error": # Remote put out the details already. raise RuntimeError( "{}: Remote exception encountered.".format( self.host.fqdn)) else: raise RuntimeError("{}: Unknown message type {}".format( self.host.fqdn, type))
def verify(self): # Safety belt that we're acting on a clean repository. if self.environment.deployment.dirty: output.annotate( "You are running a dirty deployment. This can cause " "inconsistencies -- continuing on your own risk!", red=True, ) return try: status, _ = cmd("git status --porcelain") except CmdExecutionError: output.error("Unable to check repository status. " "Is there a Git repository here?") raise else: status = status.strip() if status.strip(): output.error("Your repository has uncommitted changes.") output.annotate( """\ I am refusing to deploy in this situation as the results will be unpredictable. Please commit and push first. """, red=True, ) output.annotate(status, red=True) raise DeploymentError() outgoing, _ = cmd( "git log {remote}/{branch}..{branch} --pretty=oneline".format( remote=self.remote, branch=self.branch), acceptable_returncodes=[0, 128], ) if outgoing.strip(): output.error("""\ Your repository has outgoing changes. I am refusing to deploy in this situation as the results will be unpredictable. Please push first. """) raise DeploymentError()
def verify(self): # Safety belt that we're acting on a clean repository. if self.environment.deployment.dirty: output.annotate( "You are running a dirty deployment. This can cause " "inconsistencies -- continuing on your own risk!", red=True) return try: status = hg_cmd("hg stat") except CmdExecutionError: output.error("Unable to check repository status. " "Is there an HG repository here?") raise else: if status: output.error("Your repository has uncommitted changes.") output.annotate( """\ I am refusing to deploy in this situation as the results will be unpredictable. Please commit and push first. """, red=True) for item in status: output.annotate( "{} {}".format(item['status'], item['path']), red=True) raise DeploymentError("Uncommitted changes") try: cmd("hg -q outgoing -l 1", acceptable_returncodes=[1]) except CmdExecutionError: output.error("""\ Your repository has outgoing changes. I am refusing to deploy in this situation as the results will be unpredictable. Please push first. """) raise DeploymentError("Outgoing changes")