Commits

Sebastian Sdorra committed 1fd589e

store mercurial specific revisions as changeset properties

Comments (0)

Files changed (1)

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.parent1.revision";
+
+  /** changeset property for parent2 revision */
+  private static final String PROPERTY_PARENT2_REVISION = "hg.parent2.revision";
+
+  /** changeset property for node revision */
+  private static final String PROPERTY_REVISION = "hg.revision";
+
   //~--- 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);
     }
 
-    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)
       {
-        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);
   }
 
   /**