Mercurial > hg > icedrobot > ika
view src/main/java/org/icedrobot/ika/runtime/scm/HGRepository.java @ 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 | 8a417ad3e271 |
children | 3b0d6002605a |
line wrap: on
line source
/* * 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; 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); } /** * Clone hg Repository. * If the hg Repository allready exist then quickly pull in * new changesets and update. */ @Override public void makeClone() { 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 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() { 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 commit -minitial_repository"; System.err.println(command); IkaRuntime.exec(getFullPath(), "hg", "commit", "-minitial_repository"); } else { System.out.println("hg " + this + "allready exist"); } } @Override public void initPatchQueue() { throw new UnsupportedOperationException("Not supported yet."); } }