Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. HgDriver.php

function HgDriver::getBranches

@inheritDoc

Overrides VcsDriverInterface::getBranches

1 call to HgDriver::getBranches()
HgDriver::initialize in vendor/composer/composer/src/Composer/Repository/Vcs/HgDriver.php
@inheritDoc

File

vendor/composer/composer/src/Composer/Repository/Vcs/HgDriver.php, line 183

Class

HgDriver
@author Per Bernhardt <plb@webfactory.de>

Namespace

Composer\Repository\Vcs

Code

public function getBranches() : array {
    if (null === $this->branches) {
        $branches = [];
        $bookmarks = [];
        $this->process
            ->execute([
            'hg',
            'branches',
        ], $output, $this->repoDir);
        foreach ($this->process
            ->splitLines($output) as $branch) {
            if ($branch && Preg::isMatchStrictGroups('(^([^\\s]+)\\s+\\d+:([a-f0-9]+))', $branch, $match) && $match[1][0] !== '-') {
                $branches[$match[1]] = $match[2];
            }
        }
        $this->process
            ->execute([
            'hg',
            'bookmarks',
        ], $output, $this->repoDir);
        foreach ($this->process
            ->splitLines($output) as $branch) {
            if ($branch && Preg::isMatchStrictGroups('(^(?:[\\s*]*)([^\\s]+)\\s+\\d+:(.*)$)', $branch, $match) && $match[1][0] !== '-') {
                $bookmarks[$match[1]] = $match[2];
            }
        }
        // Branches will have preference over bookmarks
        $this->branches = array_merge($bookmarks, $branches);
    }
    return $this->branches;
}
RSS feed
Powered by Drupal