Skip to content

Commit

Permalink
operation: fix source_items
Browse files Browse the repository at this point in the history
  • Loading branch information
marvil07 committed Jul 6, 2009
1 parent d5a9a00 commit b7c12ad
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 32 deletions.
4 changes: 2 additions & 2 deletions commitlog/commitlog.module
Expand Up @@ -947,7 +947,7 @@ function theme_commitlog_operation_items($operation, $operation_items, $format =
// make a displayable string out of those.
if (!empty($item['source_items'])) {
$oldrev_string = theme('commitlog_item_revision',
$operation->repository, reset($item['source_items']), $format
$operation->repository, reset($item->source_items), $format
);

$olditems = array();
Expand Down Expand Up @@ -1136,7 +1136,7 @@ function theme_commitlog_diff_link($operation, $item) {
// Also, a diff only makes sense if the item was actually modified.
if (in_array($item['action'], array(VERSIONCONTROL_ACTION_MODIFIED, VERSIONCONTROL_ACTION_MERGED))) {
// Ok, everything's alright, let's get that diff link.
$source_item = reset($item['source_items']);
$source_item = reset($item->source_items);
$diff_url = versioncontrol_get_url_diff(
$operation->repository, $item, $source_item
);
Expand Down
30 changes: 15 additions & 15 deletions includes/VersioncontrolOperation.php
Expand Up @@ -601,17 +601,17 @@ public function insert(&$operation_items) {

// If we've got source items (which is the case for commit operations),
// add them to the item revisions and source revisions tables as well.
foreach ($item['source_items'] as $key => $source_item) {
foreach ($item->source_items as $key => $source_item) {
$source_item->ensure();
$item->insertSourceRevision($source_item, $item['action']);
$item->insertSourceRevision($source_item, $item->action);

// Cache other important items in the operations table for 'path' search
// queries, because joining the source revisions table is too expensive.
switch ($item['action']) {
case VERSIONCONTROL_ACTION_MOVED:
case VERSIONCONTROL_ACTION_COPIED:
case VERSIONCONTROL_ACTION_MERGED:
if ($item['path'] != $source_item['path']) {
if ($item->path != $source_item->path) {
$this->_insert_operation_item($source_item,
VERSIONCONTROL_OPERATION_CACHED_AFFECTED_ITEM);
}
Expand All @@ -620,12 +620,12 @@ public function insert(&$operation_items) {
break;
}

$source_item['selected_label'] = new stdClass();
$source_item['selected_label']->get_from = 'other_item';
$source_item['selected_label']->other_item = &$item;
$source_item['selected_label']->other_item_tags = array('successor_item');
$source_item->selected_label = new stdClass();
$source_item->selected_label->get_from = 'other_item';
$source_item->selected_label->other_item = &$item;
$source_item->selected_label->other_item_tags = array('successor_item');

$item['source_items'][$key] = $source_item;
$item->source_items[$key] = $source_item;
}
// Plus a special case for the "added" action, as it needs an entry in the
// source items table but contains no items in the 'source_items' property.
Expand All @@ -635,14 +635,14 @@ public function insert(&$operation_items) {

// If we've got a replaced item (might happen for copy/move commits),
// add it to the item revisions and source revisions table as well.
if (isset($item['replaced_item'])) {
$item['replaced_item']->ensure();
$item->insertSourceRevision($item['replaced_item'],
if (isset($item->replaced_item)) {
$item->replaced_item->ensure();
$item->insertSourceRevision($item->replaced_item,
VERSIONCONTROL_ACTION_REPLACED);
$item['replaced_item']['selected_label'] = new stdClass();
$item['replaced_item']['selected_label']->get_from = 'other_item';
$item['replaced_item']['selected_label']->other_item = &$item;
$item['replaced_item']['selected_label']->other_item_tags = array('successor_item');
$item->replaced_item->selected_label = new stdClass();
$item->replaced_item->selected_label->get_from = 'other_item';
$item->replaced_item->selected_label->other_item = &$item;
$item->replaced_item->selected_label->other_item_tags = array('successor_item');
}
$operation_items[$path] = $item;
}
Expand Down
31 changes: 16 additions & 15 deletions versioncontrol.module
Expand Up @@ -1090,40 +1090,41 @@ function versioncontrol_fetch_source_items($repository, &$items) {

while ($item_revision = db_fetch_object($result)) {
$successor_key = $item_keys[$item_revision->item_revision_id];
if (!isset($items[$successor_key]['source_items'])) {
$items[$successor_key]['source_items'] = array();
if (!isset($items[$successor_key]->source_items)) {
$items[$successor_key]->source_items = array();
}

$item = array(
'path' => $item_revision->path,
'revision' => $item_revision->revision,
'type' => $item_revision->type,
'item_revision_id' => $item_revision->source_item_revision_id,
$item = new VersioncontrolItem(
$item_revision->type,
$item_revision->path,
$item_revision->revision,
null,
null
);
$item['selected_label'] = new stdClass();
$item['selected_label']->get_from = 'other_item';
$item['selected_label']->other_item = &$items[$successor_key];
$item['selected_label']->other_item_tags = array('successor_item');
$item->selected_label = new stdClass();
$item->selected_label->get_from = 'other_item';
$item->selected_label->other_item = &$items[$successor_key];
$item->selected_label->other_item_tags = array('successor_item');

// Insert the item and its associated action into the successor item.
if ($item_revision->action == VERSIONCONTROL_ACTION_REPLACED) {
$items[$successor_key]['replaced_item'] = $item;
$items[$successor_key]->replaced_item = $item;
}
else if ($item_revision->action == VERSIONCONTROL_ACTION_ADDED) {
$items[$successor_key]['action'] = $item_revision->action;
// Added items only join to an empty (NULL) item, ignore that one
// instead of adding it to the source items.
}
else {
$items[$successor_key]['action'] = $item_revision->action;
$items[$successor_key]['source_items'][$item['path']] = $item;
$items[$successor_key]->action = $item_revision->action;
$items[$successor_key]->source_items[$item->path] = $item;
}

// Add the lines-changed information if it has been recorded.
// Only a single source item entry should hold this information,
// so no emphasis is placed on merging it across multiple source items.
if ($item_revision->line_changes_recorded) {
$items[$successor_key]['line_changes'] = array(
$items[$successor_key]->line_changes = array(
'added' => $item_revision->line_changes_added,
'removed' => $item_revision->line_changes_removed,
);
Expand Down

0 comments on commit b7c12ad

Please sign in to comment.