changeset 817:25482087e9b5

use only execute to call the cat command
author eugene.petrenko@jetbrains.com
date Fri, 30 May 2014 11:10:19 +0200
parents 3cd7f8d4fc52
children f7ddd9d373d0
files mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/HgRepo.java mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CatCommand.java mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CatCommandTest.java
diffstat 3 files changed, 14 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/HgRepo.java	Fri May 30 10:55:11 2014 +0200
+++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/HgRepo.java	Fri May 30 11:10:19 2014 +0200
@@ -313,16 +313,19 @@
   }
 
   //path->subrepo
-  public Map<String, SubRepo> getSubrepositories(@NotNull ChangeSet cset) {
-    String revId = cset.getId();
+  @NotNull
+  public Map<String, SubRepo> getSubrepositories(@NotNull final ChangeSet cset) {
+    final String revId = cset.getId();
+
     Map<String, SubRepo> subrepos = mySubreposCache.get(revId);
-    if (subrepos != null)
+    if (subrepos != null) {
       return new HashMap<String, SubRepo>(subrepos);
-    CatCommand cc = cat();
-    cc.setRevId(revId);
+    }
+
     File catDir = null;
+    final CatCommand cc = cat().setRevId(revId).files(asList(".hgsub", ".hgsubstate")).checkForFailure(false);
     try {
-      catDir = cc.execute(asList(".hgsub", ".hgsubstate"), false);
+      catDir = cc.call();
       subrepos = HgSubs.readSubrepositories(new File(catDir, ".hgsub"), new File(catDir, ".hgsubstate"));
       mySubreposCache.put(revId, subrepos);
       return new HashMap<String, SubRepo>(subrepos);
--- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CatCommand.java	Fri May 30 10:55:11 2014 +0200
+++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CatCommand.java	Fri May 30 11:10:19 2014 +0200
@@ -76,21 +76,11 @@
 
   @NotNull
   public File call() throws VcsException {
-    return execute(myRelativePaths, myCheckForFailure);
-  }
-
-  @NotNull
-  public File execute(List<String> relPaths) throws VcsException {
-    return execute(relPaths, true);
-  }
-
-  @NotNull
-  public File execute(@NotNull final List<String> relPaths, final boolean checkFailure) throws VcsException {
     File tempDir = null;
     try {
       tempDir = createTmpDir();
-      createDirectories(relPaths, tempDir);
-      catFiles(relPaths, checkFailure, tempDir);
+      createDirectories(myRelativePaths, tempDir);
+      catFiles(myRelativePaths, myCheckForFailure, tempDir);
       return tempDir;
     } catch (VcsException e) {
       deleteDir(tempDir, Loggers.VCS);
--- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CatCommandTest.java	Fri May 30 10:55:11 2014 +0200
+++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CatCommandTest.java	Fri May 30 11:10:19 2014 +0200
@@ -80,11 +80,12 @@
     });
   }
 
+  @NotNull
   private File runCat(@NotNull final List<String> paths) throws IOException, VcsException {
     return runCommand(new CommandExecutor<File>() {
       public File execute(@NotNull HgVcsRoot root, @NotNull HgPathProvider hgPathProvider, @NotNull File workingDir) throws VcsException {
-        CatCommand cat = new CatCommand(new CommandSettings(), hgPathProvider.getHgPath(root), workingDir, root.getAuthSettings());
-        return cat.execute(paths);
+        final CatCommand cat = new CatCommand(new CommandSettings(), hgPathProvider.getHgPath(root), workingDir, root.getAuthSettings());
+        return cat.files(paths).checkForFailure(true).call();
       }
     });
   }