Commits

Michał Górny committed db8f1f8

Mercurial: detect non-live packages.

Comments (0)

Files changed (1)

smartliverebuild/vcs/mercurial.py

 # (c) 2011 Michał Górny <mgorny@gentoo.org>
 # Released under the terms of the 2-clause BSD license.
 
-from . import RemoteVCSSupport
+from . import RemoteVCSSupport, NonLiveEbuild
 
 class MercurialSupport(RemoteVCSSupport):
 	reqenv = ['EHG_REPO_URI', 'EHG_REVISION', 'HG_REV_ID']
 
 	trustopt = ['--config', 'trusted.users=portage'] # XXX: pm.config.userpriv_uid
 
+	def __init__(self, *args, **kwargs):
+		RemoteVCSSupport.__init__(self, *args, **kwargs)
+		if self.revcmp(self.savedrev, self.env['EHG_REVISION']):
+			raise NonLiveEbuild('EHG_REVISION set to a revision, package is not really a live one')
+
 	def __str__(self):
 		return self.env['EHG_REPO_URI']
 
 
 	@staticmethod
 	def revcmp(oldrev, newrev):
-		return newrev.startswith(oldrev)
+		# assume either can be longer
+		return newrev.startswith(oldrev) or oldrev.startswith(newrev)
 
 	@property
 	def updatecmd(self):