Mercurial > hg > autobot
changeset 214:ee319fc010fa
more handling of branches....still wont really work
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Wed, 09 Feb 2011 12:11:47 -0800 |
parents | c35135b847fd |
children | 9eded49afdad |
files | autobot/process/factory.py |
diffstat | 1 files changed, 27 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/autobot/process/factory.py Wed Feb 09 08:19:38 2011 -0800 +++ b/autobot/process/factory.py Wed Feb 09 12:11:47 2011 -0800 @@ -133,11 +133,33 @@ for hg_source, branch in self.sources.get('hg', ()): self.addStep(ShellCommand(command=['hg', 'clone', hg_source], **kwargs)) + if branch and branch != 'default': + dirname = self.dirname('hg', hg_source) + self.addStep(ShellCommand(command=['hg', '-R', dirname, 'checkout', branch], + **kwargs)) # clone the git repositories for git_source, branch in self.sources.get('git', ()): self.addStep(ShellCommand(command=['git', 'clone', git_source], **kwargs)) + if branch and branch != 'master': + dirname = self.dirname('git', git_source) + '/.git' + self.addStep(ShellCommand(command=['git', '--git-dir', dirname, 'checkout', branch], + **kwargs)) + + def dirname(self, type, repo): + """ + get the directory name for a given repo + """ + if type == 'git': + dirname = repo.rstrip('/').rsplit('/', 1)[-1] + if dirname.endswith('.git'): + dirname = dirname[:-4] + return dirname + elif type == 'hg': + return repo.rstrip('/').rsplit('/')[-1] + else: + raise NotImplementedError("Unknown repository type: %s" % type) class VirtualenvFactory(SourceFactory): """ @@ -200,15 +222,13 @@ VirtualenvFactory.__init__(self, name=name, hg=hg, git=git) # install the packages - sources = [] + packages = [] for hg_source, branch in self.sources.get('hg', ()): - package = hg_source.rstrip('/').rsplit('/', 1)[-1] - sources.append(package) + package = self.dirname('hg', hg_source) + packages.append(package) for git_source, branch in self.sources.get('git', ()): - package = git_source.rstrip('/').rsplit('/', 1)[-1] - if package.endswith('.git'): - package = package[:-4] - sources.append(package) + package = self.dirname('git', git_source) + packages.append(package) for package in sources: self.addStep(ShellCommand(command=[WithProperties('%(python)s'), 'setup.py', 'install'], workdir=WithProperties('%(virtualenv)s/src/' + package),