Mercurial > hg4j
annotate cmdline/org/tmatesoft/hg/console/Outgoing.java @ 184:ec1820f64d2b
Complete incoming cmdline client, with both lite (revisions) and complete (full changeset) information dump
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Wed, 13 Apr 2011 19:09:10 +0200 |
parents | cd3371670f0b |
children | c6fa4dbfc458 |
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 |
171
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
22 import org.tmatesoft.hg.core.HgException; |
74
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
30
diff
changeset
|
23 import org.tmatesoft.hg.core.Nodeid; |
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
|
24 import org.tmatesoft.hg.internal.RepositoryComparator; |
97
ee2c750b036d
Changelog to HgChangelog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
25 import org.tmatesoft.hg.repo.HgChangelog; |
171
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.HgLookup; |
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
27 import org.tmatesoft.hg.repo.HgRemoteRepository; |
74
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
30
diff
changeset
|
28 import org.tmatesoft.hg.repo.HgRepository; |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
30
diff
changeset
|
29 |
30
de7217a0aa4d
Look up changes in the local repo that are not in the remote
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
30 |
de7217a0aa4d
Look up changes in the local repo that are not in the remote
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
31 /** |
74
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
30
diff
changeset
|
32 * WORK IN PROGRESS, DO NOT USE |
171
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
33 * hg outgoing |
74
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
30
diff
changeset
|
34 * |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
30
diff
changeset
|
35 * @author Artem Tikhomirov |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
30
diff
changeset
|
36 * @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
|
37 */ |
de7217a0aa4d
Look up changes in the local repo that are not in the remote
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
38 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
|
39 |
de7217a0aa4d
Look up changes in the local repo that are not in the remote
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
40 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
|
41 Options cmdLineOpts = Options.parse(args); |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
30
diff
changeset
|
42 HgRepository hgRepo = cmdLineOpts.findRepository(); |
30
de7217a0aa4d
Look up changes in the local repo that are not in the remote
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
43 if (hgRepo.isInvalid()) { |
de7217a0aa4d
Look up changes in the local repo that are not in the remote
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
44 System.err.printf("Can't find repository in: %s\n", hgRepo.getLocation()); |
de7217a0aa4d
Look up changes in the local repo that are not in the remote
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
45 return; |
de7217a0aa4d
Look up changes in the local repo that are not in the remote
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
46 } |
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
|
47 HgRemoteRepository hgRemote = new HgLookup().detectRemote("hg4j-gc", hgRepo); |
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 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
|
49 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
|
50 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
|
51 } |
171
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
52 |
98
225c48d964ed
Changelog to HgChangelog, Refactoring doesn't recognize name with inner class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
97
diff
changeset
|
53 HgChangelog.ParentWalker pw = hgRepo.getChangelog().new ParentWalker(); |
30
de7217a0aa4d
Look up changes in the local repo that are not in the remote
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
54 pw.init(); |
171
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
55 |
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
|
56 RepositoryComparator repoCompare = new RepositoryComparator(pw, hgRemote); |
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
|
57 repoCompare.compare(null); |
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
|
58 List<Nodeid> commonKnown = repoCompare.getCommon(); |
171
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
59 dump("Nodes known to be both locally and at remote server", commonKnown); |
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
60 // sanity check |
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
61 for (Nodeid n : commonKnown) { |
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
62 if (!pw.knownNode(n)) { |
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
63 throw new HgException("Unknown node reported as common:" + n); |
30
de7217a0aa4d
Look up changes in the local repo that are not in the remote
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
64 } |
de7217a0aa4d
Look up changes in the local repo that are not in the remote
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
65 } |
171
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
66 // find all local children of commonKnown |
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
67 List<Nodeid> result = pw.childrenOf(commonKnown); |
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
68 dump("Result", result); |
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
69 } |
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
70 |
30
de7217a0aa4d
Look up changes in the local repo that are not in the remote
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
71 |
de7217a0aa4d
Look up changes in the local repo that are not in the remote
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
72 private static void dump(String s, Collection<Nodeid> c) { |
de7217a0aa4d
Look up changes in the local repo that are not in the remote
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
73 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
|
74 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
|
75 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
|
76 } |
de7217a0aa4d
Look up changes in the local repo that are not in the remote
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
77 } |
de7217a0aa4d
Look up changes in the local repo that are not in the remote
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
78 } |