<commit_before><?php

final class DifferentialRevisionIDField
  extends DifferentialCustomField {

  public function getFieldKey() {
    return 'differential:revision-id';
  }

  public function getFieldKeyForConduit() {
    return 'revisionID';
  }

  public function getFieldName() {
    return pht('Differential Revision');
  }

  public function getFieldDescription() {
    return pht(
      'Ties commits to revisions and provides a permananent link between '.
      'them.');
  }

  public function canDisableField() {
    return false;
  }

  public function shouldAppearInCommitMessage() {
    return true;
  }

  public function shouldAllowEditInCommitMessage() {
    return false;
  }

  public function parseValueFromCommitMessage($value) {
    return self::parseRevisionIDFromURI($value);
  }

  public function renderCommitMessageValue(array $handles) {
    return PhabricatorEnv::getProductionURI('/D'.$this->getObject()->getID());
  }

  private static function parseRevisionIDFromURI($uri) {
    $path = id(new PhutilURI($uri))->getPath();
<commit_msg>Fix "arc diff --verbatim" when updating a revision<commit_after><?php

final class DifferentialRevisionIDField
  extends DifferentialCustomField {

  private $revisionID;

  public function getFieldKey() {
    return 'differential:revision-id';
  }

  public function getFieldKeyForConduit() {
    return 'revisionID';
  }

  public function getFieldName() {
    return pht('Differential Revision');
  }

  public function getFieldDescription() {
    return pht(
      'Ties commits to revisions and provides a permananent link between '.
      'them.');
  }

  public function canDisableField() {
    return false;
  }

  public function shouldAppearInCommitMessage() {
    return true;
  }

  public function parseValueFromCommitMessage($value) {
    return self::parseRevisionIDFromURI($value);
  }

  public function renderCommitMessageValue(array $handles) {
    $id = coalesce($this->revisionID, $this->getObject()->getID());
    if (!$id) {
      return null;
    }
    return PhabricatorEnv::getProductionURI('/D'.$id);
  }

  public function readValueFromCommitMessage($value) {
    $this->revisionID = $value;
  }

  private static function parseRevisionIDFromURI($uri) {
    $path = id(new PhutilURI($uri))->getPath();

{'fraction_non_alphanumeric': 0.10748476936466493, 'fraction_numerical': 0.0, 'mean_word_length': 4.063876651982379, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5760367', 'n_tokens_mistral': 701, 'n_tokens_neox': 666, 'n_words': 158}