# HG changeset patch # User Jeff Hammel # Date 1297282307 28800 # Node ID ee319fc010fa012fd8232f9e0a3a3b9e86d4536b # Parent c35135b847fdf8a76890a009ba01f316cd43a21e more handling of branches....still wont really work diff -r c35135b847fd -r ee319fc010fa autobot/process/factory.py --- 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),