merge with branch issue-287

This commit is contained in:
Sebastian Sdorra
2012-12-07 10:00:13 +01:00
5 changed files with 100 additions and 28 deletions

View File

@@ -39,6 +39,8 @@ import sonia.scm.xml.XmlMapStringAdapter;
//~--- JDK imports ------------------------------------------------------------ //~--- JDK imports ------------------------------------------------------------
import java.io.Serializable;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@@ -52,9 +54,14 @@ import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
* @author Sebastian Sdorra * @author Sebastian Sdorra
*/ */
@XmlAccessorType(XmlAccessType.FIELD) @XmlAccessorType(XmlAccessType.FIELD)
public class BasicPropertiesAware implements PropertiesAware public class BasicPropertiesAware implements PropertiesAware, Serializable
{ {
/** Field description */
private static final long serialVersionUID = -536608122577385802L;
//~--- methods --------------------------------------------------------------
/** /**
* {@inheritDoc} * {@inheritDoc}
* *

View File

@@ -88,6 +88,15 @@ public class HgLogChangesetCommand extends AbstractCommand
private static final String NULL_ID = private static final String NULL_ID =
"0000000000000000000000000000000000000000"; "0000000000000000000000000000000000000000";
/** changeset property for parent1 revision */
private static final String PROPERTY_PARENT1_REVISION = "hg.p1.rev";
/** changeset property for parent2 revision */
private static final String PROPERTY_PARENT2_REVISION = "hg.p2.rev";
/** changeset property for node revision */
private static final String PROPERTY_REVISION = "hg.rev";
//~--- constructors --------------------------------------------------------- //~--- constructors ---------------------------------------------------------
/** /**
@@ -262,7 +271,7 @@ public class HgLogChangesetCommand extends AbstractCommand
{ {
Changeset changeset = new Changeset(); Changeset changeset = new Changeset();
changeset.setId(readId(in)); changeset.setId(readId(in, changeset, PROPERTY_REVISION));
String user = in.textUpTo('\n'); String user = in.textUpTo('\n');
@@ -279,14 +288,16 @@ public class HgLogChangesetCommand extends AbstractCommand
changeset.getBranches().add(branch); changeset.getBranches().add(branch);
} }
String p1 = readId(in); String p1 = readId(in, changeset, PROPERTY_PARENT1_REVISION);
if (!isNullId(p1)) if (!isNullId(p1))
{ {
changeset.getParents().add(p1); changeset.getParents().add(p1);
} }
in.mustMatch(' ');
String p2 = readId(in); String p2 = readId(in, changeset, PROPERTY_PARENT2_REVISION);
if (!isNullId(p2)) if (!isNullId(p2))
{ {
@@ -367,38 +378,30 @@ public class HgLogChangesetCommand extends AbstractCommand
* *
* *
* @param in * @param in
* @param changeset
* @param propertyKey
* *
* @return * @return
* *
* @throws IOException * @throws IOException
*/ */
private String readId(HgInputStream in) throws IOException private String readId(HgInputStream in, Changeset changeset,
String propertyKey)
throws IOException
{ {
String nodeString = null;
if (config.isShowRevisionInId()) if (config.isShowRevisionInId())
{ {
Integer rev = in.readDecimal(); Integer rev = in.readDecimal();
if (rev != null) if (rev != null && rev >= 0)
{ {
nodeString = String.valueOf(rev); changeset.setProperty(propertyKey, String.valueOf(rev));
} }
else
{
nodeString = "-1";
}
in.upTo(':');
nodeString = nodeString.concat(":").concat(in.nextAsText(40));
}
else
{
in.upTo(':');
nodeString = in.nextAsText(40);
} }
return nodeString; in.upTo(':');
return in.nextAsText(40);
} }
/** /**

View File

@@ -245,3 +245,43 @@ registerConfigPanel({
// register type icon // register type icon
Sonia.repository.typeIcons['hg'] = 'resources/images/icons/16x16/mercurial.png'; Sonia.repository.typeIcons['hg'] = 'resources/images/icons/16x16/mercurial.png';
// override ChangesetViewerGrid to render changeset id's with revisions
Ext.override(Sonia.repository.ChangesetViewerGrid, {
isMercurialRepository: function(){
return this.repository.type == 'hg';
},
getChangesetId: function(id, record){
if ( this.isMercurialRepository() ){
var rev = Sonia.util.getProperty(record.get('properties'), 'hg.rev');
if ( rev ){
id = rev + ':' + id;
}
}
return id;
},
getParentIds: function(id, record){
var parents = record.get('parents');
if ( this.isMercurialRepository() ){
if ( parents && parents.length > 0 ){
var properties = record.get('properties');
var rev = Sonia.util.getProperty(properties, 'hg.p1.rev');
if (rev){
parents[0] = rev + ':' + parents[0];
}
if ( parents.length > 1 ){
rev = Sonia.util.getProperty(properties, 'hg.p2.rev');
if (rev){
parents[1] = rev + ':' + parents[1];
}
}
}
}
return parents;
}
});

View File

@@ -203,20 +203,28 @@ Sonia.repository.ChangesetViewerGrid = Ext.extend(Ext.grid.GridPanel, {
} }
return result; return result;
}, },
getChangesetId: function(id, record){
return id;
},
getParentIds: function(id, record){
return record.get('parents');
},
renderIds: function(value, p, record){ renderIds: function(value, p, record){
var parent = null; var parents = this.getParentIds(value, record);
var parent1 = null;
var parent2 = null; var parent2 = null;
var parents = record.get('parents');
if ( parents ){ if ( parents ){
parent = parents[0]; parent1 = parents[0];
if ( parents.length >= 1 ){ if (parents.length > 1){
parent2 = parents[1]; parent2 = parents[1];
} }
} }
return this.idsTemplate.apply({ return this.idsTemplate.apply({
id: value, id: this.getChangesetId(value, record),
parent: parent, parent: parent1,
parent2: parent2 parent2: parent2
}); });
}, },

View File

@@ -178,4 +178,18 @@ if (!Array.prototype.filter) {
return results; return results;
} }
}
Sonia.util.getProperty = function(properties, key){
var value = null;
if ( properties != null ){
for (var i=0; i<properties.length; i++){
var property = properties[i];
if ( property.key == key ){
value = property.value;
break;
}
}
}
return value;
} }