1. Tim Molendijk
  2. Mercurial Recipe

Source

Mercurial Recipe / recipe.py

import os
import logging
from mercurial import commands, ui, hg

class Recipe(object):
	
	def __init__(self, buildout, name, options):
		self.options = options
		self.repository = hg.repository(ui.ui(), options.get('repository'))
		self.newest = options.get('newest', buildout.get('buildout').get('newest', 'true')).lower() != 'false'
		self.log = logging.getLogger(name)
		
		self.options.update({
			'location': os.path.join(buildout.get('buildout').get('parts-directory'), name),
		})
	
	def install(self):
		self.log.info("Cloning repository %s to %s" % (self.repository.path, self.options.get('location')))
		commands.clone(ui.ui(), self.repository, self.options.get('location'))
		return self.options.get('location')
	
	def update(self):
		if self.newest:
			return self.install()