Adds a leaf to the branch tree.

@param Branch $branch
513123
public function addLeaf(Branch $branch)
    {
        if (isset($this->branchMap[$branch->getUniqueId()])) {
            $branchNode = $this->branchMap[$branch->getUniqueId()];
        } else {
            $branchNode = new BranchGraphNode($branch);
        }
        $branchNode->increase();

        $tempBranch = $branch->getParentBranch();
        while ($tempBranch) {
            if (isset($this->branchMap[$tempBranch->getUniqueId()])) {
                $parentBranchNode = $this->branchMap[$tempBranch->getUniqueId()];
            } else {
                $parentBranchNode = new BranchGraphNode($tempBranch);
                $this->branchMap[$tempBranch->getUniqueId()] = $parentBranchNode;
            }
            $parentBranchNode->insert($branchNode);
            $branchNode = $parentBranchNode;
            $tempBranch = $tempBranch->getParentBranch();
            if (!$tempBranch) {
                $this->root = $parentBranchNode;
            }
        }
    }
172125
protected function _addBranch(Zend_Config $config, SimpleXMLElement $xml, SimpleXMLElement $parent)
    {
        $branchType = null;

        foreach ($config as $key => $value) {
            if ($branchType === null) {
                if (is_numeric($key)) {
                    $branchType = 'numeric';
                    $branchName = $xml->getName();
                    $xml        = $parent;

                    unset($parent->{$branchName});
                } else {
                    $branchType = 'string';
                }
            } else if ($branchType !== (is_numeric($key) ? 'numeric' : 'string')) {
                // require_once 'Zend/Config/Exception.php';
                throw new Zend_Config_Exception('Mixing of string and numeric keys is not allowed');
            }

            if ($branchType === 'numeric') {
                if ($value instanceof Zend_Config) {
                    $child = $parent->addChild($branchName);

                    $this->_addBranch($value, $child, $parent);
                } else {
                    $parent->addChild($branchName, (string) $value);
                }
            } else {
                if ($value instanceof Zend_Config) {
                    $child = $xml->addChild($key);

                    $this->_addBranch($value, $child, $xml);
                } else {
                    $xml->addChild($key, (string) $value);
                }
            }
        }
    }
680239
public void checkout(String branch) throws Exception {
        if (!branch.equals(getBranch())) {
            createBranchIfNeeded(branch);
            git.checkout().setName(branch).setStartPoint("origin/" + branch)
                .setUpstreamMode(CreateBranchCommand.SetupUpstreamMode.TRACK).call();
            // for some reason jgit needs this when branch is switched
            git.checkout().setName(branch).call();
        }
    }
1159749
public function load($slug, $branch = 'master')
    {
        $this->data = array();
        $this->httpClient->setBaseUrl($this->helper->getRawFileUrl($slug, $branch, ''));

        $this->data = $this->getResponse('composer.json');
    }
1207804
public function setBranch($value)
    {
        $this->_validateNotNull('Branch', $value);
        $this->_validateString('Branch', $value);

        if ($this->data['branch'] === $value) {
            return;
        }

        $this->data['branch'] = $value;

        $this->_setModified('branch');
    }
892988
def add_leaf(self, leaf_blob):
        
        self.leaves.append(MerkleLeaf(len(self.leaves), leaf_blob))
423657
private function buildRootNode($node, $tree, $level)
    {
        $node->setLevel($level);
        $tree[$node->getId()] = $node;
    }
797740
public function addFragment($fragment)
    {
        if (is_array($fragment)) {
            $this->fragments = array_merge($this->fragments, $fragment);
        } else {
            $this->fragments[] = $fragment;
        }
    }
658058
function _buildTree(&$tree, &$element) {
        $tree[$element->name()] = $element;
        if ($element->superclass()) {
            $rootDoc = & $this->_doclet->rootDoc();
            $superclass = & $rootDoc->classNamed($element->superclass());
            if ($superclass) {
                $this->_buildTree($tree, $superclass);
            }
        }
    }
314873
public function setHead($name, $branch)
    {
        $this->arguments[] = 'set-head';
        $this->arguments[] = $name;
        $this->arguments[] = $branch;
        return $this;
    }
177221
public function import($repository, $branch = null, $file = null)
    {
        return $this->request(sprintf('github/%s?branch=%s&file=%s', $this->transform($repository), $branch, $file), 'POST');
    }
663701
protected function copyBranch($branch, $parentId) {
        $Model = $this->Model;

        $copy = new $Model($branch->attributesToArray());
        $copy->parentId = $parentId;
        $copy->save();
        $parentId = $copy->id;

        foreach ( $branch->children as $child ) {
            $this->copyBranch($child, $parentId);
        }

        return $copy;
    }
137881
def _add_default_branch(self, body):
        """"""
        assert isinstance(body, CodeStatement)
        if isinstance(body, CodeBlock):
            self.else_body = body
        else:
            self.else_body._add(body)
146943
protected function moveFirstChildBefore()
	{
		$branches = $this->getBranches();
		$this->choose->parentNode->insertBefore(array_pop($branches)->firstChild, $this->choose);
		foreach ($branches as $branch)
		{
			$branch->removeChild($branch->firstChild);
		}
	}
734386
public function branch($branch, $stash)
    {
        $stash = $this->normalizeStashName($stash);
        $this->clearAll();
        $this->addCommandName(self::STASH_COMMAND . ' branch');
        $this->addCommandSubject($branch);
        $this->addCommandSubject2($stash);
        return $this->getCommand();
    }
1047288
public function build($projectId, $branch = '')
    {
        /* @var \PHPCI\Model\Project $project */
        $project = $this->projectStore->getById($projectId);

        if (empty($project)) {
            throw new NotFoundException(Lang::get('project_x_not_found', $projectId));
        }
      
        if ($branch === '' && filter_input(INPUT_GET, 'branch') !== null) {
            $branch = filter_input(INPUT_GET, 'branch');
        }

        if (empty($branch)) {
            $branch = $project->getBranch();
        }

        $email = $_SESSION['phpci_user']->getEmail();
        $build = $this->buildService->createBuild($project, null, urldecode($branch), $email);

        if ($this->buildService->queueError) {
            $_SESSION['global_error'] = Lang::get('add_to_queue_failed');
        }

        $response = new b8\Http\Response\RedirectResponse();
        $response->setHeader('Location', PHPCI_URL.'build/view/' . $build->getId());
        return $response;
    }
1170908
public function setBranches($name, $branch, $add = false)
    {
        $this->arguments[] = 'set-branches';
        if ($add) {
            $this->arguments[] = '--add';
        }
        $this->arguments[] = $name;
        $this->arguments[] = $branch;
        return $this;
    }