annotate src/org/tmatesoft/hg/core/HgOutgoingCommand.java @ 423:9c9c442b5f2e

Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Fri, 23 Mar 2012 22:51:18 +0100
parents 7f136a3fa671
children 31a89587eb04
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 /*
419
7f136a3fa671 Clean javadoc to fix obvious warnings
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 380
diff changeset
2 * Copyright (c) 2011-2012 TMate Software Ltd
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
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
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
19 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
20 import java.util.Set;
344e8d7e4d6e Use common low to hi-level changeset api transformer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 192
diff changeset
21 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
22
192
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
23 import org.tmatesoft.hg.internal.RepositoryComparator;
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
24 import org.tmatesoft.hg.repo.HgChangelog;
423
9c9c442b5f2e Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 419
diff changeset
25 import org.tmatesoft.hg.repo.HgInvalidControlFileException;
192
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
26 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
27 import org.tmatesoft.hg.repo.HgRepository;
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
28 import org.tmatesoft.hg.util.CancelSupport;
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
29 import org.tmatesoft.hg.util.CancelledException;
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
30 import org.tmatesoft.hg.util.ProgressSupport;
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
31
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
32 /**
192
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
33 * Command to find out changes made in a local repository and missing at remote repository.
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
34 *
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
35 * @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
36 * @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
37 */
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
38 public class HgOutgoingCommand extends HgAbstractCommand<HgOutgoingCommand> {
192
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
39
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
40 private final HgRepository localRepo;
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
41 private HgRemoteRepository remoteRepo;
206
63c9fed4369e Sample command line tools for incoming/outgoing to use commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 205
diff changeset
42 @SuppressWarnings("unused")
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
43 private boolean includeSubrepo;
192
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
44 private RepositoryComparator comparator;
195
c9b305df0b89 Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 194
diff changeset
45 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
46 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
47
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
48 public HgOutgoingCommand(HgRepository hgRepo) {
192
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
49 localRepo = hgRepo;
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
50 }
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 /**
192
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
53 * @param hgRemote remoteRepository to compare against
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
54 * @return <code>this</code> for convenience
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 HgOutgoingCommand 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 return this;
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
60 }
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
61
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
62 /**
194
344e8d7e4d6e Use common low to hi-level changeset api transformer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 192
diff changeset
63 * Select specific branch to pull.
344e8d7e4d6e Use common low to hi-level changeset api transformer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 192
diff changeset
64 * Multiple branch specification possible (changeset from any of these would be included in result).
419
7f136a3fa671 Clean javadoc to fix obvious warnings
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 380
diff changeset
65 * Note, {@link #executeLite()} does not respect this setting.
192
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
66 *
194
344e8d7e4d6e Use common low to hi-level changeset api transformer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 192
diff changeset
67 * @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
68 * @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
69 * @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
70 */
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 public HgOutgoingCommand branch(String branch) {
194
344e8d7e4d6e Use common low to hi-level changeset api transformer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 192
diff changeset
72 if (branch == null) {
344e8d7e4d6e Use common low to hi-level changeset api transformer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 192
diff changeset
73 throw new IllegalArgumentException();
344e8d7e4d6e Use common low to hi-level changeset api transformer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 192
diff changeset
74 }
344e8d7e4d6e Use common low to hi-level changeset api transformer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 192
diff changeset
75 if (branches == null) {
344e8d7e4d6e Use common low to hi-level changeset api transformer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 192
diff changeset
76 branches = new TreeSet<String>();
344e8d7e4d6e Use common low to hi-level changeset api transformer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 192
diff changeset
77 }
344e8d7e4d6e Use common low to hi-level changeset api transformer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 192
diff changeset
78 branches.add(branch);
344e8d7e4d6e Use common low to hi-level changeset api transformer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 192
diff changeset
79 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
80 }
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 /**
192
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
83 * PLACEHOLDER, NOT IMPLEMENTED YET.
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
84 *
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
85 * @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
86 */
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 public HgOutgoingCommand 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
88 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
89 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
90 }
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
192
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
92 /**
194
344e8d7e4d6e Use common low to hi-level changeset api transformer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 192
diff changeset
93 * Lightweight check for outgoing changes.
344e8d7e4d6e Use common low to hi-level changeset api transformer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 192
diff changeset
94 * Reported changes are from any branch (limits set by {@link #branch(String)} are not taken into account.
192
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
95 *
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
96 * @return list on local nodes known to be missing at remote server
380
9517df1ef7ec Comments/javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 366
diff changeset
97 * @throws HgRemoteConnectionException when failed to communicate with remote repository
9517df1ef7ec Comments/javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 366
diff changeset
98 * @throws HgInvalidControlFileException if access to revlog index/data entry failed
9517df1ef7ec Comments/javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 366
diff changeset
99 * @throws CancelledException if execution of the command was cancelled
192
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
100 */
366
189dc6dc1c3e Use exceptions to expose errors reading mercurial data
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 354
diff changeset
101 public List<Nodeid> executeLite() throws HgRemoteConnectionException, HgInvalidControlFileException, CancelledException {
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
102 final ProgressSupport ps = getProgressSupport(null);
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
103 try {
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
104 ps.start(10);
322
d68dcb3b5f49 Propagate command's CancelSupport to low-level API. CancelSupport from context got priority over one from command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 295
diff changeset
105 return getComparator(new ProgressSupport.Sub(ps, 5), getCancelSupport(null, true)).getLocalOnlyRevisions();
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
106 } finally {
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
107 ps.done();
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
108 }
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
109 }
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
110
192
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 * Complete information about outgoing changes
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
113 *
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
114 * @param handler delegate to process changes
380
9517df1ef7ec Comments/javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 366
diff changeset
115 * @throws HgRemoteConnectionException when failed to communicate with remote repository
9517df1ef7ec Comments/javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 366
diff changeset
116 * @throws HgInvalidControlFileException if access to revlog index/data entry failed
9517df1ef7ec Comments/javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 366
diff changeset
117 * @throws HgCallbackTargetException to re-throw exception from the handler
9517df1ef7ec Comments/javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 366
diff changeset
118 * @throws CancelledException if execution of the command was cancelled
192
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
119 */
354
5f9073eabf06 Propagate errors with exceptions up to a end client
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
120 public void executeFull(final HgChangesetHandler handler) throws HgRemoteConnectionException, HgInvalidControlFileException, HgCallbackTargetException, CancelledException {
192
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
121 if (handler == null) {
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
122 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
123 }
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
124 final ProgressSupport ps = getProgressSupport(handler);
322
d68dcb3b5f49 Propagate command's CancelSupport to low-level API. CancelSupport from context got priority over one from command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 295
diff changeset
125 final CancelSupport cs = getCancelSupport(handler, true);
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
126 try {
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
127 ps.start(-1);
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
128 ChangesetTransformer inspector = new ChangesetTransformer(localRepo, handler, getParentHelper(), ps, cs);
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
129 inspector.limitBranches(branches);
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
130 getComparator(new ProgressSupport.Sub(ps, 1), cs).visitLocalOnlyRevisions(inspector);
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
131 inspector.checkFailure();
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
132 } finally {
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
133 ps.done();
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
134 }
192
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
366
189dc6dc1c3e Use exceptions to expose errors reading mercurial data
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 354
diff changeset
137 private RepositoryComparator getComparator(ProgressSupport ps, CancelSupport cs) throws HgRemoteConnectionException, HgInvalidControlFileException, CancelledException {
192
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
138 if (remoteRepo == null) {
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
139 throw new IllegalArgumentException("Shall specify remote repository to compare against");
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 if (comparator == null) {
195
c9b305df0b89 Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 194
diff changeset
142 comparator = new RepositoryComparator(getParentHelper(), remoteRepo);
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
143 comparator.compare(ps, cs);
192
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
144 }
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
145 return comparator;
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
146 }
195
c9b305df0b89 Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 194
diff changeset
147
366
189dc6dc1c3e Use exceptions to expose errors reading mercurial data
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 354
diff changeset
148 private HgChangelog.ParentWalker getParentHelper() throws HgInvalidControlFileException {
195
c9b305df0b89 Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 194
diff changeset
149 if (parentHelper == null) {
c9b305df0b89 Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 194
diff changeset
150 parentHelper = localRepo.getChangelog().new ParentWalker();
c9b305df0b89 Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 194
diff changeset
151 parentHelper.init();
c9b305df0b89 Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 194
diff changeset
152 }
c9b305df0b89 Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 194
diff changeset
153 return parentHelper;
c9b305df0b89 Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 194
diff changeset
154 }
c9b305df0b89 Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 194
diff changeset
155
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
156 }