Example #1
0
 private function guessHgVersion(array $config)
 {
     if (0 === $this->process->execute('hg branch', $output)) {
         $branch = trim($output);
         $version = $this->versionParser->normalizeBranch($branch);
         $isFeatureBranch = 0 === strpos($version, 'dev-');
         if ('9999999-dev' === $version) {
             $version = 'dev-' . $branch;
         }
         if (!$isFeatureBranch) {
             return $version;
         }
         $config = array('url' => getcwd());
         $driver = new HgDriver($config, new NullIO(), $this->config, $this->process);
         $branches = array_keys($driver->getBranches());
         $version = $this->guessFeatureVersion($config, $version, $branches, 'hg log -r "not ancestors(\'%candidate%\') and ancestors(\'%branch%\')" --template "{node}\\n"');
         return $version;
     }
 }
Example #2
0
 private function guessHgVersion(array $config)
 {
     // try to fetch current version from hg branch
     if (0 === $this->process->execute('hg branch', $output)) {
         $branch = trim($output);
         $version = $this->versionParser->normalizeBranch($branch);
         $isFeatureBranch = 0 === strpos($version, 'dev-');
         if ('9999999-dev' === $version) {
             $version = 'dev-' . $branch;
         }
         if (!$isFeatureBranch) {
             return $version;
         }
         // re-use the HgDriver to fetch branches (this properly includes bookmarks)
         $config = array('url' => getcwd());
         $driver = new HgDriver($config, new NullIO(), $this->config, $this->process);
         $branches = array_keys($driver->getBranches());
         // try to find the best (nearest) version branch to assume this feature's version
         $version = $this->guessFeatureVersion($config, $version, $branches, 'hg log -r "not ancestors(\'%candidate%\') and ancestors(\'%branch%\')" --template "{node}\\n"');
         return $version;
     }
 }