Commits

Sebastian Sdorra  committed 7e8c7eb Merge

merge with branch issue-287

  • Participants
  • Parent commits eb1ae10, 7709de9

Comments (0)

Files changed (5)

File scm-core/src/main/java/sonia/scm/BasicPropertiesAware.java

 
 //~--- JDK imports ------------------------------------------------------------
 
+import java.io.Serializable;
+
 import java.util.HashMap;
 import java.util.Map;
 
  * @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}
    *

File scm-plugins/scm-hg-plugin/src/main/java/sonia/scm/repository/spi/javahg/HgLogChangesetCommand.java

   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 ---------------------------------------------------------
 
   /**
   {
     Changeset changeset = new Changeset();
 
-    changeset.setId(readId(in));
+    changeset.setId(readId(in, changeset, PROPERTY_REVISION));
 
     String user = in.textUpTo('\n');
 
       changeset.getBranches().add(branch);
     }
 
-    String p1 = readId(in);
+    String p1 = readId(in, changeset, PROPERTY_PARENT1_REVISION);
 
     if (!isNullId(p1))
     {
       changeset.getParents().add(p1);
     }
+    
+    in.mustMatch(' ');
 
-    String p2 = readId(in);
+    String p2 = readId(in, changeset, PROPERTY_PARENT2_REVISION);
 
     if (!isNullId(p2))
     {
    *
    *
    * @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;
+    in.upTo(':');
+
+    return in.nextAsText(40);
   }
 
   /**

File scm-plugins/scm-hg-plugin/src/main/resources/sonia/scm/hg.config.js

 // 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;
+  }
+  
+});

File scm-webapp/src/main/webapp/resources/js/repository/sonia.repository.changesetviewergrid.js

     }
     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
     });
   },

File scm-webapp/src/main/webapp/resources/js/util/sonia.util.js

     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;
 }