changeset 12:5fa4fe467471

Refactor framework and plugins.
author Mario Torre <neugens.limasoftware@gmail.com>
date Tue, 29 Mar 2011 23:53:18 +0200
parents 4f143125b460
children ffeb5d49c3f2
files src/main/java/org/icedrobot/ika/plugins/borg/AndroidAssimilator.java src/main/java/org/icedrobot/ika/plugins/borg/ClonerTask.java src/main/java/org/icedrobot/ika/plugins/borg/IcedRobotCloner.java src/main/java/org/icedrobot/ika/plugins/git/IkaGitWrapper.java src/main/java/org/icedrobot/ika/plugins/scm/GITRepository.java src/main/java/org/icedrobot/ika/plugins/scm/HGRepository.java src/main/java/org/icedrobot/ika/plugins/scm/Repository.java src/main/java/org/icedrobot/ika/runtime/IkaRuntime.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 11 files changed, 403 insertions(+), 462 deletions(-) [+]
line wrap: on
line diff
--- a/src/main/java/org/icedrobot/ika/plugins/borg/AndroidAssimilator.java	Tue Mar 29 20:15:04 2011 +0200
+++ b/src/main/java/org/icedrobot/ika/plugins/borg/AndroidAssimilator.java	Tue Mar 29 23:53:18 2011 +0200
@@ -18,8 +18,8 @@
 
 package org.icedrobot.ika.plugins.borg;
 
-import org.icedrobot.ika.plugins.scm.Repository;
-import org.icedrobot.ika.plugins.scm.GITRepository;
+import org.icedrobot.ika.runtime.scm.Repository;
+import org.icedrobot.ika.runtime.scm.GITRepository;
 import java.io.File;
 import java.io.IOException;
 import java.util.Properties;
--- a/src/main/java/org/icedrobot/ika/plugins/borg/ClonerTask.java	Tue Mar 29 20:15:04 2011 +0200
+++ b/src/main/java/org/icedrobot/ika/plugins/borg/ClonerTask.java	Tue Mar 29 23:53:18 2011 +0200
@@ -18,8 +18,8 @@
 
 package org.icedrobot.ika.plugins.borg;
 
-import org.icedrobot.ika.plugins.scm.Repository;
-import org.icedrobot.ika.plugins.scm.HGRepository;
+import org.icedrobot.ika.runtime.scm.Repository;
+import org.icedrobot.ika.runtime.scm.HGRepository;
 import java.io.File;
 
 import java.util.Properties;
--- a/src/main/java/org/icedrobot/ika/plugins/borg/IcedRobotCloner.java	Tue Mar 29 20:15:04 2011 +0200
+++ b/src/main/java/org/icedrobot/ika/plugins/borg/IcedRobotCloner.java	Tue Mar 29 23:53:18 2011 +0200
@@ -18,8 +18,9 @@
 
 package org.icedrobot.ika.plugins.borg;
 
-import org.icedrobot.ika.plugins.scm.Repository;
-import org.icedrobot.ika.plugins.scm.HGRepository;
+import org.icedrobot.ika.runtime.scm.Repository;
+import org.icedrobot.ika.runtime.scm.HGRepository;
+
 import java.io.File;
 import java.io.IOException;
 import java.util.Properties;
