Split Git subTree.

@param string $subtree
@param string $namespace

@return  void
510058
protected function splitTree($subtree, $namespace)
    {
        $this->out()->out(sprintf('@ Start subtree split (%s)', $subtree))
            ->out('---------------------------------------');

        // Do split
        $this->exec(sprintf('git branch -D sub-%s', $subtree));
        $this->exec('git subtree split -P src/' . $namespace . ' -b sub-' . $subtree);

        // Create a new branch
        $this->exec(sprintf('git branch -D %s-%s', $this->branch, $subtree));

        // Add remote repo
        $this->exec(
            sprintf(
                'git remote add %s git@github.com:%s/windwalker-%s.git', $subtree, $this->organization,
                $subtree
            )
        );

        $force = $this->io->getOption('f') ?: $this->io->getOption('force', false);

        $force = $force ? ' -f' : false;

        if (!$force) {
            $this->exec(sprintf('git fetch %s', $subtree));

            $this->exec(
                sprintf(
                    'git checkout -b %s-%s --track %s/%s', $this->branch, $subtree, $subtree,
                    $this->branch
                )
            );

            $this->exec(sprintf('git merge sub-%s', $subtree));
        }

        $this->exec(sprintf('git push %s sub-%s:%s ' . $force, $subtree, $subtree, $this->branch));

        if ($this->tag) {
            $this->exec('git checkout sub-' . $subtree);

            $this->exec(sprintf('git tag -d %s', $this->tag));

            $this->exec(sprintf('git push %s :refs/tags/%s', $subtree, $this->tag));

            $this->exec(sprintf('git tag %s', $this->tag));

            $this->exec(sprintf('git push %s %s', $subtree, $this->tag));
        }

        $this->exec('git checkout ' . $this->branch);
    }
372473
public function preloadEmbeddedNodes(
        array $messages,
        array $paths = [],
        string $namespace = NcrPreloader::DEFAULT_NAMESPACE
    ): void {
        $this->ncrPreloader->addEmbeddedNodeRefs($messages, $paths, $namespace);
    }
927569
private function removeNonSatNSNode(string $namespace)
    {
        foreach ($this->dom()->getElementsByTagNameNS($namespace, '*') as $children) {
            $children->parentNode->removeChild($children);
        }
    }
177928
public function subtreePushBltProject($options = [
    'branch' => NULL,
  ]) {
    $this->say("Pushing to acquia/blt-project");
    $prefix = "subtree-splits/blt-project";
    $url = "git@github.com:acquia/blt-project.git";
    if (!$options['branch']) {
      $options['branch'] = $this->getCurrentBranch();
    }
    $this->_exec("git subtree add --prefix $prefix $url {$options['branch']} --squash");
    $this->_exec("git subtree pull --prefix $prefix $url {$options['branch']} --squash");
    $this->_exec("git subtree push --prefix $prefix $url {$options['branch']} --squash");
  }
112068
public function setSubclasses(array $subclasses)
    {
        foreach ($subclasses as $subclass) {
            if (strpos($subclass, '\\') === false && strlen($this->namespace)) {
                $this->subClasses[] = $this->namespace . '\\' . $subclass;
            } else {
                $this->subClasses[] = $subclass;
            }
        }
    }
786563
private function loadSubContexts($subcontexts)
    {
        foreach ($subcontexts as $path => $subcontext) {
            if (!file_exists($path)) {
                throw new \RuntimeException(sprintf('Subcontext path %s path does not exist.', $path));
            }

            // Load file.
            require_once $path;
        }
    }
1136721
public function setTo($namespace, $key, $value = null)
    {
        $oldNamespace = $this->namespace;
        $this->setNamespace($namespace);
        $this->set($key, $value);
        $this->setNamespace($oldNamespace);
    }
16855
private static function splitFilters(array $tree): array
    {
        $n = \count($tree);

        $filters = $temp = [];
        $lastSplit = null;

        $first = \array_search('|', $tree, false);

        for ($i = $n - 1; $i >= $first; --$i) {
            $part = $tree[$n];

            if (\is_array($part)) {
                $temp[] = $part;
                continue;
            }

            /* @var Token $part */
            if ($part->is('|')) {
                if ($temp === []) {
                    throw new \InvalidArgumentException('Invalid filter syntax');
                }

                $count = \count($temp);

                $args = [];
                if ($count === 1) {
                    $name = $temp[0];
                } elseif ($count === 2) {
                    [$args, $name] = $temp;
                } else {
                    break;
                }

                if ($name instanceof Token && \is_array($args) && $name->is(T_STRING)) {
                    $lastSplit = $i;
                    $filters[] = [$name, $args];
                } else {
                    break;
                }
            } else {
                $temp[] = $part;
            }
        }

        $tree = \array_slice($tree, 0, $lastSplit);
        $filters = \array_reverse($filters);

        return [$tree, $filters];
    }
