Commits

Sebastian Sdorra  committed add95a3

fix wrong mercurial changeset ids during hooks

  • Participants
  • Parent commits a742b42

Comments (0)

Files changed (2)

File scm-plugins/scm-hg-plugin/src/main/java/sonia/scm/repository/AbstractHgHandler.java

 {
 
   /** Field description */
+  protected static final String ENV_ID_REVISION = "SCM_ID_REVISION";
+
+  /** Field description */
   protected static final String ENV_NODE = "HG_NODE";
 
   /** Field description */
    * @param repositoryDirectory
    */
   protected AbstractHgHandler(HgRepositoryHandler handler, HgContext context,
-                              Repository repository)
+    Repository repository)
   {
     this(handler, context, repository, handler.getDirectory(repository));
   }
    * @param repositoryDirectory
    */
   protected AbstractHgHandler(HgRepositoryHandler handler, HgContext context,
-                              Repository repository, File repositoryDirectory)
+    Repository repository, File repositoryDirectory)
   {
     this.handler = handler;
     this.context = context;
    * @throws IOException
    */
   protected Process createHgProcess(Map<String, String> extraEnv,
-                                    String... args)
-          throws IOException
+    String... args)
+    throws IOException
   {
     return createProcess(extraEnv, handler.getConfig().getHgBinary(), args);
   }
    * @throws IOException
    */
   protected Process createScriptProcess(HgPythonScript script,
-          Map<String, String> extraEnv)
-          throws IOException
+    Map<String, String> extraEnv)
+    throws IOException
   {
-    return createProcess(
-        extraEnv, handler.getConfig().getPythonBinary(),
-        script.getFile(SCMContext.getContext()).getAbsolutePath());
+    return createProcess(extraEnv, handler.getConfig().getPythonBinary(),
+      script.getFile(SCMContext.getContext()).getAbsolutePath());
   }
 
   /**
    * @throws RepositoryException
    */
   protected <T> T getResultFromScript(Class<T> resultType,
-          HgPythonScript script)
-          throws IOException, RepositoryException
+    HgPythonScript script)
+    throws IOException, RepositoryException
   {
     return getResultFromScript(resultType, script,
-                               new HashMap<String, String>());
+      new HashMap<String, String>());
   }
 
   /**
    * @throws RepositoryException
    */
   protected <T> T getResultFromScript(Class<T> resultType,
-          HgPythonScript script, Map<String, String> extraEnv)
-          throws IOException, RepositoryException
+    HgPythonScript script, Map<String, String> extraEnv)
+    throws IOException, RepositoryException
   {
     Process p = createScriptProcess(script, extraEnv);
     T result = null;
    * @throws IOException
    */
   private Process createProcess(Map<String, String> extraEnv, String cmd,
-                                String... args)
-          throws IOException
+    String... args)
+    throws IOException
   {
     HgConfig config = handler.getConfig();
     List<String> cmdList = new ArrayList<String>();
     env.put(ENV_PYTHONIOENCODING, ENCODING);
     env.put(ENV_HGENCODING, ENCODING);
 
+    //J-
+    env.put(ENV_ID_REVISION, 
+      String.valueOf(handler.getConfig().isShowRevisionInId())
+    );
+    //J+
+
     if (context.isSystemEnvironment())
     {
       env.putAll(System.getenv());
       if (logger.isDebugEnabled())
       {
         logger.debug("enable hg pending for {}",
-                     repositoryDirectory.getAbsolutePath());
+          repositoryDirectory.getAbsolutePath());
       }
 
       env.put(ENV_PENDING, repositoryDirectory.getAbsolutePath());
       StringBuilder msg = new StringBuilder("start process in directory '");
 
       msg.append(repositoryDirectory.getAbsolutePath()).append(
-          "' with env: \n");
+        "' with env: \n");
 
       for (Map.Entry<String, String> e : env.entrySet())
       {

File scm-plugins/scm-hg-plugin/src/main/resources/sonia/scm/python/util.py

     appendListNodes(doc, wrapperNode, name, values)
     
 def getId(ctx):
-  return str(ctx.rev()) + ':' + hex(ctx.node()[:6])
+  id = ''
+  if os.environ['SCM_ID_REVISION'] == 'true':
+    id = str(ctx.rev()) + ':'
+  return id + hex(ctx.node())
   
 def appendAuthorNodes(doc, parentNode, ctx):
   authorName = ctx.user()