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)
feature.content-md5
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,12 +4,14 @@
- 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
## Bugfixes
- monotone zip archive entries now all carry the revision date as mtime (issue 645)
- Timeline only displays filter options for items a user has actually access to (issue 655)
- The log, tags and branches parsers for Mercurial are more robust now (issue 663)
- The log, tags and branches parsers for Mercurial are more robust now (issue 663)
- Fix SSH public key parsing issues and improve the check for existing, uploaded keys (issue 679)
- Let the SVN command line client not store the login credentials we give him as arguments

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

@ -6,13 +6,13 @@
<table class="code" summary=" ">
{if !$tree_in || $props}
{aurl 'url', 'IDF_Views_Source::commit', array($project.shortname, $commit)}
{aurl 'url', 'IDF_Views_Source::commit', array($project.shortname, $commit)}
<tfoot>
{if $props}
<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

@ -13,13 +13,13 @@
<th>{trans 'Size'}</th>
</tr>
</thead>{if (!$tree_in and !$tags_in and $commit != 'HEAD') || $props}
{aurl 'url', 'IDF_Views_Source::commit', array($project.shortname, $commit)}
{aurl 'url', 'IDF_Views_Source::commit', array($project.shortname, $commit)}
<tfoot>
{if $props}
<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>
@ -45,7 +45,7 @@
<td class="fileicon"><img src="{media '/idf/img/'~$file.type~'.png'}" alt="{$file.type}" /></td>
<td><a href="{$url}">{$file.file}</a></td>
<td><span class="smaller">{$file.date|dateago:"without"}</span></td>
<td><span class="smaller">{$file.date|dateago:"without"}</span></td>
<td>{$file.rev}</td>
<td{if $file.type != 'blob'} colspan="2"{/if}><span class="smaller">{$file.author|strip_tags|trim}{trans ':'} {issuetext $file.log, $request, true, false}</span></td>
{if $file.type == 'blob'}

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();