def populatedRepositorySetUp(self, parent, name):
     """Prepare the test repsotiroy"""
     self.workd = join(parent, name)
     deferred = run('mkdir', ['-p', self.workd])
     deferred.addCallback(lambda _: self.git('init'))
     deferred.addCallback(lambda _: add_commit(self.workd, 'bar', 
                                  'spong', 'foo'))
     return deferred.addCallback(lambda _: git(self.workd, 'tag', 'master-1'))
def add_commit(workd, filename, contents, message, branch='master'):
    """Add a commit to workd which sets filename to contain
    contents with commit message on branch"""
    deferred = git(workd, 'branch').addCallback(linesplitdropsplit)
    def consider_branch_list(branches):
        if ([br for br in branches if br[1] == branch] == [] and 
            branch != 'master'):
            return git(workd, 'checkout', '-b', branch)
    deferred.addCallback(consider_branch_list)
    def write(_):
        with file(workd+'/'+filename, 'w') as fobj:
            fobj.write(contents)
    deferred.addCallback(write)
    deferred.addCallback(lambda _: git(workd, 'add', filename))
    def commit(_):
        """Perform the commit"""
        return git(workd, 'commit', '-m', message)
    return deferred.addCallback(commit)
 def git(self, *arguments):
     """Run a git command with arguments on our test repository"""
     return git(self.workd, *arguments)
 def commit(_):
     """Perform the commit"""
     return git(workd, 'commit', '-m', message)
 def consider_branch_list(branches):
     if ([br for br in branches if br[1] == branch] == [] and 
         branch != 'master'):
         return git(workd, 'checkout', '-b', branch)