Mercurial > jhg
annotate 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 | 
| rev | line source | 
|---|---|
| 
654
 
12a4f60ea972
1) Console push tool. 2) Pass class to blame into FileUtils
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
1 /* | 
| 
 
12a4f60ea972
1) Console push tool. 2) Pass class to blame into FileUtils
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
2 * Copyright (c) 2013 TMate Software Ltd | 
| 
 
12a4f60ea972
1) Console push tool. 2) Pass class to blame into FileUtils
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
3 * | 
| 
 
12a4f60ea972
1) Console push tool. 2) Pass class to blame into FileUtils
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
4 * This program is free software; you can redistribute it and/or modify | 
| 
 
12a4f60ea972
1) Console push tool. 2) Pass class to blame into FileUtils
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
5 * it under the terms of the GNU General Public License as published by | 
| 
 
12a4f60ea972
1) Console push tool. 2) Pass class to blame into FileUtils
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
6 * the Free Software Foundation; version 2 of the License. | 
| 
 
12a4f60ea972
1) Console push tool. 2) Pass class to blame into FileUtils
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
7 * | 
| 
 
12a4f60ea972
1) Console push tool. 2) Pass class to blame into FileUtils
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
8 * This program is distributed in the hope that it will be useful, | 
| 
 
12a4f60ea972
1) Console push tool. 2) Pass class to blame into FileUtils
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
| 
 
12a4f60ea972
1) Console push tool. 2) Pass class to blame into FileUtils
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 
| 
 
12a4f60ea972
1) Console push tool. 2) Pass class to blame into FileUtils
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
11 * GNU General Public License for more details. | 
| 
 
12a4f60ea972
1) Console push tool. 2) Pass class to blame into FileUtils
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
12 * | 
| 
 
12a4f60ea972
1) Console push tool. 2) Pass class to blame into FileUtils
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
13 * For information on how to redistribute this software under | 
| 
 
12a4f60ea972
1) Console push tool. 2) Pass class to blame into FileUtils
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
14 * the terms of a license other than GNU General Public License | 
| 
 
12a4f60ea972
1) Console push tool. 2) Pass class to blame into FileUtils
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
15 * contact TMate Software at support@hg4j.com | 
| 
 
12a4f60ea972
1) Console push tool. 2) Pass class to blame into FileUtils
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
16 */ | 
| 
 
12a4f60ea972
1) Console push tool. 2) Pass class to blame into FileUtils
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
17 package org.tmatesoft.hg.console; | 
| 
 
12a4f60ea972
1) Console push tool. 2) Pass class to blame into FileUtils
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
18 | 
| 
 
12a4f60ea972
1) Console push tool. 2) Pass class to blame into FileUtils
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
19 import java.util.Collections; | 
| 
 
12a4f60ea972
1) Console push tool. 2) Pass class to blame into FileUtils
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
20 | 
| 
 
12a4f60ea972
1) Console push tool. 2) Pass class to blame into FileUtils
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
21 import org.tmatesoft.hg.core.HgPushCommand; | 
| 
 
12a4f60ea972
1) Console push tool. 2) Pass class to blame into FileUtils
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
22 import org.tmatesoft.hg.core.HgRepoFacade; | 
| 
 
12a4f60ea972
1) Console push tool. 2) Pass class to blame into FileUtils
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
23 import org.tmatesoft.hg.repo.HgLookup; | 
| 
 
12a4f60ea972
1) Console push tool. 2) Pass class to blame into FileUtils
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
24 import org.tmatesoft.hg.repo.HgRemoteRepository; | 
| 
 
12a4f60ea972
1) Console push tool. 2) Pass class to blame into FileUtils
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
25 | 
| 
 
12a4f60ea972
1) Console push tool. 2) Pass class to blame into FileUtils
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
26 /** | 
| 
 
12a4f60ea972
1) Console push tool. 2) Pass class to blame into FileUtils
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
27 * | 
| 
 
12a4f60ea972
1) Console push tool. 2) Pass class to blame into FileUtils
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
28 * @author Artem Tikhomirov | 
| 
 
12a4f60ea972
1) Console push tool. 2) Pass class to blame into FileUtils
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
29 * @author TMate Software Ltd. | 
| 
 
12a4f60ea972
1) Console push tool. 2) Pass class to blame into FileUtils
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
30 */ | 
| 
 
12a4f60ea972
1) Console push tool. 2) Pass class to blame into FileUtils
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
31 public class Push { | 
| 
 
12a4f60ea972
1) Console push tool. 2) Pass class to blame into FileUtils
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
32 | 
| 
 
12a4f60ea972
1) Console push tool. 2) Pass class to blame into FileUtils
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
33 public static void main(String[] args) throws Exception { | 
| 
 
12a4f60ea972
1) Console push tool. 2) Pass class to blame into FileUtils
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
34 Options cmdLineOpts = Options.parse(args, Collections.<String>emptySet()); | 
| 
 
12a4f60ea972
1) Console push tool. 2) Pass class to blame into FileUtils
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
35 HgRepoFacade hgRepo = new HgRepoFacade(); | 
| 
 
12a4f60ea972
1) Console push tool. 2) Pass class to blame into FileUtils
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
36 if (!hgRepo.init(cmdLineOpts.findRepository())) { | 
| 
 
12a4f60ea972
1) Console push tool. 2) Pass class to blame into FileUtils
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
37 System.err.printf("Can't find repository in: %s\n", hgRepo.getRepository().getLocation()); | 
| 
 
12a4f60ea972
1) Console push tool. 2) Pass class to blame into FileUtils
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
38 return; | 
| 
 
12a4f60ea972
1) Console push tool. 2) Pass class to blame into FileUtils
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
39 } | 
| 
 
12a4f60ea972
1) Console push tool. 2) Pass class to blame into FileUtils
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
40 // XXX perhaps, HgRepoFacade shall get detectRemote() analog (to get remote server with respect of facade's repo) | 
| 
 
12a4f60ea972
1) Console push tool. 2) Pass class to blame into FileUtils
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
41 HgRemoteRepository hgRemote = new HgLookup().detectRemote(cmdLineOpts.getSingle(""), hgRepo.getRepository()); | 
| 
 
12a4f60ea972
1) Console push tool. 2) Pass class to blame into FileUtils
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
42 if (hgRemote.isInvalid()) { | 
| 
 
12a4f60ea972
1) Console push tool. 2) Pass class to blame into FileUtils
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
43 System.err.printf("Remote repository %s is not valid", hgRemote.getLocation()); | 
| 
 
12a4f60ea972
1) Console push tool. 2) Pass class to blame into FileUtils
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
44 return; | 
| 
 
12a4f60ea972
1) Console push tool. 2) Pass class to blame into FileUtils
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
45 } | 
| 
 
12a4f60ea972
1) Console push tool. 2) Pass class to blame into FileUtils
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
46 HgPushCommand cmd = hgRepo.createPushCommand(); | 
| 
 
12a4f60ea972
1) Console push tool. 2) Pass class to blame into FileUtils
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
47 cmd.destination(hgRemote); | 
| 
 
12a4f60ea972
1) Console push tool. 2) Pass class to blame into FileUtils
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
48 cmd.execute(); | 
| 
 
12a4f60ea972
1) Console push tool. 2) Pass class to blame into FileUtils
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
49 System.out.printf("Added %d changesets\n", cmd.getPushedRevisions().size()); | 
| 
 
12a4f60ea972
1) Console push tool. 2) Pass class to blame into FileUtils
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
50 } | 
| 
 
12a4f60ea972
1) Console push tool. 2) Pass class to blame into FileUtils
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
51 } | 
