annotate src/org/tmatesoft/hg/core/HgIncomingCommand.java @ 194:344e8d7e4d6e

Use common low to hi-level changeset api transformer
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Fri, 15 Apr 2011 03:35:08 +0200
parents e5407b5a586a
children c9b305df0b89
rev   line source
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:
diff changeset
1 /*
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:
diff changeset
2 * Copyright (c) 2011 TMate Software Ltd
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:
diff changeset
3 *
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:
diff changeset
4 * This program is free software; you can redistribute it and/or modify
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:
diff changeset
5 * it under the terms of the GNU General Public License as published by
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:
diff changeset
6 * the Free Software Foundation; version 2 of the License.
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:
diff changeset
7 *
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:
diff changeset
8 * This program is distributed in the hope that it will be useful,
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:
diff changeset
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
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:
diff changeset
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
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:
diff changeset
11 * GNU General Public License for more details.
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:
diff changeset
12 *
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:
diff changeset
13 * For information on how to redistribute this software under
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:
diff changeset
14 * the terms of a license other than GNU General Public License
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:
diff changeset
15 * contact TMate Software at support@hg4j.com
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:
diff changeset
16 */
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:
diff changeset
17 package org.tmatesoft.hg.core;
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:
diff changeset
18
192
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
19 import java.io.IOException;
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
20 import java.util.ArrayList;
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
21 import java.util.LinkedHashSet;
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
22 import java.util.LinkedList;
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:
diff changeset
23 import java.util.List;
194
344e8d7e4d6e Use common low to hi-level changeset api transformer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 192
diff changeset
24 import java.util.Set;
344e8d7e4d6e Use common low to hi-level changeset api transformer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 192
diff changeset
25 import java.util.TreeSet;
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:
diff changeset
26
192
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
27 import org.tmatesoft.hg.internal.RepositoryComparator;
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
28 import org.tmatesoft.hg.internal.RepositoryComparator.BranchChain;
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
29 import org.tmatesoft.hg.repo.HgBundle;
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
30 import org.tmatesoft.hg.repo.HgChangelog;
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
31 import org.tmatesoft.hg.repo.HgChangelog.RawChangeset;
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
32 import org.tmatesoft.hg.repo.HgRemoteRepository;
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:
diff changeset
33 import org.tmatesoft.hg.repo.HgRepository;
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:
diff changeset
34 import org.tmatesoft.hg.util.CancelledException;
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:
diff changeset
35
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:
diff changeset
36 /**
192
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
37 * Command to find out changes available in a remote repository, missing locally.
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
38 *
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:
diff changeset
39 * @author Artem Tikhomirov
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:
diff changeset
40 * @author TMate Software Ltd.
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:
diff changeset
41 */
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:
diff changeset
42 public class HgIncomingCommand {
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:
diff changeset
43
192
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
44 private final HgRepository localRepo;
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
45 private HgRemoteRepository remoteRepo;
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:
diff changeset
46 private boolean includeSubrepo;
192
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
47 private RepositoryComparator comparator;
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
48 private List<BranchChain> missingBranches;
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
49 private HgChangelog.ParentWalker parentHelper;
194
344e8d7e4d6e Use common low to hi-level changeset api transformer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 192
diff changeset
50 private Set<String> branches;
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:
diff changeset
51
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:
diff changeset
52 public HgIncomingCommand(HgRepository hgRepo) {
192
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
53 localRepo = hgRepo;
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
54 }
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
55
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
56 public HgIncomingCommand against(HgRemoteRepository hgRemote) {
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
57 remoteRepo = hgRemote;
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
58 comparator = null;
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
59 missingBranches = null;
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
60 return this;
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:
diff changeset
61 }
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:
diff changeset
62
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:
diff changeset
63 /**
194
344e8d7e4d6e Use common low to hi-level changeset api transformer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 192
diff changeset
64 * Select specific branch to push.
344e8d7e4d6e Use common low to hi-level changeset api transformer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 192
diff changeset
65 * Multiple branch specification possible (changeset from any of these would be included in result).
344e8d7e4d6e Use common low to hi-level changeset api transformer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 192
diff changeset
66 * Note, {@link #executeLite(Object)} does not respect this setting.
192
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
67 *
194
344e8d7e4d6e Use common low to hi-level changeset api transformer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 192
diff changeset
68 * @param branch - branch name, case-sensitive, non-null.
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:
diff changeset
69 * @return <code>this</code> for convenience
194
344e8d7e4d6e Use common low to hi-level changeset api transformer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 192
diff changeset
70 * @throws IllegalArgumentException when branch argument is null
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:
diff changeset
71 */
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:
diff changeset
72 public HgIncomingCommand branch(String branch) {
194
344e8d7e4d6e Use common low to hi-level changeset api transformer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 192
diff changeset
73 if (branch == null) {
344e8d7e4d6e Use common low to hi-level changeset api transformer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 192
diff changeset
74 throw new IllegalArgumentException();
344e8d7e4d6e Use common low to hi-level changeset api transformer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 192
diff changeset
75 }
344e8d7e4d6e Use common low to hi-level changeset api transformer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 192
diff changeset
76 if (branches == null) {
344e8d7e4d6e Use common low to hi-level changeset api transformer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 192
diff changeset
77 branches = new TreeSet<String>();
344e8d7e4d6e Use common low to hi-level changeset api transformer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 192
diff changeset
78 }
344e8d7e4d6e Use common low to hi-level changeset api transformer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 192
diff changeset
79 branches.add(branch);
344e8d7e4d6e Use common low to hi-level changeset api transformer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 192
diff changeset
80 return this;
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:
diff changeset
81 }
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:
diff changeset
82
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:
diff changeset
83 /**
192
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
84 * PLACEHOLDER, NOT IMPLEMENTED YET.
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
85 *
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:
diff changeset
86 * Whether to include sub-repositories when collecting changes, default is <code>true</code> XXX or false?
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:
diff changeset
87 * @return <code>this</code> for convenience
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:
diff changeset
88 */
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:
diff changeset
89 public HgIncomingCommand subrepo(boolean include) {
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:
diff changeset
90 includeSubrepo = include;
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:
diff changeset
91 throw HgRepository.notImplemented();
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:
diff changeset
92 }
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:
diff changeset
93
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:
diff changeset
94 /**
194
344e8d7e4d6e Use common low to hi-level changeset api transformer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 192
diff changeset
95 * Lightweight check for incoming changes, gives only list of revisions to pull.
344e8d7e4d6e Use common low to hi-level changeset api transformer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 192
diff changeset
96 * Reported changes are from any branch (limits set by {@link #branch(String)} are not taken into account.
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:
diff changeset
97 *
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:
diff changeset
98 * @param context anything hg4j can use to get progress and/or cancel support
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:
diff changeset
99 * @return list of nodes present at remote and missing locally
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:
diff changeset
100 * @throws HgException
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:
diff changeset
101 * @throws CancelledException
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:
diff changeset
102 */
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:
diff changeset
103 public List<Nodeid> executeLite(Object context) throws HgException, CancelledException {
192
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
104 LinkedHashSet<Nodeid> result = new LinkedHashSet<Nodeid>();
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
105 RepositoryComparator repoCompare = getComparator(context);
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
106 for (BranchChain bc : getMissingBranches(context)) {
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
107 List<Nodeid> missing = repoCompare.visitBranches(bc);
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
108 assert bc.branchRoot.equals(missing.get(0));
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
109 missing.remove(0);
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
110 result.addAll(missing);
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
111 }
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
112 ArrayList<Nodeid> rv = new ArrayList<Nodeid>(result);
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
113 return rv;
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:
diff changeset
114 }
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:
diff changeset
115
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:
diff changeset
116 /**
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:
diff changeset
117 * Full information about incoming changes
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:
diff changeset
118 *
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:
diff changeset
119 * @throws HgException
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:
diff changeset
120 * @throws CancelledException
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:
diff changeset
121 */
192
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
122 public void executeFull(final HgLogCommand.Handler handler) throws HgException, CancelledException {
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
123 if (handler == null) {
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
124 throw new IllegalArgumentException("Delegate can't be null");
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
125 }
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
126 final List<Nodeid> common = getCommon(handler);
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
127 HgBundle changegroup = remoteRepo.getChanges(new LinkedList<Nodeid>(common));
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
128 try {
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
129 changegroup.changes(localRepo, new HgChangelog.Inspector() {
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
130 private int localIndex;
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
131 private final HgChangelog.ParentWalker parentHelper;
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
132 private final ChangesetTransformer transformer;
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
133 private final HgChangelog changelog;
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
134
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
135 {
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
136 transformer = new ChangesetTransformer(localRepo, handler);
194
344e8d7e4d6e Use common low to hi-level changeset api transformer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 192
diff changeset
137 transformer.limitBranches(branches);
192
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
138 parentHelper = getParentHelper();
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
139 changelog = localRepo.getChangelog();
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
140 }
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
141
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
142 public void next(int revisionNumber, Nodeid nodeid, RawChangeset cset) {
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
143 if (parentHelper.knownNode(nodeid)) {
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
144 if (!common.contains(nodeid)) {
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
145 throw new HgBadStateException("Bundle shall not report known nodes other than roots we've supplied");
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
146 }
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
147 localIndex = changelog.getLocalRevision(nodeid);
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
148 return;
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
149 }
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
150 transformer.next(++localIndex, nodeid, cset);
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
151 }
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
152 });
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
153 } catch (IOException ex) {
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
154 throw new HgException(ex);
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
155 }
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
156 }
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
157
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
158 private RepositoryComparator getComparator(Object context) throws HgException, CancelledException {
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
159 if (remoteRepo == null) {
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
160 throw new HgBadArgumentException("Shall specify remote repository to compare against", null);
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
161 }
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
162 if (comparator == null) {
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
163 comparator = new RepositoryComparator(getParentHelper(), remoteRepo);
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
164 comparator.compare(context);
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
165 }
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
166 return comparator;
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
167 }
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
168
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
169 private HgChangelog.ParentWalker getParentHelper() {
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
170 if (parentHelper == null) {
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
171 parentHelper = localRepo.getChangelog().new ParentWalker();
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
172 parentHelper.init();
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
173 }
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
174 return parentHelper;
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
175 }
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
176
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
177 private List<BranchChain> getMissingBranches(Object context) throws HgException, CancelledException {
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
178 if (missingBranches == null) {
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
179 missingBranches = getComparator(context).calculateMissingBranches();
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
180 }
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
181 return missingBranches;
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
182 }
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
183
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
184 private List<Nodeid> getCommon(Object context) throws HgException, CancelledException {
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
185 final LinkedHashSet<Nodeid> common = new LinkedHashSet<Nodeid>();
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
186 // XXX common can be obtained from repoCompare, but at the moment it would almost duplicate work of calculateMissingBranches
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
187 // once I refactor latter, common shall be taken from repoCompare.
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
188 for (BranchChain bc : getMissingBranches(context)) {
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
189 common.add(bc.branchRoot);
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
190 }
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
191 return new LinkedList<Nodeid>(common);
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:
diff changeset
192 }
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:
diff changeset
193 }