1156125
function fixSubtree( $element, $mainChild )
    {
        $parent = $element->parentNode;
        $mainParent = $mainChild->parentNode;
        while ( $element->hasChildNodes() )
        {
            $child = $element->firstChild;

            $child = $element->removeChild( $child );
            $child = $mainParent->insertBefore( $child, $mainChild );

            if ( !$this->XMLSchema->check( $mainParent, $child ) )
            {
                $this->fixSubtree( $child, $mainChild );
            }
        }
        $parent->removeChild( $element );
    }
784907
public function clearFrom($namespace, $key = null)
    {
        $oldNamespace = $this->namespace;
        $this->setNamespace($namespace);
        $this->clear($key);
        $this->setNamespace($oldNamespace);
    }
948965
protected function buildTree(array $simpleTree, $tree = [])
    {
        foreach ($simpleTree as $item) {
            if (!isset($this->collection[$item['id']])) {
                continue;
            }

            $content = $this->collection[$item['id']];

            unset($this->collection[$item['id']]); // TODO Fix multi-usage of single item

            if (isset($item['__children']) && count($item['__children'])) {
                $content['__children'] = $this->buildTree($item['__children']);
            } else {
                $content['__children'] = [];
            }

            $tree[] = $content;
        }

        return $tree;
    }
364313
public function setPaths($paths, $namespace = self::DEFAULT_NAMESPACE)
    {
        if (! is_array($paths)) {
            $paths = [$paths];
        }
        $this->paths[$namespace] = [];
        foreach ($paths as $path) {
            $this->addPath($path, $namespace);
        }
    }
921584
public function append_subtree(_smarty_parsetree $subtree)
    {
        $last_subtree = count($this->subtrees) - 1;
        if ($last_subtree >= 0 && $this->subtrees[$last_subtree] instanceof _smarty_tag && $this->subtrees[$last_subtree]->saved_block_nesting < $this->parser->block_nesting_level) {
            if ($subtree instanceof _smarty_code) {
                $this->subtrees[$last_subtree]->data .= '<?php echo ' . $subtree->data . ';?>';
            } elseif ($subtree instanceof _smarty_dq_content) {
                $this->subtrees[$last_subtree]->data .= '<?php echo "' . $subtree->data . '";?>';
            } else {
                $this->subtrees[$last_subtree]->data .= $subtree->data;
            }
        } else {
            $this->subtrees[] = $subtree;
        }
        if ($subtree instanceof _smarty_tag) {
            $this->parser->block_nesting_level = count($this->parser->compiler->_tag_stack);
        }
    }
895393
public void mergeSubtree(final OperationTransformerRegistry targetRegistry, final Map<PathAddress, ModelVersion> subTree) {
        for(Map.Entry<PathAddress, ModelVersion> entry: subTree.entrySet()) {
            mergeSubtree(targetRegistry, entry.getKey(), entry.getValue());
        }
    }
526608
public function TraverseSubtree( $action )
	{
		if ( ! is_null( $this->_childs ) )
		{
			foreach ( $this->_childs as $node )
			{
				$action( $node );
				$node->TraverseSubtree( $action );
			}
		}
	}
227887
def get_subtree(self, tree, xpath_str):
        """"""
        return tree.xpath(xpath_str, namespaces=self.namespaces)
654608
private function build_section_sub_tree($main_tree, $tree_level, $section_level) {
    $sub_sections = array();
    if (isset($main_tree[$tree_level]) && isset($main_tree[$tree_level][$section_level])) {
      $sub_sections = $main_tree[$tree_level][$section_level];
      $sub_tree_level = $tree_level + 1;
      foreach ($sub_sections as $sub_section_level => $sub_section) {
        $sub_sections[$sub_section_level]['sub'] = $this->build_section_sub_tree($main_tree, $sub_tree_level, $sub_section_level);
      }
    }
    return $sub_sections;
  }