mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-10 15:35:49 +01:00
merge with branch issue-287
This commit is contained in:
@@ -39,6 +39,8 @@ import sonia.scm.xml.XmlMapStringAdapter;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -52,9 +54,14 @@ import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public class BasicPropertiesAware implements PropertiesAware
|
||||
public class BasicPropertiesAware implements PropertiesAware, Serializable
|
||||
{
|
||||
|
||||
/** Field description */
|
||||
private static final long serialVersionUID = -536608122577385802L;
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
|
||||
@@ -88,6 +88,15 @@ public class HgLogChangesetCommand extends AbstractCommand
|
||||
private static final String NULL_ID =
|
||||
"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 ---------------------------------------------------------
|
||||
|
||||
/**
|
||||
@@ -262,7 +271,7 @@ public class HgLogChangesetCommand extends AbstractCommand
|
||||
{
|
||||
Changeset changeset = new Changeset();
|
||||
|
||||
changeset.setId(readId(in));
|
||||
changeset.setId(readId(in, changeset, PROPERTY_REVISION));
|
||||
|
||||
String user = in.textUpTo('\n');
|
||||
|
||||
@@ -279,14 +288,16 @@ public class HgLogChangesetCommand extends AbstractCommand
|
||||
changeset.getBranches().add(branch);
|
||||
}
|
||||
|
||||
String p1 = readId(in);
|
||||
String p1 = readId(in, changeset, PROPERTY_PARENT1_REVISION);
|
||||
|
||||
if (!isNullId(p1))
|
||||
{
|
||||
changeset.getParents().add(p1);
|
||||
}
|
||||
|
||||
String p2 = readId(in);
|
||||
in.mustMatch(' ');
|
||||
|
||||
String p2 = readId(in, changeset, PROPERTY_PARENT2_REVISION);
|
||||
|
||||
if (!isNullId(p2))
|
||||
{
|
||||
@@ -367,38 +378,30 @@ public class HgLogChangesetCommand extends AbstractCommand
|
||||
*
|
||||
*
|
||||
* @param in
|
||||
* @param changeset
|
||||
* @param propertyKey
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @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())
|
||||
{
|
||||
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;
|
||||
return in.nextAsText(40);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -245,3 +245,43 @@ registerConfigPanel({
|
||||
// register type icon
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
});
|
||||
@@ -204,19 +204,27 @@ Sonia.repository.ChangesetViewerGrid = Ext.extend(Ext.grid.GridPanel, {
|
||||
return result;
|
||||
},
|
||||
|
||||
getChangesetId: function(id, record){
|
||||
return id;
|
||||
},
|
||||
|
||||
getParentIds: function(id, record){
|
||||
return record.get('parents');
|
||||
},
|
||||
|
||||
renderIds: function(value, p, record){
|
||||
var parent = null;
|
||||
var parents = this.getParentIds(value, record);
|
||||
var parent1 = null;
|
||||
var parent2 = null;
|
||||
var parents = record.get('parents');
|
||||
if ( parents ){
|
||||
parent = parents[0];
|
||||
if ( parents.length >= 1 ){
|
||||
parent1 = parents[0];
|
||||
if (parents.length > 1){
|
||||
parent2 = parents[1];
|
||||
}
|
||||
}
|
||||
return this.idsTemplate.apply({
|
||||
id: value,
|
||||
parent: parent,
|
||||
id: this.getChangesetId(value, record),
|
||||
parent: parent1,
|
||||
parent2: parent2
|
||||
});
|
||||
},
|
||||
|
||||
@@ -179,3 +179,17 @@ if (!Array.prototype.filter) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
Reference in New Issue
Block a user