Skip to content

Commit

Permalink
format_revision_identifier is now a repo method
Browse files Browse the repository at this point in the history
avoid vc callback to use inherit as the interaction way
  • Loading branch information
marvil07 committed Jul 28, 2009
1 parent b83beff commit 02473cc
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 29 deletions.
20 changes: 20 additions & 0 deletions includes/VersioncontrolRepository.php
Expand Up @@ -478,6 +478,26 @@ public function getItem($path, $constraints = array()) {
return $item;
}

/**
* Get the user-visible version of a revision identifier (for an operation or
* an item), as plaintext. By default, this function simply returns $revision.
*
* Version control backends can, however, choose to implement their own version
* of this function, which for example makes it possible to cut the SHA-1 hash
* in distributed version control systems down to a readable length.
*
* @param $revision
* The unformatted revision, as given in $operation['revision']
* or $item['revision'] (or the respective table columns for those values).
* @param $format
* Either 'full' for the original version, or 'short' for a more compact form.
* If the revision identifier doesn't need to be shortened, the results can
* be the same for both versions.
*/
public function formatRevisionIdentifier($revision, $format = 'full') {
return $revision;
}

//ArrayAccess interface implementation
public function offsetExists($offset) {
return isset($this->$offset);
Expand Down
31 changes: 2 additions & 29 deletions versioncontrol.module
Expand Up @@ -1456,33 +1456,6 @@ function _versioncontrol_get_repository_urls($repository) {
}


/**
* Get the user-visible version of a revision identifier (for an operation or
* an item), as plaintext. By default, this function simply returns $revision.
*
* Version control backends can, however, choose to implement their own version
* of this function, which for example makes it possible to cut the SHA-1 hash
* in distributed version control systems down to a readable length.
*
* @param $repository
* The repository array for the repository where the revision is located.
* @param $revision
* The unformatted revision, as given in $operation['revision']
* or $item['revision'] (or the respective table columns for those values).
* @param $format
* Either 'full' for the original version, or 'short' for a more compact form.
* If the revision identifier doesn't need to be shortened, the results can
* be the same for both versions.
*/
function versioncontrol_format_revision_identifier($repository, $revision, $format = 'full') {
if (versioncontrol_backend_implements($repository->vcs, 'format_revision_identifier')) {
return _versioncontrol_call_backend(
$repository->vcs, 'format_revision_identifier', array($repository, $revision, $format)
);
}
return $revision;
}

/**
* Get the user-visible version of a commit identifier a.k.a. 'revision',
* as plaintext. By default, this function returns the operation's revision
Expand All @@ -1503,7 +1476,7 @@ function versioncontrol_format_operation_revision_identifier($operation, $format
if (empty($operation->revision)) {
return '#'. $operation->vc_op_id;
}
return versioncontrol_format_revision_identifier($operation->repository, $operation->revision, $format);
return $operation->repository->formatRevisionIdentifier($operation->revision, $format);
}

/**
Expand All @@ -1524,7 +1497,7 @@ function versioncontrol_format_operation_revision_identifier($operation, $format
* be the same for both versions.
*/
function versioncontrol_format_item_revision_identifier($repository, $item, $format = 'full') {
return versioncontrol_format_revision_identifier($repository, $item['revision']);
return $repository->formatRevisionIdentifier($item['revision']);
}

/**
Expand Down

0 comments on commit 02473cc

Please sign in to comment.