Commits

Sebastian Sdorra  committed f60516c

fix mercurial sub repository detection in source browser

  • Participants
  • Parent commits a5dc1c7

Comments (0)

Files changed (1)

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

 import com.aragost.javahg.internals.AbstractCommand;
 import com.aragost.javahg.internals.HgInputStream;
 
+import com.google.common.base.Strings;
 import com.google.common.collect.Lists;
 
 import sonia.scm.repository.FileObject;
+import sonia.scm.repository.SubRepository;
 
 //~--- JDK imports ------------------------------------------------------------
 
       {
         file = readFile(stream);
       }
-      else if (type == 's') {}
+      else if (type == 's')
+      {
+        file = readSubRepository(stream);
+      }
 
       if (file != null)
       {
    * Method description
    *
    *
+   * @param stream
+   *
+   * @return
+   *
+   * @throws IOException
+   */
+  private FileObject readSubRepository(HgInputStream stream) throws IOException
+  {
+    FileObject directory = new FileObject();
+    String path = removeTrailingSlash(stream.textUpTo('\n'));
+
+    directory.setName(getNameFromPath(path));
+    directory.setDirectory(true);
+    directory.setPath(path);
+
+    String revision = stream.textUpTo(' ');
+    String url = stream.textUpTo('\0');
+
+    SubRepository subRepository = new SubRepository(url);
+
+    if (!Strings.isNullOrEmpty(revision))
+    {
+      subRepository.setRevision(revision);
+    }
+
+    directory.setSubRepository(subRepository);
+
+    return directory;
+  }
+
+  /**
+   * Method description
+   *
+   *
    * @param path
    *
    * @return