You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 line
1.5KB

  1. <?php
  2. /*
  3. * This file is part of the Fxp Composer Asset Plugin package.
  4. *
  5. * (c) François Pluchino <francois.pluchino@gmail.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Fxp\Composer\AssetPlugin\Repository\Vcs;
  11. use Composer\Cache;
  12. use Composer\Repository\Vcs\HgDriver as BaseHgDriver;
  13. use Composer\Util\Filesystem;
  14. use Composer\Util\ProcessExecutor;
  15. /**
  16. * Mercurial vcs driver.
  17. *
  18. * @author François Pluchino <francois.pluchino@gmail.com>
  19. */
  20. class HgDriver extends BaseHgDriver
  21. {
  22. /**
  23. * @var Cache
  24. */
  25. protected $cache;
  26. /**
  27. * {@inheritdoc}
  28. */
  29. public function initialize()
  30. {
  31. parent::initialize();
  32. $cacheUrl = Filesystem::isLocalPath($this->url)
  33. ? realpath($this->url)
  34. : $this->url;
  35. $this->cache = new Cache($this->io, $this->config->get('cache-repo-dir').'/'.preg_replace('{[^a-z0-9.]}i', '-', $cacheUrl));
  36. }
  37. /**
  38. * {@inheritdoc}
  39. */
  40. public function getComposerInformation($identifier)
  41. {
  42. $resource = sprintf('%s %s', ProcessExecutor::escape($identifier), $this->repoConfig['filename']);
  43. return ProcessUtil::getComposerInformation($this->cache, $this->infoCache, $this->repoConfig['asset-type'], $this->process, $identifier, $resource, sprintf('hg cat -r %s', $resource), sprintf('hg log --template "{date|rfc3339date}" -r %s', ProcessExecutor::escape($identifier)), $this->repoDir);
  44. }
  45. }