smart-live-rebuild / smartliverebuild / vcs /

#	vim:fileencoding=utf-8
# (c) 2011 Michał Górny <>
# Released under the terms of the 2-clause BSD license.

from . import RemoteVCSSupport, NonLiveEbuild

class BzrSupport(RemoteVCSSupport):
	optenv = ['EBZR_REVISION']

	def callenv(self):
		env = RemoteVCSSupport.callenv.fget(self).copy()
		env.update({'BZR_LOG': '/dev/null'})
		return env

	def __init__(self, *args, **kwargs):
		RemoteVCSSupport.__init__(self, *args, **kwargs)
		if self.env['EBZR_REVISION']:
			raise NonLiveEbuild('EBZR_REVISION set, package is not really a live one')

	def __str__(self):
		return self.env['EBZR_REPO_URI']

	def parseoutput(self, out):
		return int(out) if out else None

	def savedrev(self):
		rev = self.env['EBZR_REVNO']
		return self.parseoutput(rev)

	def revcmp(oldrev, newrev):
		return oldrev >= newrev

	def updatecmd(self):
		return '%s %s' % (self.env['EBZR_REVNO_CMD'], self.env['EBZR_REPO_URI'])