Mercurial > hg > icedrobot > ika
changeset 27:17afcf8034a6
Deja assimilate vu
Ika can now assimilate already assimilated dest dirs.
* ika/plugins/borg/IcedRobotCloner.java: Updated to handle re-runs.
* ika/runtime/scm/GITRepository.java: Likewise.
* ika/runtime/scm/HGRepository.java: Likewise.
* ika/runtime/scm/Repository.java: Likewise.
author | Xerxes R?nby <xerxes@zafena.se> |
---|---|
date | Mon, 11 Apr 2011 01:50:51 +0200 |
parents | 56444e17df1a |
children | 65812348191d |
files | src/main/java/org/icedrobot/ika/plugins/borg/IcedRobotCloner.java src/main/java/org/icedrobot/ika/runtime/scm/GITRepository.java src/main/java/org/icedrobot/ika/runtime/scm/HGRepository.java src/main/java/org/icedrobot/ika/runtime/scm/Repository.java |
diffstat | 4 files changed, 99 insertions(+), 46 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/org/icedrobot/ika/plugins/borg/IcedRobotCloner.java Sat Apr 09 22:38:20 2011 +0200 +++ b/src/main/java/org/icedrobot/ika/plugins/borg/IcedRobotCloner.java Mon Apr 11 01:50:51 2011 +0200 @@ -101,11 +101,10 @@ File repositoryLocation = new File(destinationDir); if (repositoryLocation.exists()) { - throw new IkaPluginException("destination directory " + + System.out.println("destination directory " + repositoryLocation + " already existing"); - } - if (!repositoryLocation.mkdir()) { + } else if (!repositoryLocation.mkdir()) { throw new IkaPluginException("cannot create directory " + repositoryLocation); }
--- a/src/main/java/org/icedrobot/ika/runtime/scm/GITRepository.java Sat Apr 09 22:38:20 2011 +0200 +++ b/src/main/java/org/icedrobot/ika/runtime/scm/GITRepository.java Mon Apr 11 01:50:51 2011 +0200 @@ -23,9 +23,6 @@ import org.icedrobot.ika.plugins.IkaPluginException; import org.icedrobot.ika.runtime.IkaRuntime; -/** - * @author Mario Torre <neugens.limasoftware@gmail.com> - */ public class GITRepository extends Repository { /** @@ -56,42 +53,81 @@ } /** - * + * Clone the git Repository. + * If the git Repository allready exist then pop local patches and + * then fetch and merge new changesets from the remotePath. */ @Override public void makeClone() { - String command = "git clone --progress -b " + getBranch() + " " + remotePath; - System.err.println(command); - IkaRuntime.exec(getFullPath(), "git", "clone", "--progress", "-b", getBranch(), remotePath); + File git = new File(fullPath + File.separator + name + + File.separator + ".git" ); + if(!git.exists()) { + String command = "git clone --progress -b " + + getBranch() + " " + remotePath; + System.err.println(command); + IkaRuntime.exec(getFullPath(), "git", "clone", "--progress", "-b", + getBranch(), remotePath); + } else { + File patchQueue = new File(fullPath + File.separator + name + + File.separator + ".git" + + File.separator + "patches" ); + if(patchQueue.exists()) { + String command = "guilt pop --all"; + System.err.println(command); + IkaRuntime.exec(new File(getFullPath() + File.separator + name), + "guilt", "pop", "--all"); + } + + String command = "git fetch --progress " + remotePath; + System.err.println(command); + IkaRuntime.exec(new File(getFullPath() + File.separator + name), + "git", "fetch", "--progress", remotePath); + + command = "git merge HEAD"; + System.err.println(command); + IkaRuntime.exec(new File(getFullPath() + File.separator + name), + "git", "merge", "HEAD"); + } } /** - * + * Create new git and initialize it to the prefered branch. + * Skipped if the git branch already exist. */ @Override public void create() { - String command = "git init ."; - System.err.println(command); - IkaRuntime.exec(getFullPath(), "git", "init"); + File repoBranch = new File(fullPath + File.separator + ".git" + + File.separator + "refs" + + File.separator + "heads" + + File.separator + getBranch()); + if(!repoBranch.exists()) { - command = "git add --all"; - System.err.println(command); - IkaRuntime.exec(getFullPath(), "git", "add", "--all"); + String command = "git init ."; + System.err.println(command); + IkaRuntime.exec(getFullPath(), "git", "init"); + + command = "git add --all"; + System.err.println(command); + IkaRuntime.exec(getFullPath(), "git", "add", "--all"); - command = "git commit -m initial_repository --verbose"; - System.err.println(command); - IkaRuntime.exec(getFullPath(), "git", "commit", "-m", "initial_repository", "--verbose"); + command = "git commit -m initial_repository --verbose"; + System.err.println(command); + IkaRuntime.exec(getFullPath(), "git", "commit", "-m", + "initial_repository", "--verbose"); + + command = "git branch " + getBranch(); + System.err.println(command); + IkaRuntime.exec(getFullPath(), "git", "branch", getBranch()); - command = "git branch " + branch; - System.err.println(command); - IkaRuntime.exec(getFullPath(), "git", "branch", branch); + command = "git checkout " + getBranch(); + System.err.println(command); + IkaRuntime.exec(getFullPath(), "git", "checkout", getBranch()); - command = "git checkout " + branch; - System.err.println(command); - IkaRuntime.exec(getFullPath(), "git", "checkout", branch); - - System.err.println(">>>>>>>> done: " + this + " <<<<<<<<"); + System.err.println(">>>>>>>> done: " + this + " <<<<<<<<"); + } else { + System.err.println(">>>>>>>> already done: " + this + " <<<<<<<<"); + } } /**
--- a/src/main/java/org/icedrobot/ika/runtime/scm/HGRepository.java Sat Apr 09 22:38:20 2011 +0200 +++ b/src/main/java/org/icedrobot/ika/runtime/scm/HGRepository.java Mon Apr 11 01:50:51 2011 +0200 @@ -21,9 +21,6 @@ import java.io.File; import org.icedrobot.ika.runtime.IkaRuntime; -/** - * @author Mario Torre <neugens.limasoftware@gmail.com> - */ public class HGRepository extends Repository { /** @@ -47,13 +44,27 @@ } /** - * + * Clone hg Repository. + * If the hg Repository allready exist then quickly pull in + * new changesets and update. */ @Override public void makeClone() { - String command = "hg clone " + remotePath + " " + getFullPath(); - System.err.println(command); - IkaRuntime.exec(getFullPath(), "hg", "clone", remotePath, getFullPath().toString()); + File hg = new File(this.fullPath + File.separator + ".hg"); + if(!hg.exists()){ + String command = "hg clone " + remotePath + " " + getFullPath(); + System.err.println(command); + IkaRuntime.exec(getFullPath(), "hg", "clone", + remotePath, getFullPath().toString()); + } else { + String command = "hg pull " + remotePath; + System.err.println(command); + IkaRuntime.exec(getFullPath(), "hg", "pull", remotePath); + + command = "hg update"; + System.err.println(command); + IkaRuntime.exec(getFullPath(), "hg", "update"); + } } @Override @@ -79,18 +90,23 @@ @Override public void create() { - - String command = "hg init ."; - System.err.println(command); - IkaRuntime.exec(getFullPath(), "hg", "init"); + File hg = new File(this.fullPath + File.separator + ".hg"); + if(!hg.exists()){ + String command = "hg init ."; + System.err.println(command); + IkaRuntime.exec(getFullPath(), "hg", "init"); - command = "hg add"; - System.err.println(command); - IkaRuntime.exec(getFullPath(), "hg", "add"); + command = "hg add"; + System.err.println(command); + IkaRuntime.exec(getFullPath(), "hg", "add"); - command = "hg commit -minitial_repository"; - System.err.println(command); - IkaRuntime.exec(getFullPath(), "hg", "commit", "-minitial_repository"); + command = "hg commit -minitial_repository"; + System.err.println(command); + IkaRuntime.exec(getFullPath(), "hg", "commit", + "-minitial_repository"); + } else { + System.out.println("hg " + this + "allready exist"); + } } @Override
--- a/src/main/java/org/icedrobot/ika/runtime/scm/Repository.java Sat Apr 09 22:38:20 2011 +0200 +++ b/src/main/java/org/icedrobot/ika/runtime/scm/Repository.java Mon Apr 11 01:50:51 2011 +0200 @@ -55,7 +55,9 @@ * doesn't exist. */ public void createRoot() { - getFullPath().mkdir(); + File p = getFullPath(); + if(!p.exists()) + p.mkdir(); } /**