Add support for the display of monotone node attributes.

(also fix the way the attributes view is displayed, i.e. do not
 use single strings, but one string in context which is much easier
 to translate)
This commit is contained in:
Thomas Keller 2011-05-31 13:11:55 +02:00
parent d079838818
commit ca2ef814fb
7 changed files with 94 additions and 18 deletions

View File

@ -4,6 +4,8 @@
- Mercurial source views now show parent revisions (if any) and detailed change information
- File download URLs now contain the file name rather than the upload id; old links still work though (issue 686)
- Display monotone file and directory attributes in the tree and file view
(needs a monotone with an interface version of 13.1 or newer)
## Bugfixes

View File

@ -31,10 +31,10 @@ class IDF_Scm_Monotone extends IDF_Scm
/** the minimum supported interface version */
public static $MIN_INTERFACE_VERSION = 13.0;
private $stdio;
private static $instances = array();
private $stdio;
/**
* Constructor
*/
@ -698,6 +698,29 @@ class IDF_Scm_Monotone extends IDF_Scm
return (object) $res;
}
/**
* @see IDF_Scm::getProperties()
*/
public function getProperties($rev, $path='')
{
$out = $this->stdio->exec(array('interface_version'));
// support for querying file attributes of committed revisions
// was added for mtn 1.1 (interface version 13.1)
if (floatval($out) < 13.1)
return array();
$out = $this->stdio->exec(array('get_attributes', $path), array('r' => $rev));
$stanzas = IDF_Scm_Monotone_BasicIO::parse($out);
$res = array();
foreach ($stanzas as $stanza) {
$line = $stanza[0];
$res[$line['values'][0]] = $line['values'][1];
}
return $res;
}
/**
* @see IDF_Scm::getExtraProperties
*/

View File

@ -5,12 +5,25 @@
<h2 class="top"><a href="{url 'IDF_Views_Source::treeBase', array($project.shortname, $commit)}">{trans 'Root'}</a><span class="sep">/</span>{if $breadcrumb}{$breadcrumb|safe}{/if}</h2>
<table class="code" summary=" ">
{if !$tree_in and !$tags_in}
{if (!$tree_in and !$tags_in) or $props}
{aurl 'url', 'IDF_Views_Source::commit', array($project.shortname, $commit)}
<tfoot>
<tr><th colspan="2">{blocktrans}Source at commit <a class="mono" href="{$url}">{$commit}</a> created {$cobject.date|dateago}.{/blocktrans}<br/>
<span class="smaller">{blocktrans}By {$cobject.author|strip_tags|trim}, {$cobject.title}{/blocktrans}</span>
</th></tr>
{if $props}
<tr><th colspan="2">
<ul>
{foreach $props as $prop => $val}
<li>{blocktrans}Property <strong>{$prop}</strong> set to <em>{$val}</em>{/blocktrans}</li>
{/foreach}
</ul>
</th></tr>
{/if}
{if !$tree_in and !$tags_in}
<tr>
<th colspan="2">{blocktrans}Source at commit <a class="mono" href="{$url}">{$commit}</a> created {$cobject.date|dateago}.{/blocktrans}<br/>
<span class="smaller">{blocktrans}By {$cobject.author|strip_tags|trim}, {$cobject.title}{/blocktrans}</span>
</th>
</tr>
{/if}
</tfoot>
{/if}
<tbody>

View File

@ -11,14 +11,27 @@
<th>{trans 'Message'}</th>
<th>{trans 'Size'}</th>
</tr>
</thead>{if !$tree_in and !$tags_in}
</thead>
{if (!$tree_in and !$tags_in) or $props}
{aurl 'url', 'IDF_Views_Source::commit', array($project.shortname, $commit)}
<tfoot>
<tr><th colspan="5">{blocktrans}Source at commit <a class="mono" href="{$url}">{$commit}</a> created {$cobject.date|dateago}.{/blocktrans}<br/>
<span class="smaller">{blocktrans}By {$cobject.author|strip_tags|trim}, {$cobject.title}{/blocktrans}</span>
</th></tr>
{if $props}
<tr><th colspan="5">
<ul>
{foreach $props as $prop => $val}
<li>{blocktrans}Property <strong>{$prop}</strong> set to <em>{$val}</em>{/blocktrans}</li>
{/foreach}
</ul>
</th></tr>
{/if}
{if !$tree_in and !$tags_in}
<tr><th colspan="5">{blocktrans}Source at commit <a class="mono" href="{$url}">{$commit}</a> created {$cobject.date|dateago}.{/blocktrans}<br/>
<span class="smaller">{blocktrans}By {$cobject.author|strip_tags|trim}, {$cobject.title}{/blocktrans}</span>
</th></tr>
{/if}
{/if}
</tfoot>
{/if}<tbody>
<tbody>
{if $base}
<tr>
<td>&nbsp;</td>

View File

@ -12,7 +12,7 @@
<tr><th colspan="2">
<ul>
{foreach $props as $prop => $val}
<li>{trans 'Property'} <strong>{$prop}</strong> {trans 'set to:'} <em>{$val}</em></li>
<li>{blocktrans}Property <strong>{$prop}</strong> set to <em>{$val}</em>{/blocktrans}</li>
{/foreach}
</ul>
</th></tr>

View File

@ -19,7 +19,7 @@
<tr><th colspan="6">
<ul>
{foreach $props as $prop => $val}
<li>{trans 'Property'} <strong>{$prop}</strong> {trans 'set to:'} <em>{$val}</em></li>
<li>{blocktrans}Property <strong>{$prop}</strong> set to <em>{$val}</em>{/blocktrans}</li>
{/foreach}
</ul>
</th></tr>

View File

@ -714,6 +714,31 @@ END;
$this->assertEquals('', $commit->diff);
}
public function testGetProperties()
{
$rev = "2345678901234567890123456789012345678901";
$instance = $this->createMock();
$instance->getStdio()->setExpectedOutput(array('interface_version'), array(), '13.1');
$stdio =<<<END
attr "foo" "bar"
state "unchanged"
attr "some new
line" "and more <weird>-
nesses"
END;
$instance->getStdio()->setExpectedOutput(array('get_attributes', 'foo'), array('r' => $rev), $stdio);
$res = $instance->getProperties($rev, 'foo');
$this->assertEquals(2, count($res));
$this->assertEquals(array(
'foo' => 'bar',
"some new\nline" => "and more <weird>-\nnesses"
), $res);
}
public function testGetExtraProperties()
{
$instance = $this->createMock();