annotate src/org/tmatesoft/hg/core/HgOutgoingCommand.java @ 427:31a89587eb04

FIXMEs: consistent names, throws for commands and their handlers. Use of checked exceptions in hi-level api
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Thu, 29 Mar 2012 17:14:35 +0200
parents 9c9c442b5f2e
children 1fc0da631200
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;
427
31a89587eb04 FIXMEs: consistent names, throws for commands and their handlers. Use of checked exceptions in hi-level api
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 423
diff changeset
28 import org.tmatesoft.hg.repo.HgRuntimeException;
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
29 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
30 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
31 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
32
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 /**
192
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
34 * 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
35 *
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
36 * @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
37 * @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
38 */
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
39 public class HgOutgoingCommand extends HgAbstractCommand<HgOutgoingCommand> {
192
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
40
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
41 private final HgRepository localRepo;
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
42 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
43 @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
44 private boolean includeSubrepo;
192
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
45 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
46 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
47 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
48
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
49 public HgOutgoingCommand(HgRepository hgRepo) {
192
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
50 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
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
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
53 /**
192
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
54 * @param hgRemote remoteRepository to compare against
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
55 * @return <code>this</code> for convenience
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
56 */
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
57 public HgOutgoingCommand against(HgRemoteRepository hgRemote) {
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
58 remoteRepo = hgRemote;
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
59 comparator = null;
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
60 return this;
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
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
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 pull.
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).
419
7f136a3fa671 Clean javadoc to fix obvious warnings
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 380
diff changeset
66 * 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
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 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
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.
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
85 *
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 * @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
87 */
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 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
89 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
90 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
91 }
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
192
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
93 /**
194
344e8d7e4d6e Use common low to hi-level changeset api transformer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 192
diff changeset
94 * 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
95 * 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
96 *
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
97 * @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
98 * @throws HgRemoteConnectionException when failed to communicate with remote repository
427
31a89587eb04 FIXMEs: consistent names, throws for commands and their handlers. Use of checked exceptions in hi-level api
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 423
diff changeset
99 * @throws HgException subclass thereof to indicate specific issue with the command arguments or repository state
380
9517df1ef7ec Comments/javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 366
diff changeset
100 * @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
101 */
427
31a89587eb04 FIXMEs: consistent names, throws for commands and their handlers. Use of checked exceptions in hi-level api
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 423
diff changeset
102 public List<Nodeid> executeLite() throws HgRemoteConnectionException, HgException, 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
103 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
104 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
105 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
106 return getComparator(new ProgressSupport.Sub(ps, 5), getCancelSupport(null, true)).getLocalOnlyRevisions();
427
31a89587eb04 FIXMEs: consistent names, throws for commands and their handlers. Use of checked exceptions in hi-level api
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 423
diff changeset
107 } catch (HgRuntimeException ex) {
31a89587eb04 FIXMEs: consistent names, throws for commands and their handlers. Use of checked exceptions in hi-level api
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 423
diff changeset
108 throw new HgLibraryFailureException(ex);
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
109 } 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
110 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
111 }
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
112 }
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
113
192
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
114 /**
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
115 * Complete information about outgoing changes
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
116 *
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
117 * @param handler delegate to process changes
427
31a89587eb04 FIXMEs: consistent names, throws for commands and their handlers. Use of checked exceptions in hi-level api
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 423
diff changeset
118 * @throws HgCallbackTargetException propagated exception from the handler
380
9517df1ef7ec Comments/javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 366
diff changeset
119 * @throws HgRemoteConnectionException when failed to communicate with remote repository
427
31a89587eb04 FIXMEs: consistent names, throws for commands and their handlers. Use of checked exceptions in hi-level api
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 423
diff changeset
120 * @throws HgException subclass thereof to indicate specific issue with the command arguments or repository state
380
9517df1ef7ec Comments/javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 366
diff changeset
121 * @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
122 */
427
31a89587eb04 FIXMEs: consistent names, throws for commands and their handlers. Use of checked exceptions in hi-level api
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 423
diff changeset
123 public void executeFull(final HgChangesetHandler handler) throws HgCallbackTargetException, HgException, CancelledException {
192
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
124 if (handler == null) {
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
125 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
126 }
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
127 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
128 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
129 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
130 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
131 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
132 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
133 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
134 inspector.checkFailure();
427
31a89587eb04 FIXMEs: consistent names, throws for commands and their handlers. Use of checked exceptions in hi-level api
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 423
diff changeset
135 } catch (HgRuntimeException ex) {
31a89587eb04 FIXMEs: consistent names, throws for commands and their handlers. Use of checked exceptions in hi-level api
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 423
diff changeset
136 throw new HgLibraryFailureException(ex);
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
137 } 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
138 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
139 }
192
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
366
189dc6dc1c3e Use exceptions to expose errors reading mercurial data
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 354
diff changeset
142 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
143 if (remoteRepo == null) {
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
144 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
145 }
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
146 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
147 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
148 comparator.compare(ps, cs);
192
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 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
151 }
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
152
366
189dc6dc1c3e Use exceptions to expose errors reading mercurial data
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 354
diff changeset
153 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
154 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
155 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
156 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
157 }
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
158 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
159 }
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
160
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
161 }