--- a/src/main/java/org/icedrobot/ika/plugins/git/IkaGitWrapper.java	Tue Mar 29 20:15:04 2011 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,95 +0,0 @@
-/*
- * IKA - IcedRobot Kiosk Application
- * Copyright (C) 2011  IcedRobot team
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-package org.icedrobot.ika.plugins.git;
-
-import java.io.File;
-import joptsimple.OptionParser;
-import joptsimple.OptionSet;
-import org.icedrobot.ika.plugins.IkaPlugin;
-import org.icedrobot.ika.plugins.IkaPluginResult;
-import org.icedrobot.ika.plugins.scm.GITRepository;
-import org.icedrobot.ika.plugins.scm.HGRepository;
-import org.icedrobot.ika.plugins.scm.Repository;
-
-/**
- * @author Mario Torre <neugens.limasoftware@gmail.com>
- */
-public class IkaGitWrapper implements IkaPlugin {
-
-    @Override
-    public String getName() {
-        return "git";
-    }
-
-    @Override
-    public String getDescription() {
-        return "handles various git tasks for IcedRobot";
-    }
-
-    @Override
-    public IkaPluginResult execute(String[] args) {
-
-        if (args != null) {
-            OptionParser parser = new OptionParser();
-            parser.accepts("makerepo").withRequiredArg();
-            
-            OptionSet options = parser.parse(args);
-        
-            if (options.has("makerepo")) {
-                String destinationDir = (String) options.valueOf("makerepo");
-
-                File base = new File(destinationDir);
-                if (!base.exists()) {
-                    System.out.println("desitination directory doesn't exist");
-                    return IkaPluginResult.FAILURE;
-                }
-
-                System.err.println("base.getName(): " + base.getName());
-                Repository repository = new GITRepository(base.getName(), base,
-                                                          "", "", "icedrobot");
-                repository.create();
-
-                repository.initPatchQueue();
-
-                String s = File.separator;
-                File basePath = new File(repository.getFullPath() + s +
-                                         ".git" + s + "patches");
-
-                Repository hgRepo = new HGRepository(base.getName(), basePath,
-                                                     "", "");
-                hgRepo.create();
-                
-
-                return IkaPluginResult.OK;
-            }
-        }
-        displayUsage();
-        return IkaPluginResult.OK;
-    }
-
-    private void displayUsage() {
-        System.out.println("Usage: ika git --makerepo=" +
-                           "<destination directory>");
-        System.out.println("\t--makerepo");
-        System.out.println("\t\t\tdirectory where to create the " +
-                           "new git repository");
-        System.out.println("\t\t\tThis argument is mandatory.");
-        System.out.println("\t\t\tThe respository is created with a default");
-        System.out.println("\t\t\t\"icedrobot\" branch");
-    }
-}
--- a/src/main/java/org/icedrobot/ika/plugins/scm/GITRepository.java	Tue Mar 29 20:15:04 2011 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,129 +0,0 @@
-/*
- * IKA - IcedRobot Kiosk Application
- * Copyright (C) 2011  IcedRobot team
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-package org.icedrobot.ika.plugins.scm;
-
-import java.io.File;
-import java.io.IOException;
-import org.icedrobot.ika.plugins.IkaPluginException;
-
-/**
- * @author Mario Torre <neugens.limasoftware@gmail.com>
- */
-public class GITRepository extends Repository {
-    
-    /**
-     * Creates a new git Repository with the give name as ID, the
-     * base directory as the location where the clone will be performed, the
-     * relativePath as the name of the cloned repository, the remotePath as the
-     * location of the source repository and branch as the version of the
-     * repository to clone.
-     */
-    public GITRepository(String name, File baseDirectory, String relativePath,
-                         String remotePath, String branch) {
-
-        this.name = name;
-        this.baseDirectory = baseDirectory;
-        this.relativePath = relativePath;
-        this.remotePath = remotePath;
-
-        this.branch = branch;
-
-        String canonicalPath;
-        try {
-             canonicalPath = baseDirectory.getCanonicalPath();
-        } catch (IOException ex) {
-            throw new IkaPluginException(ex.getMessage(), ex);
-        }
-
-        this.fullPath = new File(canonicalPath + File.separator + relativePath);
-    }
-
-    /**
-     *
-     */
-    @Override
-    public void makeClone() {
-        String command = "git clone -b " + getBranch() + " " + remotePath;
-        System.err.println(command);
-        exec(command, getFullPath());
-    }
-
-
-    /**
-     *
-     */
-    @Override
-    public void create() {
-
-        String command = "git init .";
-        System.err.println(command);
-        exec(command, getFullPath());
-
-        command = "git add --all";
-        System.err.println(command);
-        exec(command, getFullPath());
-
-        command = "git commit -m initial_repository --verbose";
-        System.err.println(command);
-        exec(command, getFullPath());
-
-        command = "git branch " + branch;
-        System.err.println(command);
-        exec(command, getFullPath());
-
-        command = "git checkout " + branch;
-        System.err.println(command);
-        exec(command, getFullPath());
-
-        System.err.println(">>>>>>>> done: " + this + " <<<<<<<<");
-    }
-
-    /**
-     *
-     */
-    @Override
-    public Repository makeSubRepository(String name, String relativePath,
-                                        String branch) {
-
-        if (name.equals(".")) {
-            name = this.getName();
-        }
-        Repository subRepository =
-            new GITRepository(name, new File(getFullPath() + File.separator +
-                                             getName()),
-                              relativePath, null, branch);
-        subRepository.create();
-        return subRepository;
-    }
-
-    @Override
-    public void applyPatchQueue() {
-        String command = "guilt push --all";
-        System.err.println(command);
-        exec(command, getFullPath());
-    }
-
-    @Override
-    public void initPatchQueue() {
-
-        String command = "guilt init";
-        System.err.println(command);
-        exec(command, getFullPath());
-    }
-}
--- a/src/main/java/org/icedrobot/ika/plugins/scm/HGRepository.java	Tue Mar 29 20:15:04 2011 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,99 +0,0 @@
-/*
- * IKA - IcedRobot Kiosk Application
- * Copyright (C) 2011  IcedRobot team
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-package org.icedrobot.ika.plugins.scm;
-
-import java.io.File;
-
-/**
- * @author Mario Torre <neugens.limasoftware@gmail.com>
- */
-public class HGRepository extends Repository {
-
-    /**
-     * Creates a new mercurial forest Repository with the give name as ID, the
-     * base directory as the location where the clone will be performed, the
-     * relativePath as the name of the cloned repository, the remotePath as the
-     * location of the source repository. The Forest extension is needed
-     * to create the repository. The branch is always HEAD.
-     */
-    public HGRepository(String name, File baseDirectory,
-                              String relativePath,
-                              String remotePath) {
-
-        this.name = name;
-        this.baseDirectory = baseDirectory;
-        this.relativePath = relativePath;
-        this.remotePath = remotePath;
-
-        this.fullPath = new File(baseDirectory.getAbsolutePath() +
-                                 File.separator + relativePath);
-    }
-
-    /**
-     *
-     */
-    @Override
-    public void makeClone() {
-        String command = "hg clone " + remotePath + " " + getFullPath();
-        System.err.println(command);
-        exec(command, getFullPath());
-    }
-
-    @Override
-    public String getBranch() {
-        // only HEAD is supported
-        return "HEAD";
-    }
-
-    /**
-     *
-     */
-    @Override
-    public Repository makeSubRepository(String name, String relativePath,
-                                        String branch) {
-        
-        throw new UnsupportedOperationException("not supported yet");
-    }
-
-    @Override
-    public void applyPatchQueue() {
-        throw new UnsupportedOperationException("Not supported yet.");
-    }
-
-    @Override
-    public void create() {
-
-        String command = "hg init .";
-        System.err.println(command);
-        exec(command, getFullPath());
-
-        command = "hg add";
-        System.err.println(command);
-        exec(command, getFullPath());
-
-        command = "hg commit -minitial_repository";
-        System.err.println(command);
-        exec(command, getFullPath());
-    }
-
-    @Override
-    public void initPatchQueue() {
-        throw new UnsupportedOperationException("Not supported yet.");
-    }
-}
--- a/src/main/java/org/icedrobot/ika/plugins/scm/Repository.java	Tue Mar 29 20:15:04 2011 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,133 +0,0 @@
-/*
- * IKA - IcedRobot Kiosk Application
- * Copyright (C) 2011  IcedRobot team
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-package org.icedrobot.ika.plugins.scm;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import org.icedrobot.ika.plugins.IkaPluginException;
-
-/**
- * @author Mario Torre <neugens.limasoftware@gmail.com>
- */
-public abstract class Repository {
-
-    protected String name;
-    protected File baseDirectory;
-    protected File fullPath;
-
-    protected String relativePath;
-    protected String remotePath;
-    protected String branch;
-
-    public abstract void create();
-    abstract public void initPatchQueue();
-    public abstract void applyPatchQueue();
-    public abstract void makeClone();
-    public abstract Repository makeSubRepository(String name,
-                                                 String relativePath,
-                                                 String branch);
-
-    protected static void exec(String command, File path) {
-        try {
-            System.err.println("command: " + command + ", path: " + path);
-            Process process = Runtime.getRuntime().exec(command, null, path);
-
-            InputStream is = process.getInputStream();
-            InputStreamReader reader = new InputStreamReader(is);
-
-            BufferedReader br = new BufferedReader(reader);
-
-            String line;
-            while ((line = br.readLine()) != null) {
-                System.out.println(line);
-            }
-
-        } catch (IOException ex) {
-            Logger.getLogger(Repository.class.getName()).
-                    log(Level.SEVERE, "cannot execute: " + command, ex);
-            throw new IkaPluginException("cannot execute: " + command, ex);
-        }
-    }
-
-    /**
-     * Create the directory under which this repository will be located if it
-     * doesn't exist.
-     */
-    public void createRoot() {
-        getFullPath().mkdir();
-    }
-
-    /**
-     * @return the name
-     */
-    public String getName() {
-        return name;
-    }
-
-    /**
-     * @return the baseDirectory
-     */
-    public File getBaseDirectory() {
-        return baseDirectory;
-    }
-
-    /**
-     * @return the fullPath
-     */
-    public File getFullPath() {
-        try {
-            return fullPath.getCanonicalFile();
-        } catch (IOException ex) {
-            throw new IkaPluginException(ex.toString(), ex);
-        }
-    }
-
-    /**
-     * @return the relativePath
-     */
-    public String getRelativePath() {
-        return relativePath;
-    }
-
-    /**
-     * @return the remotePath
-     */
-    public String getRemotePath() {
-        return remotePath;
-    }
-
-    /**
-     * @return the branch
-     */
-    public String getBranch() {
-        return branch;
-    }
-
-    @Override
-    public String toString() {
-        return fullPath.toString();
-    }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/org/icedrobot/ika/runtime/IkaRuntime.java	Tue Mar 29 23:53:18 2011 +0200
@@ -0,0 +1,55 @@
+/*
+ * IKA - IcedRobot Kiosk Application
+ * Copyright (C) 2011  IcedRobot team
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.icedrobot.ika.runtime;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import org.icedrobot.ika.plugins.IkaPluginException;
+
+public class IkaRuntime {
+
+    /**
+     * Executes the given command on the passed path.
+     */
+    public static void exec(String command, File path) {
+        try {
+            System.err.println("command: " + command + ", path: " + path);
+            Process process = Runtime.getRuntime().exec(command, null, path);
+
+            InputStream is = process.getInputStream();
+            InputStreamReader reader = new InputStreamReader(is);
+
+            BufferedReader br = new BufferedReader(reader);
+
+            String line;
+            while ((line = br.readLine()) != null) {
+                System.out.println(line);
+            }
+
+        } catch (IOException ex) {
+            Logger.getLogger(IkaRuntime.class.getName()).
+                    log(Level.SEVERE, "cannot execute: " + command, ex);
+            throw new IkaPluginException("cannot execute: " + command, ex);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/org/icedrobot/ika/runtime/scm/GITRepository.java	Tue Mar 29 23:53:18 2011 +0200
@@ -0,0 +1,130 @@
+/*
+ * IKA - IcedRobot Kiosk Application
+ * Copyright (C) 2011  IcedRobot team
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package org.icedrobot.ika.runtime.scm;
+
+import java.io.File;
+import java.io.IOException;
+import org.icedrobot.ika.plugins.IkaPluginException;
+import org.icedrobot.ika.runtime.IkaRuntime;
+
+/**
+ * @author Mario Torre <neugens.limasoftware@gmail.com>
+ */
+public class GITRepository extends Repository {
+    
+    /**
+     * Creates a new git Repository with the give name as ID, the
+     * base directory as the location where the clone will be performed, the
+     * relativePath as the name of the cloned repository, the remotePath as the
+     * location of the source repository and branch as the version of the
+     * repository to clone.
+     */
+    public GITRepository(String name, File baseDirectory, String relativePath,
+                         String remotePath, String branch) {
+
+        this.name = name;
+        this.baseDirectory = baseDirectory;
+        this.relativePath = relativePath;
+        this.remotePath = remotePath;
+
+        this.branch = branch;
+
+        String canonicalPath;
+        try {
+             canonicalPath = baseDirectory.getCanonicalPath();
+        } catch (IOException ex) {
+            throw new IkaPluginException(ex.getMessage(), ex);
+        }
+
+        this.fullPath = new File(canonicalPath + File.separator + relativePath);
+    }
+
+    /**
+     *
+     */
+    @Override
+    public void makeClone() {
+        String command = "git clone -b " + getBranch() + " " + remotePath;
+        System.err.println(command);
+        IkaRuntime.exec(command, getFullPath());
+    }
+
+
+    /**
+     *
+     */
+    @Override
+    public void create() {
+
+        String command = "git init .";
+        System.err.println(command);
+        IkaRuntime.exec(command, getFullPath());
+
+        command = "git add --all";
+        System.err.println(command);
+        IkaRuntime.exec(command, getFullPath());
+
+        command = "git commit -m initial_repository --verbose";
+        System.err.println(command);
+        IkaRuntime.exec(command, getFullPath());
+
+        command = "git branch " + branch;
+        System.err.println(command);
+        IkaRuntime.exec(command, getFullPath());
+
+        command = "git checkout " + branch;
+        System.err.println(command);
+        IkaRuntime.exec(command, getFullPath());
+
+        System.err.println(">>>>>>>> done: " + this + " <<<<<<<<");
+    }
+
+    /**
+     *
+     */
+    @Override
+    public Repository makeSubRepository(String name, String relativePath,
+                                        String branch) {
+
+        if (name.equals(".")) {
+            name = this.getName();
+        }
+        Repository subRepository =
+            new GITRepository(name, new File(getFullPath() + File.separator +
+                                             getName()),
+                              relativePath, null, branch);
+        subRepository.create();
+        return subRepository;
+    }
+
+    @Override
+    public void applyPatchQueue() {
+        String command = "guilt push --all";
+        System.err.println(command);
+        IkaRuntime.exec(command, getFullPath());
+    }
+
+    @Override
+    public void initPatchQueue() {
+
+        String command = "guilt init";
+        System.err.println(command);
+        IkaRuntime.exec(command, getFullPath());
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/org/icedrobot/ika/runtime/scm/HGRepository.java	Tue Mar 29 23:53:18 2011 +0200
@@ -0,0 +1,100 @@
+/*
+ * IKA - IcedRobot Kiosk Application
+ * Copyright (C) 2011  IcedRobot team
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package org.icedrobot.ika.runtime.scm;
+
+import java.io.File;
+import org.icedrobot.ika.runtime.IkaRuntime;
+
+/**
+ * @author Mario Torre <neugens.limasoftware@gmail.com>
+ */
+public class HGRepository extends Repository {
+
+    /**
+     * Creates a new mercurial forest Repository with the give name as ID, the
+     * base directory as the location where the clone will be performed, the
+     * relativePath as the name of the cloned repository, the remotePath as the
+     * location of the source repository. The Forest extension is needed
+     * to create the repository. The branch is always HEAD.
+     */
+    public HGRepository(String name, File baseDirectory,
+                              String relativePath,
+                              String remotePath) {
+
+        this.name = name;
+        this.baseDirectory = baseDirectory;
+        this.relativePath = relativePath;
+        this.remotePath = remotePath;
+
+        this.fullPath = new File(baseDirectory.getAbsolutePath() +
+                                 File.separator + relativePath);
+    }
+
+    /**
+     *
+     */
+    @Override
+    public void makeClone() {
+        String command = "hg clone " + remotePath + " " + getFullPath();
+        System.err.println(command);
+        IkaRuntime.exec(command, getFullPath());
+    }
+
+    @Override
+    public String getBranch() {
+        // only HEAD is supported
+        return "HEAD";
+    }
+
+    /**
+     *
+     */
+    @Override
+    public Repository makeSubRepository(String name, String relativePath,
+                                        String branch) {
+        
+        throw new UnsupportedOperationException("not supported yet");
+    }
+
+    @Override
+    public void applyPatchQueue() {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public void create() {
+
+        String command = "hg init .";
+        System.err.println(command);
+        IkaRuntime.exec(command, getFullPath());
+
+        command = "hg add";
+        System.err.println(command);
+        IkaRuntime.exec(command, getFullPath());
+
+        command = "hg commit -minitial_repository";
+        System.err.println(command);
+        IkaRuntime.exec(command, getFullPath());
+    }
+
+    @Override
+    public void initPatchQueue() {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/org/icedrobot/ika/runtime/scm/Repository.java	Tue Mar 29 23:53:18 2011 +0200
@@ -0,0 +1,111 @@
+/*
+ * IKA - IcedRobot Kiosk Application
+ * Copyright (C) 2011  IcedRobot team
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package org.icedrobot.ika.runtime.scm;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.icedrobot.ika.plugins.IkaPluginException;
+
+/**
+ * @author Mario Torre <neugens.limasoftware@gmail.com>
+ */
+public abstract class Repository {
+
+    protected String name;
+    protected File baseDirectory;
+    protected File fullPath;
+
+    protected String relativePath;
+    protected String remotePath;
+    protected String branch;
+
+    public abstract void create();
+    abstract public void initPatchQueue();
+    public abstract void applyPatchQueue();
+    public abstract void makeClone();
+    public abstract Repository makeSubRepository(String name,
+                                                 String relativePath,
+                                                 String branch);
+
+    /**
+     * Create the directory under which this repository will be located if it
+     * doesn't exist.
+     */
+    public void createRoot() {
+        getFullPath().mkdir();
+    }
+
+    /**
+     * @return the name
+     */
+    public String getName() {
+        return name;
+    }
+
+    /**
+     * @return the baseDirectory
+     */
+    public File getBaseDirectory() {
+        return baseDirectory;
+    }
+
+    /**
+     * @return the fullPath
+     */
+    public File getFullPath() {
+        try {
+            return fullPath.getCanonicalFile();
+        } catch (IOException ex) {
+            throw new IkaPluginException(ex.toString(), ex);
+        }
+    }
+
+    /**
+     * @return the relativePath
+     */
+    public String getRelativePath() {
+        return relativePath;
+    }
+
+    /**
+     * @return the remotePath
+     */
+    public String getRemotePath() {
+        return remotePath;
+    }
+
+    /**
+     * @return the branch
+     */
+    public String getBranch() {
+        return branch;
+    }
+
+    @Override
+    public String toString() {
+        return fullPath.toString();
+    }
+}