Mercurial > hg4j
annotate cmdline/org/tmatesoft/hg/console/Outgoing.java @ 249:4c3b9f679412
Deprecated HgLogCommand.FileRevision gone, top-level HgFileRevision is bright and shiny replacement
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Fri, 12 Aug 2011 18:58:16 +0200 |
parents | 41a778e3fd31 |
children | 45dc79e545f5 |
rev | line source |
---|---|
30
de7217a0aa4d
Look up changes in the local repo that are not in the remote
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
1 /* |
74
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
30
diff
changeset
|
2 * Copyright (c) 2011 TMate Software Ltd |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
30
diff
changeset
|
3 * |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
30
diff
changeset
|
4 * This program is free software; you can redistribute it and/or modify |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
30
diff
changeset
|
5 * it under the terms of the GNU General Public License as published by |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
30
diff
changeset
|
6 * the Free Software Foundation; version 2 of the License. |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
30
diff
changeset
|
7 * |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
30
diff
changeset
|
8 * This program is distributed in the hope that it will be useful, |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
30
diff
changeset
|
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
30
diff
changeset
|
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
30
diff
changeset
|
11 * GNU General Public License for more details. |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
30
diff
changeset
|
12 * |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
30
diff
changeset
|
13 * For information on how to redistribute this software under |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
30
diff
changeset
|
14 * the terms of a license other than GNU General Public License |
102
a3a2e5deb320
Updated contact address to support@hg4j.com
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
98
diff
changeset
|
15 * contact TMate Software at support@hg4j.com |
30
de7217a0aa4d
Look up changes in the local repo that are not in the remote
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
16 */ |
74
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
30
diff
changeset
|
17 package org.tmatesoft.hg.console; |
30
de7217a0aa4d
Look up changes in the local repo that are not in the remote
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
18 |
de7217a0aa4d
Look up changes in the local repo that are not in the remote
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
19 import java.util.Collection; |
de7217a0aa4d
Look up changes in the local repo that are not in the remote
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
20 import java.util.List; |
de7217a0aa4d
Look up changes in the local repo that are not in the remote
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
21 |
206
63c9fed4369e
Sample command line tools for incoming/outgoing to use commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
192
diff
changeset
|
22 import org.tmatesoft.hg.core.HgOutgoingCommand; |
63c9fed4369e
Sample command line tools for incoming/outgoing to use commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
192
diff
changeset
|
23 import org.tmatesoft.hg.core.HgRepoFacade; |
74
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
30
diff
changeset
|
24 import org.tmatesoft.hg.core.Nodeid; |
171
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
25 import org.tmatesoft.hg.repo.HgLookup; |
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
26 import org.tmatesoft.hg.repo.HgRemoteRepository; |
74
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
30
diff
changeset
|
27 |
30
de7217a0aa4d
Look up changes in the local repo that are not in the remote
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
28 |
de7217a0aa4d
Look up changes in the local repo that are not in the remote
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
29 /** |
206
63c9fed4369e
Sample command line tools for incoming/outgoing to use commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
192
diff
changeset
|
30 * <em>hg outgoing</em> |
74
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
30
diff
changeset
|
31 * |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
30
diff
changeset
|
32 * @author Artem Tikhomirov |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
30
diff
changeset
|
33 * @author TMate Software Ltd. |
30
de7217a0aa4d
Look up changes in the local repo that are not in the remote
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
34 */ |
de7217a0aa4d
Look up changes in the local repo that are not in the remote
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
35 public class Outgoing { |
de7217a0aa4d
Look up changes in the local repo that are not in the remote
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
36 |
de7217a0aa4d
Look up changes in the local repo that are not in the remote
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
37 public static void main(String[] args) throws Exception { |
74
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
30
diff
changeset
|
38 Options cmdLineOpts = Options.parse(args); |
206
63c9fed4369e
Sample command line tools for incoming/outgoing to use commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
192
diff
changeset
|
39 HgRepoFacade hgRepo = new HgRepoFacade(); |
63c9fed4369e
Sample command line tools for incoming/outgoing to use commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
192
diff
changeset
|
40 if (!hgRepo.init(cmdLineOpts.findRepository())) { |
63c9fed4369e
Sample command line tools for incoming/outgoing to use commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
192
diff
changeset
|
41 System.err.printf("Can't find repository in: %s\n", hgRepo.getRepository().getLocation()); |
30
de7217a0aa4d
Look up changes in the local repo that are not in the remote
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
42 return; |
de7217a0aa4d
Look up changes in the local repo that are not in the remote
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
43 } |
206
63c9fed4369e
Sample command line tools for incoming/outgoing to use commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
192
diff
changeset
|
44 // XXX perhaps, HgRepoFacade shall get detectRemote() analog (to get remote server with respect of facade's repo) |
63c9fed4369e
Sample command line tools for incoming/outgoing to use commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
192
diff
changeset
|
45 HgRemoteRepository hgRemote = new HgLookup().detectRemote(cmdLineOpts.getSingle(""), hgRepo.getRepository()); |
181
cd3371670f0b
Refactor incoming and outgoing code to be shared with RepositoryComparator. Placeholders for in/out commands. Refactor common remote lookup code
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
178
diff
changeset
|
46 if (hgRemote.isInvalid()) { |
cd3371670f0b
Refactor incoming and outgoing code to be shared with RepositoryComparator. Placeholders for in/out commands. Refactor common remote lookup code
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
178
diff
changeset
|
47 System.err.printf("Remote repository %s is not valid", hgRemote.getLocation()); |
cd3371670f0b
Refactor incoming and outgoing code to be shared with RepositoryComparator. Placeholders for in/out commands. Refactor common remote lookup code
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
178
diff
changeset
|
48 return; |
172
87f40938c9b2
Configuration handling out of HgLookup (bad idea to use URL to pass keys)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
171
diff
changeset
|
49 } |
206
63c9fed4369e
Sample command line tools for incoming/outgoing to use commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
192
diff
changeset
|
50 // |
63c9fed4369e
Sample command line tools for incoming/outgoing to use commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
192
diff
changeset
|
51 HgOutgoingCommand cmd = hgRepo.createOutgoingCommand(); |
63c9fed4369e
Sample command line tools for incoming/outgoing to use commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
192
diff
changeset
|
52 cmd.against(hgRemote); |
171
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
53 |
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
54 // find all local children of commonKnown |
215
41a778e3fd31
Issue 5: Facilities for progress and cancellation. More specific exceptions. Exceptions from callbacks as RuntimeException
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
206
diff
changeset
|
55 List<Nodeid> result = cmd.executeLite(); |
185
c6fa4dbfc458
Complete Outgoing cmdline, with both lite (revisions) and complete (changeset) information dump
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
181
diff
changeset
|
56 dump("Lite", result); |
192
e5407b5a586a
Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
185
diff
changeset
|
57 // |
e5407b5a586a
Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
185
diff
changeset
|
58 // |
185
c6fa4dbfc458
Complete Outgoing cmdline, with both lite (revisions) and complete (changeset) information dump
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
181
diff
changeset
|
59 System.out.println("Full"); |
c6fa4dbfc458
Complete Outgoing cmdline, with both lite (revisions) and complete (changeset) information dump
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
181
diff
changeset
|
60 // show all, starting from next to common |
206
63c9fed4369e
Sample command line tools for incoming/outgoing to use commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
192
diff
changeset
|
61 final ChangesetDumpHandler h = new ChangesetDumpHandler(hgRepo.getRepository()); |
63c9fed4369e
Sample command line tools for incoming/outgoing to use commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
192
diff
changeset
|
62 h.complete(cmdLineOpts.getBoolean("--debug")).verbose(cmdLineOpts.getBoolean("-v", "--verbose")); |
63c9fed4369e
Sample command line tools for incoming/outgoing to use commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
192
diff
changeset
|
63 cmd.executeFull(h); |
63c9fed4369e
Sample command line tools for incoming/outgoing to use commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
192
diff
changeset
|
64 h.done(); |
171
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
65 } |
192
e5407b5a586a
Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
185
diff
changeset
|
66 |
206
63c9fed4369e
Sample command line tools for incoming/outgoing to use commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
192
diff
changeset
|
67 // public static class ChangesetFormatter { |
63c9fed4369e
Sample command line tools for incoming/outgoing to use commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
192
diff
changeset
|
68 // private final StringBuilder sb = new StringBuilder(1024); |
63c9fed4369e
Sample command line tools for incoming/outgoing to use commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
192
diff
changeset
|
69 // |
63c9fed4369e
Sample command line tools for incoming/outgoing to use commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
192
diff
changeset
|
70 // public CharSequence simple(int revisionNumber, Nodeid nodeid, RawChangeset cset) { |
63c9fed4369e
Sample command line tools for incoming/outgoing to use commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
192
diff
changeset
|
71 // sb.setLength(0); |
63c9fed4369e
Sample command line tools for incoming/outgoing to use commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
192
diff
changeset
|
72 // sb.append(String.format("changeset: %d:%s\n", revisionNumber, nodeid.toString())); |
63c9fed4369e
Sample command line tools for incoming/outgoing to use commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
192
diff
changeset
|
73 // sb.append(String.format("user: %s\n", cset.user())); |
63c9fed4369e
Sample command line tools for incoming/outgoing to use commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
192
diff
changeset
|
74 // sb.append(String.format("date: %s\n", cset.dateString())); |
63c9fed4369e
Sample command line tools for incoming/outgoing to use commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
192
diff
changeset
|
75 // sb.append(String.format("comment: %s\n\n", cset.comment())); |
63c9fed4369e
Sample command line tools for incoming/outgoing to use commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
192
diff
changeset
|
76 // return sb; |
63c9fed4369e
Sample command line tools for incoming/outgoing to use commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
192
diff
changeset
|
77 // } |
63c9fed4369e
Sample command line tools for incoming/outgoing to use commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
192
diff
changeset
|
78 // } |
171
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
79 |
30
de7217a0aa4d
Look up changes in the local repo that are not in the remote
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
80 |
206
63c9fed4369e
Sample command line tools for incoming/outgoing to use commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
192
diff
changeset
|
81 static void dump(String s, Collection<Nodeid> c) { |
30
de7217a0aa4d
Look up changes in the local repo that are not in the remote
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
82 System.out.println(s); |
de7217a0aa4d
Look up changes in the local repo that are not in the remote
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
83 for (Nodeid n : c) { |
de7217a0aa4d
Look up changes in the local repo that are not in the remote
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
84 System.out.println(n); |
de7217a0aa4d
Look up changes in the local repo that are not in the remote
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
85 } |
de7217a0aa4d
Look up changes in the local repo that are not in the remote
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
86 } |
de7217a0aa4d
Look up changes in the local repo that are not in the remote
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
87 } |