1. Michał Górny
  2. smart-live-rebuild


Michał Górny  committed db8f1f8

Mercurial: detect non-live packages.

  • Participants
  • Parent commits d760067
  • Branches master

Comments (0)

Files changed (1)

File smartliverebuild/vcs/mercurial.py

View file
  • Ignore whitespace
 # (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']
 	def revcmp(oldrev, newrev):
-		return newrev.startswith(oldrev)
+		# assume either can be longer
+		return newrev.startswith(oldrev) or oldrev.startswith(newrev)
 	def updatecmd(self):