* Monotone.php: get inTags() and inBranches() correct - they need to

return a list with selectors as keys, otherwise the main menu won't
  link the active revision, but instead use the main branch
* changelog.html, tree.html: shorten the branch / tag output a bit
  (still ugly to have a fixed output like this, though), link tags
  by their selector, no longer by their revision ID. We loose some
  flexibility here, since tags could actually mark different
  revisions, which are now ignored
This commit is contained in:
Thomas Keller 2010-06-29 09:59:49 +02:00
parent e46a6fa171
commit d2f0bac907
3 changed files with 24 additions and 16 deletions

View File

@ -628,13 +628,14 @@ class IDF_Scm_Monotone extends IDF_Scm
/** /**
* Returns unique certificate values for the given revs and the specific * Returns unique certificate values for the given revs and the specific
* cert name * cert name, optionally prefixed with $prefix
* *
* @param array * @param array
* @param string * @param string
* @param string
* @return array * @return array
*/ */
private function _getUniqueCertValuesFor($revs, $certName) private function _getUniqueCertValuesFor($revs, $certName, $prefix)
{ {
$certValues = array(); $certValues = array();
foreach ($revs as $rev) foreach ($revs as $rev)
@ -642,8 +643,10 @@ class IDF_Scm_Monotone extends IDF_Scm
$certs = $this->_getCerts($rev); $certs = $this->_getCerts($rev);
if (!array_key_exists($certName, $certs)) if (!array_key_exists($certName, $certs))
continue; continue;
foreach ($certs[$certName] as $certValue)
$certValues = array_merge($certValues, $certs[$certName]); {
$certValues[] = "$prefix$certValue";
}
} }
return array_unique($certValues); return array_unique($certValues);
} }
@ -686,7 +689,7 @@ class IDF_Scm_Monotone extends IDF_Scm
{ {
$revs = $this->_resolveSelector($commit); $revs = $this->_resolveSelector($commit);
if (count($revs) == 0) return array(); if (count($revs) == 0) return array();
return $this->_getUniqueCertValuesFor($revs, "branch"); return $this->_getUniqueCertValuesFor($revs, "branch", "h:");
} }
/** /**
@ -716,7 +719,12 @@ class IDF_Scm_Monotone extends IDF_Scm
} }
if ($stanzaline['key'] == "revision") if ($stanzaline['key'] == "revision")
{ {
$tags[$stanzaline['hash']] = $tagname; // FIXME: warn if multiple revisions have
// equally named tags
if (!array_key_exists("t:$tagname", $tags))
{
$tags["t:$tagname"] = $tagname;
}
break; break;
} }
} }
@ -733,7 +741,7 @@ class IDF_Scm_Monotone extends IDF_Scm
{ {
$revs = $this->_resolveSelector($commit); $revs = $this->_resolveSelector($commit);
if (count($revs) == 0) return array(); if (count($revs) == 0) return array();
return $this->_getUniqueCertValuesFor($revs, "tag"); return $this->_getUniqueCertValuesFor($revs, "tag", "t:");
} }
/** /**

View File

@ -3,9 +3,9 @@
<p><strong>{trans 'Branches:'}</strong><br/> <p><strong>{trans 'Branches:'}</strong><br/>
{foreach $branches as $selector => $branch} {foreach $branches as $selector => $branch}
{aurl 'url', 'IDF_Views_Source::changeLog', array($project.shortname, $selector)} {aurl 'url', 'IDF_Views_Source::changeLog', array($project.shortname, $selector)}
<span class="label{if in_array($branch, $tree_in)} active{/if}"> <span class="label{if in_array($selector, $tree_in)} active{/if}">
<a href="{$url}" class="label" title="{$branch}"> <a href="{$url}" class="label" title="{$branch}">
{$branch|shorten:25} {$branch|shorten:24}
</a> </a>
</span><br/> </span><br/>
{/foreach} {/foreach}
@ -14,9 +14,9 @@
<p><strong>{trans 'Tags:'}</strong><br/> <p><strong>{trans 'Tags:'}</strong><br/>
{foreach $tags as $selector => $tag} {foreach $tags as $selector => $tag}
{aurl 'url', 'IDF_Views_Source::changeLog', array($project.shortname, $selector)} {aurl 'url', 'IDF_Views_Source::changeLog', array($project.shortname, $selector)}
<span class="label{if in_array($tag, $tags_in)} active{/if}"> <span class="label{if in_array($selector, $tags_in)} active{/if}">
<a href="{$url}" class="label" title="{$tag}"> <a href="{$url}" class="label" title="{$tag}">
{$tag|shorten:25} {$tag|shorten:24}
</a> </a>
</span><br/> </span><br/>
{/foreach} {/foreach}

View File

@ -35,7 +35,7 @@
<td{if $file.type == 'tree'} colspan="4"{/if}><a href="{$url}">{$file.file}</a></td>{else}<td><a href="#" title="{$file.hash}">{$file.file}</a></td>{/if} <td{if $file.type == 'tree'} colspan="4"{/if}><a href="{$url}">{$file.file}</a></td>{else}<td><a href="#" title="{$file.hash}">{$file.file}</a></td>{/if}
{if $file.type == 'blob'} {if $file.type == 'blob'}
{if isset($file.date) and $file.log != '----'} {if isset($file.date) and $file.log != '----'}
<td><span class="smaller">{$file.date|dateago:"wihtout"}</span></td> <td><span class="smaller">{$file.date|dateago:"without"}</span></td>
<td><span class="smaller">{$file.author|strip_tags|trim}{trans ':'} {issuetext $file.log, $request, true, false}</span></td> <td><span class="smaller">{$file.author|strip_tags|trim}{trans ':'} {issuetext $file.log, $request, true, false}</span></td>
{else}<td colspan="2"></td>{/if} {else}<td colspan="2"></td>{/if}
<td>{$file.size|size}</td>{/if} <td>{$file.size|size}</td>{/if}
@ -58,9 +58,9 @@
<p><strong>{trans 'Branches:'}</strong><br/> <p><strong>{trans 'Branches:'}</strong><br/>
{foreach $branches as $selector => $branch} {foreach $branches as $selector => $branch}
{aurl 'url', 'IDF_Views_Source::treeBase', array($project.shortname, $selector)} {aurl 'url', 'IDF_Views_Source::treeBase', array($project.shortname, $selector)}
<span class="label{if in_array($branch, $tree_in)} active{/if}"> <span class="label{if in_array($selector, $tree_in)} active{/if}">
<a href="{$url}" class="label" title="{$branch}"> <a href="{$url}" class="label" title="{$branch}">
{$branch|shorten:25} {$branch|shorten:24}
</a> </a>
</span><br/> </span><br/>
{/foreach} {/foreach}
@ -69,9 +69,9 @@
<p><strong>{trans 'Tags:'}</strong><br/> <p><strong>{trans 'Tags:'}</strong><br/>
{foreach $tags as $selector => $tag} {foreach $tags as $selector => $tag}
{aurl 'url', 'IDF_Views_Source::treeBase', array($project.shortname, $selector)} {aurl 'url', 'IDF_Views_Source::treeBase', array($project.shortname, $selector)}
<span class="label{if in_array($tag, $tags_in)} active{/if}"> <span class="label{if in_array($selector, $tags_in)} active{/if}">
<a href="{$url}" class="label" title="{$tag}"> <a href="{$url}" class="label" title="{$tag}">
{$tag|shorten:25} {$tag|shorten:24}
</a> </a>
</span><br/> </span><br/>
{/foreach} {/foreach}