Source

gorilla / lib / gorilla / guts / repo.py

import subprocess

class MercurialRepo(object):
    def __init__(self, path, sources):
        self.path = path
        self.sources = sources['hg']
        self.command = ['hg', '-R', self.path]
    
    def clone(self):
        command = self.command + ['clone', self.sources[0], '--noupdate']
        
        rc = subprocess.call(command, shell=False, stdout=subprocess.PIPE)
        return rc == 0
    
    def pull(self):
        command = self.command + ['pull', self.sources[0]]
        
        rc = subprocess.call(command, shell=False, stdout=subprocess.PIPE)
        return rc == 0
    
    def update(self, version):
        version = 'tip' if version == 'latest' else version
        command = self.command + ['update', version]
        
        rc = subprocess.call(command, shell=False, stdout=subprocess.PIPE)
        return rc == 0
    
    @property
    def tags(self):
        command = self.command + ['tags', '--quiet']
        proc = subprocess.Popen(command, shell=False, stdout=subprocess.PIPE)
        
        return proc.communicate()[0].splitlines()