comparison hg4j-cli/src/main/java/org/tmatesoft/hg/console/Clone.java @ 213:6ec4af642ba8 gradle

Project uses Gradle for build - actual changes
author Alexander Kitaev <kitaev@gmail.com>
date Tue, 10 May 2011 10:52:53 +0200
parents
children
comparison
equal deleted inserted replaced
212:edb2e2829352 213:6ec4af642ba8
1 /*
2 * Copyright (c) 2011 TMate Software Ltd
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 2 of the License.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * For information on how to redistribute this software under
14 * the terms of a license other than GNU General Public License
15 * contact TMate Software at support@hg4j.com
16 */
17 package org.tmatesoft.hg.console;
18
19 import java.io.File;
20 import java.util.List;
21
22 import org.tmatesoft.hg.core.HgCloneCommand;
23 import org.tmatesoft.hg.repo.HgLookup;
24 import org.tmatesoft.hg.repo.HgRemoteRepository;
25
26 /**
27 * Initial clone of a repository. Creates a brand new repository and populates it from specified source.
28 *
29 * @author Artem Tikhomirov
30 * @author TMate Software Ltd.
31 */
32 public class Clone {
33
34 // ran with args: svnkit c:\temp\hg\test-clone
35 public static void main(String[] args) throws Exception {
36 Options cmdLineOpts = Options.parse(args);
37 List<String> noOptsArgs = cmdLineOpts.getList("");
38 if (noOptsArgs.isEmpty()) {
39 System.err.println("Need at least one argument pointing to remote server to pull changes from");
40 return;
41 }
42 HgCloneCommand cmd = new HgCloneCommand();
43 String remoteRepo = noOptsArgs.get(0);
44 HgRemoteRepository hgRemote = new HgLookup().detectRemote(remoteRepo, null);
45 if (hgRemote.isInvalid()) {
46 System.err.printf("Remote repository %s is not valid", hgRemote.getLocation());
47 return;
48 }
49 cmd.source(hgRemote);
50 if (noOptsArgs.size() > 1) {
51 cmd.destination(new File(noOptsArgs.get(1)));
52 } else {
53 cmd.destination(new File(System.getProperty("user.dir")));
54 }
55 cmd.execute();
56 }
57 }