Mercurial > jhg
comparison cmdline/org/tmatesoft/hg/console/Push.java @ 654:12a4f60ea972
1) Console push tool. 2) Pass class to blame into FileUtils
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Wed, 03 Jul 2013 15:11:40 +0200 |
parents | |
children | b1a3a056d7e6 |
comparison
equal
deleted
inserted
replaced
653:629a7370554c | 654:12a4f60ea972 |
---|---|
1 /* | |
2 * Copyright (c) 2013 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.util.Collections; | |
20 | |
21 import org.tmatesoft.hg.core.HgPushCommand; | |
22 import org.tmatesoft.hg.core.HgRepoFacade; | |
23 import org.tmatesoft.hg.repo.HgLookup; | |
24 import org.tmatesoft.hg.repo.HgRemoteRepository; | |
25 | |
26 /** | |
27 * | |
28 * @author Artem Tikhomirov | |
29 * @author TMate Software Ltd. | |
30 */ | |
31 public class Push { | |
32 | |
33 public static void main(String[] args) throws Exception { | |
34 Options cmdLineOpts = Options.parse(args, Collections.<String>emptySet()); | |
35 HgRepoFacade hgRepo = new HgRepoFacade(); | |
36 if (!hgRepo.init(cmdLineOpts.findRepository())) { | |
37 System.err.printf("Can't find repository in: %s\n", hgRepo.getRepository().getLocation()); | |
38 return; | |
39 } | |
40 // XXX perhaps, HgRepoFacade shall get detectRemote() analog (to get remote server with respect of facade's repo) | |
41 HgRemoteRepository hgRemote = new HgLookup().detectRemote(cmdLineOpts.getSingle(""), hgRepo.getRepository()); | |
42 if (hgRemote.isInvalid()) { | |
43 System.err.printf("Remote repository %s is not valid", hgRemote.getLocation()); | |
44 return; | |
45 } | |
46 HgPushCommand cmd = hgRepo.createPushCommand(); | |
47 cmd.destination(hgRemote); | |
48 cmd.execute(); | |
49 System.out.printf("Added %d changesets\n", cmd.getPushedRevisions().size()); | |
50 } | |
51 } |