annotate src/org/tmatesoft/hg/internal/RepositoryComparator.java @ 654:12a4f60ea972

1) Console push tool. 2) Pass class to blame into FileUtils
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Wed, 03 Jul 2013 15:11:40 +0200
parents 629a7370554c
children 822f3a83ff57
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 /*
628
6526d8adbc0f Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 432
diff changeset
2 * Copyright (c) 2011-2013 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.internal;
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 static org.tmatesoft.hg.core.Nodeid.NULL;
cd3371670f0b Refactor incoming and outgoing code to be shared with RepositoryComparator. Placeholders for in/out commands. Refactor common remote lookup code
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
20
192
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 184
diff changeset
21 import java.util.ArrayList;
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: 383
diff changeset
22 import java.util.Arrays;
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.Collections;
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
24 import java.util.HashMap;
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
25 import java.util.HashSet;
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 import java.util.LinkedList;
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 java.util.List;
192
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 184
diff changeset
28 import java.util.ListIterator;
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 java.util.Map;
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 java.util.Map.Entry;
202
706bcc7cfee4 Basic test for HgIncomingCommand. Fix RepositoryComparator for cases when whole repository is unknown. Respect freshly initialized (empty) repositories in general.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 192
diff changeset
31 import java.util.Set;
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
215
41a778e3fd31 Issue 5: Facilities for progress and cancellation. More specific exceptions. Exceptions from callbacks as RuntimeException
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 210
diff changeset
33 import org.tmatesoft.hg.core.HgRemoteConnectionException;
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
34 import org.tmatesoft.hg.core.Nodeid;
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 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: 383
diff changeset
36 import org.tmatesoft.hg.repo.HgInvalidStateException;
628
6526d8adbc0f Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 432
diff changeset
37 import org.tmatesoft.hg.repo.HgParentChildMap;
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
38 import org.tmatesoft.hg.repo.HgRemoteRepository;
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 import org.tmatesoft.hg.repo.HgRemoteRepository.Range;
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 import org.tmatesoft.hg.repo.HgRemoteRepository.RemoteBranch;
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 import org.tmatesoft.hg.util.CancelSupport;
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 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
43 import org.tmatesoft.hg.util.ProgressSupport;
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
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
45 /**
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 *
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 * @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
48 * @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
49 */
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 public class RepositoryComparator {
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
206
63c9fed4369e Sample command line tools for incoming/outgoing to use commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 203
diff changeset
52 private final boolean debug = Boolean.parseBoolean(System.getProperty("hg4j.remote.debug"));
432
1fc0da631200 Revlog.ParentWalker helper class got promoted as TLC, renamed to HgParentChildMap
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 425
diff changeset
53 private final HgParentChildMap<HgChangelog> localRepo;
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
54 private final HgRemoteRepository remoteRepo;
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
55 private List<Nodeid> common;
645
14dac192aa26 Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 628
diff changeset
56 private List<Nodeid> remoteHeads;
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
57
432
1fc0da631200 Revlog.ParentWalker helper class got promoted as TLC, renamed to HgParentChildMap
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 425
diff changeset
58 public RepositoryComparator(HgParentChildMap<HgChangelog> pwLocal, HgRemoteRepository hgRemote) {
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
59 localRepo = pwLocal;
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
60 remoteRepo = hgRemote;
cd3371670f0b Refactor incoming and outgoing code to be shared with RepositoryComparator. Placeholders for in/out commands. Refactor common remote lookup code
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
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
215
41a778e3fd31 Issue 5: Facilities for progress and cancellation. More specific exceptions. Exceptions from callbacks as RuntimeException
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 210
diff changeset
63 public RepositoryComparator compare(ProgressSupport progressSupport, CancelSupport cancelSupport) throws HgRemoteConnectionException, CancelledException {
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
64 cancelSupport.checkCancelled();
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
65 progressSupport.start(10);
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
66 common = Collections.unmodifiableList(findCommonWithRemote());
192
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 184
diff changeset
67 // sanity check
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 184
diff changeset
68 for (Nodeid n : common) {
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 184
diff changeset
69 if (!localRepo.knownNode(n)) {
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: 383
diff changeset
70 throw new HgInvalidStateException("Unknown node reported as common:" + n);
192
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 184
diff changeset
71 }
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 184
diff changeset
72 }
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
73 progressSupport.done();
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
74 return this;
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
75 }
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
76
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
77 public List<Nodeid> getCommon() {
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
78 if (common == null) {
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: 383
diff changeset
79 throw new HgInvalidStateException("Call #compare(Object) first");
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 return common;
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: 184
diff changeset
83
645
14dac192aa26 Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 628
diff changeset
84 public List<Nodeid> getRemoteHeads() {
14dac192aa26 Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 628
diff changeset
85 assert remoteHeads != null;
14dac192aa26 Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 628
diff changeset
86 return remoteHeads;
14dac192aa26 Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 628
diff changeset
87 }
14dac192aa26 Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 628
diff changeset
88
192
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 184
diff changeset
89 /**
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 184
diff changeset
90 * @return revisions that are children of common entries, i.e. revisions that are present on the local server and not on remote.
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 184
diff changeset
91 */
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 184
diff changeset
92 public List<Nodeid> getLocalOnlyRevisions() {
645
14dac192aa26 Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 628
diff changeset
93 final List<Nodeid> c = getCommon();
14dac192aa26 Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 628
diff changeset
94 if (c.isEmpty()) {
14dac192aa26 Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 628
diff changeset
95 return localRepo.all();
14dac192aa26 Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 628
diff changeset
96 } else {
654
12a4f60ea972 1) Console push tool. 2) Pass class to blame into FileUtils
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 653
diff changeset
97 final RevisionSet rsCommon = new RevisionSet(c);
12a4f60ea972 1) Console push tool. 2) Pass class to blame into FileUtils
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 653
diff changeset
98 final RevisionSet localHeads = new RevisionSet(localRepo.heads());
652
cd77bf51b562 Push: tests. Commit respects phases.new-commit setting. Fix outgoing when changes are not children of common (Issue 47)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 645
diff changeset
99 final List<Nodeid> commonChildren = localRepo.childrenOf(c);
cd77bf51b562 Push: tests. Commit respects phases.new-commit setting. Fix outgoing when changes are not children of common (Issue 47)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 645
diff changeset
100 final RevisionSet rsCommonChildren = new RevisionSet(commonChildren);
654
12a4f60ea972 1) Console push tool. 2) Pass class to blame into FileUtils
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 653
diff changeset
101 // check if there's any revision in the repository that doesn't trace to common
12a4f60ea972 1) Console push tool. 2) Pass class to blame into FileUtils
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 653
diff changeset
102 // e.g. branches from one of common ancestors
12a4f60ea972 1) Console push tool. 2) Pass class to blame into FileUtils
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 653
diff changeset
103 RevisionSet headsNotFromCommon = localHeads.subtract(rsCommonChildren).subtract(rsCommon);
652
cd77bf51b562 Push: tests. Commit respects phases.new-commit setting. Fix outgoing when changes are not children of common (Issue 47)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 645
diff changeset
104 if (headsNotFromCommon.isEmpty()) {
cd77bf51b562 Push: tests. Commit respects phases.new-commit setting. Fix outgoing when changes are not children of common (Issue 47)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 645
diff changeset
105 return commonChildren;
cd77bf51b562 Push: tests. Commit respects phases.new-commit setting. Fix outgoing when changes are not children of common (Issue 47)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 645
diff changeset
106 }
cd77bf51b562 Push: tests. Commit respects phases.new-commit setting. Fix outgoing when changes are not children of common (Issue 47)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 645
diff changeset
107 RevisionSet all = new RevisionSet(localRepo.all());
654
12a4f60ea972 1) Console push tool. 2) Pass class to blame into FileUtils
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 653
diff changeset
108 // need outgoing := ancestors(missing) - ancestors(common):
652
cd77bf51b562 Push: tests. Commit respects phases.new-commit setting. Fix outgoing when changes are not children of common (Issue 47)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 645
diff changeset
109 RevisionSet rsAncestors = all.ancestors(headsNotFromCommon, localRepo);
cd77bf51b562 Push: tests. Commit respects phases.new-commit setting. Fix outgoing when changes are not children of common (Issue 47)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 645
diff changeset
110 // #ancestors gives only parents, we need terminating children as well
cd77bf51b562 Push: tests. Commit respects phases.new-commit setting. Fix outgoing when changes are not children of common (Issue 47)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 645
diff changeset
111 rsAncestors = rsAncestors.union(headsNotFromCommon);
cd77bf51b562 Push: tests. Commit respects phases.new-commit setting. Fix outgoing when changes are not children of common (Issue 47)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 645
diff changeset
112 final RevisionSet rsAncestorsCommon = all.ancestors(rsCommon, localRepo);
cd77bf51b562 Push: tests. Commit respects phases.new-commit setting. Fix outgoing when changes are not children of common (Issue 47)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 645
diff changeset
113 RevisionSet outgoing = rsAncestors.subtract(rsAncestorsCommon).subtract(rsCommon);
654
12a4f60ea972 1) Console push tool. 2) Pass class to blame into FileUtils
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 653
diff changeset
114 // outgoing keeps children that spined off prior to common revisions
652
cd77bf51b562 Push: tests. Commit respects phases.new-commit setting. Fix outgoing when changes are not children of common (Issue 47)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 645
diff changeset
115 return outgoing.union(rsCommonChildren).asList();
645
14dac192aa26 Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 628
diff changeset
116 }
192
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 184
diff changeset
117 }
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 184
diff changeset
118
215
41a778e3fd31 Issue 5: Facilities for progress and cancellation. More specific exceptions. Exceptions from callbacks as RuntimeException
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 210
diff changeset
119 private List<Nodeid> findCommonWithRemote() throws HgRemoteConnectionException {
645
14dac192aa26 Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 628
diff changeset
120 remoteHeads = remoteRepo.heads();
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
121 LinkedList<Nodeid> resultCommon = new LinkedList<Nodeid>(); // these remotes are known in local
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
122 LinkedList<Nodeid> toQuery = new LinkedList<Nodeid>(); // these need further queries to find common
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
123 for (Nodeid rh : remoteHeads) {
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
124 if (localRepo.knownNode(rh)) {
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
125 resultCommon.add(rh);
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
126 } else {
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
127 toQuery.add(rh);
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
128 }
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
129 }
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
130 if (toQuery.isEmpty()) {
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
131 return resultCommon;
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
132 }
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
133 LinkedList<RemoteBranch> checkUp2Head = new LinkedList<RemoteBranch>(); // branch.root and branch.head are of interest only.
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
134 // these are branches with unknown head but known root, which might not be the last common known,
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
135 // i.e. there might be children changeset that are also available at remote, [..?..common-head..remote-head] - need to
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
136 // scroll up to common head.
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
137 while (!toQuery.isEmpty()) {
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
138 List<RemoteBranch> remoteBranches = remoteRepo.branches(toQuery); //head, root, first parent, second parent
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
139 toQuery.clear();
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
140 while(!remoteBranches.isEmpty()) {
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
141 RemoteBranch rb = remoteBranches.remove(0);
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
142 // I assume branches remote call gives branches with head equal to what I pass there, i.e.
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
143 // that I don't need to check whether rb.head is unknown.
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
144 if (localRepo.knownNode(rb.root)) {
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
145 // we known branch start, common head is somewhere in its descendants line
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 checkUp2Head.add(rb);
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
147 } else {
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
148 // dig deeper in the history, if necessary
274
9fb50c04f03c Use Nodeid.isNull check instead of NULL.equals
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 215
diff changeset
149 if (!rb.p1.isNull() && !localRepo.knownNode(rb.p1)) {
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
150 toQuery.add(rb.p1);
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 }
274
9fb50c04f03c Use Nodeid.isNull check instead of NULL.equals
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 215
diff changeset
152 if (!rb.p2.isNull() && !localRepo.knownNode(rb.p2)) {
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
153 toQuery.add(rb.p2);
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
154 }
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
155 }
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 }
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
157 }
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
158 // can't check nodes between checkUp2Head element and local heads, remote might have distinct descendants sequence
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
159 for (RemoteBranch rb : checkUp2Head) {
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
160 // rb.root is known 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
161 List<Nodeid> remoteRevisions = remoteRepo.between(rb.head, rb.root);
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
162 if (remoteRevisions.isEmpty()) {
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
163 // head is immediate child
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
164 resultCommon.add(rb.root);
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
165 } else {
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
166 // between gives result from head to root, I'd like to go in reverse direction
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
167 Collections.reverse(remoteRevisions);
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
168 Nodeid root = rb.root;
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
169 while(!remoteRevisions.isEmpty()) {
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
170 Nodeid n = remoteRevisions.remove(0);
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
171 if (localRepo.knownNode(n)) {
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
172 if (remoteRevisions.isEmpty()) {
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
173 // this is the last known node before an unknown
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
174 resultCommon.add(n);
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
175 break;
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
176 }
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
177 if (remoteRevisions.size() == 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
178 // there's only one left between known n and unknown head
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
179 // this check is to save extra between query, not really essential
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
180 Nodeid last = remoteRevisions.remove(0);
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
181 resultCommon.add(localRepo.knownNode(last) ? last : n);
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
182 break;
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
183 }
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
184 // might get handy for next between query, to narrow search down
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
185 root = n;
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
186 } else {
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
187 remoteRevisions = remoteRepo.between(n, root);
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
188 Collections.reverse(remoteRevisions);
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
189 if (remoteRevisions.isEmpty()) {
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
190 resultCommon.add(root);
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
191 }
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 }
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
194 }
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
195 }
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
196 // TODO ensure unique elements in the list
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
197 return resultCommon;
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
198 }
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
199
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
200 // somewhat similar to Outgoing.findCommonWithRemote()
215
41a778e3fd31 Issue 5: Facilities for progress and cancellation. More specific exceptions. Exceptions from callbacks as RuntimeException
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 210
diff changeset
201 public List<BranchChain> calculateMissingBranches() throws HgRemoteConnectionException {
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
202 List<Nodeid> remoteHeads = remoteRepo.heads();
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
203 LinkedList<Nodeid> common = new LinkedList<Nodeid>(); // these remotes are known in local
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
204 LinkedList<Nodeid> toQuery = new LinkedList<Nodeid>(); // these need further queries to find common
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
205 for (Nodeid rh : remoteHeads) {
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
206 if (localRepo.knownNode(rh)) {
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
207 common.add(rh);
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
208 } else {
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
209 toQuery.add(rh);
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
210 }
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
211 }
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
212 if (toQuery.isEmpty()) {
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
213 return Collections.emptyList(); // no 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
214 }
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
215 LinkedList<BranchChain> branches2load = new LinkedList<BranchChain>(); // return value
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
216 // detailed comments are in Outgoing.findCommonWithRemote
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
217 LinkedList<RemoteBranch> checkUp2Head = new LinkedList<RemoteBranch>();
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
218 // records relation between branch head and its parent branch, if any
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
219 HashMap<Nodeid, BranchChain> head2chain = new HashMap<Nodeid, BranchChain>();
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
220 while (!toQuery.isEmpty()) {
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
221 List<RemoteBranch> remoteBranches = remoteRepo.branches(toQuery); //head, root, first parent, second parent
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
222 toQuery.clear();
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
223 while(!remoteBranches.isEmpty()) {
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
224 RemoteBranch rb = remoteBranches.remove(0);
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
225 BranchChain chainElement = head2chain.get(rb.head);
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
226 if (chainElement == null) {
cd3371670f0b Refactor incoming and outgoing code to be shared with RepositoryComparator. Placeholders for in/out commands. Refactor common remote lookup code
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
227 chainElement = new BranchChain(rb.head);
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
228 // record this unknown branch to download later
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
229 branches2load.add(chainElement);
184
ec1820f64d2b Complete incoming cmdline client, with both lite (revisions) and complete (full changeset) information dump
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
230 // the only chance we'll need chainElement in the head2chain is when we know this branch's root
ec1820f64d2b Complete incoming cmdline client, with both lite (revisions) and complete (full changeset) information dump
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
231 head2chain.put(rb.head, chainElement);
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
232 }
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
233 if (localRepo.knownNode(rb.root)) {
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
234 // we known branch start, common head is somewhere in its descendants line
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
235 checkUp2Head.add(rb);
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
236 } else {
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
237 chainElement.branchRoot = rb.root;
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
238 // dig deeper in the history, if necessary
274
9fb50c04f03c Use Nodeid.isNull check instead of NULL.equals
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 215
diff changeset
239 boolean hasP1 = !rb.p1.isNull(), hasP2 = !rb.p2.isNull();
202
706bcc7cfee4 Basic test for HgIncomingCommand. Fix RepositoryComparator for cases when whole repository is unknown. Respect freshly initialized (empty) repositories in general.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 192
diff changeset
240 if (hasP1 && !localRepo.knownNode(rb.p1)) {
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
241 toQuery.add(rb.p1);
209
9ce3b26798c4 Few branches (distinct BranchChains from distinct heads) may end up with same nodes. Building BC structure fixed to reuse chain elements
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 207
diff changeset
242 // we might have seen parent node already, and recorded it as a branch chain
9ce3b26798c4 Few branches (distinct BranchChains from distinct heads) may end up with same nodes. Building BC structure fixed to reuse chain elements
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 207
diff changeset
243 // we shall reuse existing BC to get it completely initializer (head2chain map
9ce3b26798c4 Few branches (distinct BranchChains from distinct heads) may end up with same nodes. Building BC structure fixed to reuse chain elements
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 207
diff changeset
244 // on second put with the same key would leave first BC uninitialized.
9ce3b26798c4 Few branches (distinct BranchChains from distinct heads) may end up with same nodes. Building BC structure fixed to reuse chain elements
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 207
diff changeset
245
9ce3b26798c4 Few branches (distinct BranchChains from distinct heads) may end up with same nodes. Building BC structure fixed to reuse chain elements
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 207
diff changeset
246 // It seems there's no reason to be affraid (XXX although shall double-check)
9ce3b26798c4 Few branches (distinct BranchChains from distinct heads) may end up with same nodes. Building BC structure fixed to reuse chain elements
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 207
diff changeset
247 // that BC's chain would get corrupt (its p1 and p2 fields assigned twice with different values)
9ce3b26798c4 Few branches (distinct BranchChains from distinct heads) may end up with same nodes. Building BC structure fixed to reuse chain elements
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 207
diff changeset
248 // as parents are always the same (and likely, BC that is common would be the last unknown)
9ce3b26798c4 Few branches (distinct BranchChains from distinct heads) may end up with same nodes. Building BC structure fixed to reuse chain elements
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 207
diff changeset
249 BranchChain bc = head2chain.get(rb.p1);
9ce3b26798c4 Few branches (distinct BranchChains from distinct heads) may end up with same nodes. Building BC structure fixed to reuse chain elements
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 207
diff changeset
250 if (bc == null) {
9ce3b26798c4 Few branches (distinct BranchChains from distinct heads) may end up with same nodes. Building BC structure fixed to reuse chain elements
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 207
diff changeset
251 head2chain.put(rb.p1, bc = new BranchChain(rb.p1));
9ce3b26798c4 Few branches (distinct BranchChains from distinct heads) may end up with same nodes. Building BC structure fixed to reuse chain elements
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 207
diff changeset
252 }
210
6a2481866491 Wrong parent assignment when building branch chain
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 209
diff changeset
253 chainElement.p1 = bc;
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
254 }
202
706bcc7cfee4 Basic test for HgIncomingCommand. Fix RepositoryComparator for cases when whole repository is unknown. Respect freshly initialized (empty) repositories in general.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 192
diff changeset
255 if (hasP2 && !localRepo.knownNode(rb.p2)) {
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
256 toQuery.add(rb.p2);
209
9ce3b26798c4 Few branches (distinct BranchChains from distinct heads) may end up with same nodes. Building BC structure fixed to reuse chain elements
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 207
diff changeset
257 BranchChain bc = head2chain.get(rb.p2);
9ce3b26798c4 Few branches (distinct BranchChains from distinct heads) may end up with same nodes. Building BC structure fixed to reuse chain elements
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 207
diff changeset
258 if (bc == null) {
9ce3b26798c4 Few branches (distinct BranchChains from distinct heads) may end up with same nodes. Building BC structure fixed to reuse chain elements
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 207
diff changeset
259 head2chain.put(rb.p2, bc = new BranchChain(rb.p2));
9ce3b26798c4 Few branches (distinct BranchChains from distinct heads) may end up with same nodes. Building BC structure fixed to reuse chain elements
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 207
diff changeset
260 }
9ce3b26798c4 Few branches (distinct BranchChains from distinct heads) may end up with same nodes. Building BC structure fixed to reuse chain elements
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 207
diff changeset
261 chainElement.p2 = bc;
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
262 }
202
706bcc7cfee4 Basic test for HgIncomingCommand. Fix RepositoryComparator for cases when whole repository is unknown. Respect freshly initialized (empty) repositories in general.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 192
diff changeset
263 if (!hasP1 && !hasP2) {
706bcc7cfee4 Basic test for HgIncomingCommand. Fix RepositoryComparator for cases when whole repository is unknown. Respect freshly initialized (empty) repositories in general.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 192
diff changeset
264 // special case, when we do incoming against blank repository, chainElement.branchRoot
706bcc7cfee4 Basic test for HgIncomingCommand. Fix RepositoryComparator for cases when whole repository is unknown. Respect freshly initialized (empty) repositories in general.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 192
diff changeset
265 // is first unknown element (revision 0). We need to add another fake BranchChain
706bcc7cfee4 Basic test for HgIncomingCommand. Fix RepositoryComparator for cases when whole repository is unknown. Respect freshly initialized (empty) repositories in general.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 192
diff changeset
266 // to fill the promise that terminal BranchChain has branchRoot that is known both locally and remotely
706bcc7cfee4 Basic test for HgIncomingCommand. Fix RepositoryComparator for cases when whole repository is unknown. Respect freshly initialized (empty) repositories in general.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 192
diff changeset
267 BranchChain fake = new BranchChain(NULL);
706bcc7cfee4 Basic test for HgIncomingCommand. Fix RepositoryComparator for cases when whole repository is unknown. Respect freshly initialized (empty) repositories in general.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 192
diff changeset
268 fake.branchRoot = NULL;
706bcc7cfee4 Basic test for HgIncomingCommand. Fix RepositoryComparator for cases when whole repository is unknown. Respect freshly initialized (empty) repositories in general.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 192
diff changeset
269 chainElement.p1 = chainElement.p2 = fake;
706bcc7cfee4 Basic test for HgIncomingCommand. Fix RepositoryComparator for cases when whole repository is unknown. Respect freshly initialized (empty) repositories in general.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 192
diff changeset
270 }
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
271 }
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
272 }
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
273 }
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
274 for (RemoteBranch rb : checkUp2Head) {
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
275 Nodeid h = rb.head;
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
276 Nodeid r = rb.root;
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
277 int watchdog = 1000;
184
ec1820f64d2b Complete incoming cmdline client, with both lite (revisions) and complete (full changeset) information dump
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
278 assert head2chain.containsKey(h);
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
279 BranchChain bc = head2chain.get(h);
184
ec1820f64d2b Complete incoming cmdline client, with both lite (revisions) and complete (full changeset) information dump
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 181
diff changeset
280 assert bc != null : h.toString();
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
281 // if we know branch root locally, there could be no parent branch chain elements.
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
282 assert bc.p1 == null;
cd3371670f0b Refactor incoming and outgoing code to be shared with RepositoryComparator. Placeholders for in/out commands. Refactor common remote lookup code
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
283 assert bc.p2 == null;
cd3371670f0b Refactor incoming and outgoing code to be shared with RepositoryComparator. Placeholders for in/out commands. Refactor common remote lookup code
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
284 do {
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
285 List<Nodeid> between = remoteRepo.between(h, r);
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
286 if (between.isEmpty()) {
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
287 bc.branchRoot = r;
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
288 break;
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
289 } else {
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
290 Collections.reverse(between);
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
291 for (Nodeid n : between) {
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
292 if (localRepo.knownNode(n)) {
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
293 r = n;
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
294 } else {
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
295 h = n;
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
296 break;
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
297 }
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
298 }
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
299 Nodeid lastInBetween = between.get(between.size() - 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
300 if (r.equals(lastInBetween)) {
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
301 bc.branchRoot = r;
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
302 break;
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
303 } else if (h.equals(lastInBetween)) { // the only chance for current head pointer to point to the sequence tail
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
304 // is when r is second from the between list end (iow, head,1,[2],4,8...,root)
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
305 bc.branchRoot = r;
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
306 break;
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
307 }
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
308 }
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
309 } while(--watchdog > 0);
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
310 if (watchdog == 0) {
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: 383
diff changeset
311 throw new HgInvalidStateException(String.format("Can't narrow down branch [%s, %s]", rb.head.shortNotation(), rb.root.shortNotation()));
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
312 }
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
313 }
206
63c9fed4369e Sample command line tools for incoming/outgoing to use commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 203
diff changeset
314 if (debug) {
207
1bf0a5af2d5d Conditional debug printouts
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 206
diff changeset
315 System.out.println("calculateMissingBranches:");
206
63c9fed4369e Sample command line tools for incoming/outgoing to use commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 203
diff changeset
316 for (BranchChain bc : branches2load) {
63c9fed4369e Sample command line tools for incoming/outgoing to use commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 203
diff changeset
317 bc.dump();
63c9fed4369e Sample command line tools for incoming/outgoing to use commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 203
diff changeset
318 }
63c9fed4369e Sample command line tools for incoming/outgoing to use commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 203
diff changeset
319 }
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
320 return branches2load;
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
321 }
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
322
202
706bcc7cfee4 Basic test for HgIncomingCommand. Fix RepositoryComparator for cases when whole repository is unknown. Respect freshly initialized (empty) repositories in general.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 192
diff changeset
323 // root and head (and all between) are unknown for each chain element but last (terminal), which has known root (revision
706bcc7cfee4 Basic test for HgIncomingCommand. Fix RepositoryComparator for cases when whole repository is unknown. Respect freshly initialized (empty) repositories in general.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 192
diff changeset
324 // known to be locally and at remote server
706bcc7cfee4 Basic test for HgIncomingCommand. Fix RepositoryComparator for cases when whole repository is unknown. Respect freshly initialized (empty) repositories in general.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 192
diff changeset
325 // alternative would be to keep only unknown elements (so that promise of calculateMissingBranches would be 100% true), but that
706bcc7cfee4 Basic test for HgIncomingCommand. Fix RepositoryComparator for cases when whole repository is unknown. Respect freshly initialized (empty) repositories in general.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 192
diff changeset
326 // seems to complicate the method, while being useful only for the case when we ask incoming for an empty repository (i.e.
706bcc7cfee4 Basic test for HgIncomingCommand. Fix RepositoryComparator for cases when whole repository is unknown. Respect freshly initialized (empty) repositories in general.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 192
diff changeset
327 // where branch chain return all nodes, -1..tip.
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
328 public static final class BranchChain {
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
329 // when we construct a chain, we know head which is missing locally, hence init it right away.
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
330 // as for root (branch unknown start), we might happen to have one locally, and need further digging to find out right branch start
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
331 public final Nodeid branchHead;
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
332 public Nodeid branchRoot;
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
333 // either of these can be null, or both.
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
334 // although RemoteBranch has either both parents null, or both non-null, when we construct a chain
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
335 // we might encounter that we locally know one of branch's parent, hence in the chain corresponding field will be blank.
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
336 public BranchChain p1;
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
337 public BranchChain p2;
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
338
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
339 public BranchChain(Nodeid head) {
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
340 assert head != null;
cd3371670f0b Refactor incoming and outgoing code to be shared with RepositoryComparator. Placeholders for in/out commands. Refactor common remote lookup code
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
341 branchHead = head;
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
342 }
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
343 public boolean isTerminal() {
202
706bcc7cfee4 Basic test for HgIncomingCommand. Fix RepositoryComparator for cases when whole repository is unknown. Respect freshly initialized (empty) repositories in general.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 192
diff changeset
344 return p1 == null && p2 == null; // either can be null, see comment above. Terminal is only when no way to descent
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
345 }
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
346
202
706bcc7cfee4 Basic test for HgIncomingCommand. Fix RepositoryComparator for cases when whole repository is unknown. Respect freshly initialized (empty) repositories in general.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 192
diff changeset
347 // true when this BranchChain is a branch that spans up to very start of the repository
706bcc7cfee4 Basic test for HgIncomingCommand. Fix RepositoryComparator for cases when whole repository is unknown. Respect freshly initialized (empty) repositories in general.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 192
diff changeset
348 // Thus, the only common revision is NULL, recorded in a fake BranchChain object shared between p1 and p2
706bcc7cfee4 Basic test for HgIncomingCommand. Fix RepositoryComparator for cases when whole repository is unknown. Respect freshly initialized (empty) repositories in general.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 192
diff changeset
349 /*package-local*/ boolean isRepoStart() {
274
9fb50c04f03c Use Nodeid.isNull check instead of NULL.equals
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 215
diff changeset
350 return p1 == p2 && p1 != null && p1.branchHead == p1.branchRoot && p1.branchHead.isNull();
202
706bcc7cfee4 Basic test for HgIncomingCommand. Fix RepositoryComparator for cases when whole repository is unknown. Respect freshly initialized (empty) repositories in general.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 192
diff changeset
351 }
706bcc7cfee4 Basic test for HgIncomingCommand. Fix RepositoryComparator for cases when whole repository is unknown. Respect freshly initialized (empty) repositories in general.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 192
diff changeset
352
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
353 @Override
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
354 public String toString() {
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
355 return String.format("BranchChain [%s, %s]", branchRoot, branchHead);
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
356 }
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
357
206
63c9fed4369e Sample command line tools for incoming/outgoing to use commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 203
diff changeset
358 void dump() {
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
359 System.out.println(toString());
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
360 internalDump(" ");
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
361 }
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
362
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
363 private void internalDump(String prefix) {
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
364 if (p1 != null) {
cd3371670f0b Refactor incoming and outgoing code to be shared with RepositoryComparator. Placeholders for in/out commands. Refactor common remote lookup code
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
365 System.out.println(prefix + p1.toString());
210
6a2481866491 Wrong parent assignment when building branch chain
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 209
diff changeset
366 } else if (p2 != null) {
6a2481866491 Wrong parent assignment when building branch chain
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 209
diff changeset
367 System.out.println(prefix + "NONE?!");
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
368 }
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
369 if (p2 != null) {
cd3371670f0b Refactor incoming and outgoing code to be shared with RepositoryComparator. Placeholders for in/out commands. Refactor common remote lookup code
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
370 System.out.println(prefix + p2.toString());
210
6a2481866491 Wrong parent assignment when building branch chain
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 209
diff changeset
371 } else if (p1 != null) {
6a2481866491 Wrong parent assignment when building branch chain
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 209
diff changeset
372 System.out.println(prefix + "NONE?!");
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
373 }
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
374 prefix += " ";
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
375 if (p1 != null) {
cd3371670f0b Refactor incoming and outgoing code to be shared with RepositoryComparator. Placeholders for in/out commands. Refactor common remote lookup code
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
376 p1.internalDump(prefix);
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
377 }
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
378 if (p2 != null) {
cd3371670f0b Refactor incoming and outgoing code to be shared with RepositoryComparator. Placeholders for in/out commands. Refactor common remote lookup code
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
379 p2.internalDump(prefix);
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
380 }
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
381 }
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
382 }
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
383
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
384 /**
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
385 * @return list of nodeids from branchRoot to branchHead, inclusive. IOW, first element of the list is always root of the branch
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
386 */
295
981f9f50bb6c Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 274
diff changeset
387 public List<Nodeid> completeBranch(final Nodeid branchRoot, final Nodeid branchHead) throws HgRemoteConnectionException {
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
388 class DataEntry {
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
389 public final Nodeid queryHead;
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
390 public final int headIndex;
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
391 public List<Nodeid> entries;
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
392
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
393 public DataEntry(Nodeid head, int index, List<Nodeid> data) {
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
394 queryHead = head;
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
395 headIndex = index;
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
396 entries = data;
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
397 }
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
398 };
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
399
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
400 List<Nodeid> initial = remoteRepo.between(branchHead, branchRoot);
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
401 Nodeid[] result = new Nodeid[1 + (1 << initial.size())];
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
402 result[0] = branchHead;
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
403 int rootIndex = -1; // index in the result, where to place branche's root.
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
404 if (initial.isEmpty()) {
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
405 rootIndex = 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
406 } else if (initial.size() == 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
407 rootIndex = 2;
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
408 }
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
409 LinkedList<DataEntry> datas = new LinkedList<DataEntry>();
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
410 // DataEntry in datas has entries list filled with 'between' data, whereas
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
411 // DataEntry in toQuery keeps only nodeid and its index, with entries to be initialized before
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
412 // moving to datas.
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
413 LinkedList<DataEntry> toQuery = new LinkedList<DataEntry>();
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
414 //
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
415 datas.add(new DataEntry(branchHead, 0, initial));
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
416 int totalQueries = 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
417 HashSet<Nodeid> queried = new HashSet<Nodeid>();
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
418 while(!datas.isEmpty()) {
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
419 // keep record of those planned to be queried next time we call between()
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
420 // although may keep these in queried, if really don't want separate collection
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
421 HashSet<Nodeid> scheduled = new HashSet<Nodeid>();
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
422 do {
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
423 DataEntry de = datas.removeFirst();
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
424 // populate result with discovered elements between de.qiueryRoot and branch's head
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
425 for (int i = 1, j = 0; j < de.entries.size(); i = i << 1, j++) {
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
426 int idx = de.headIndex + i;
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
427 result[idx] = de.entries.get(j);
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
428 }
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
429 // form next query entries from new unknown elements
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
430 if (de.entries.size() > 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
431 /* when entries has only one element, it means de.queryRoot was at head-2 position, and thus
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
432 * no new information can be obtained. E.g. when it's 2, it might be case of [0..4] query with
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
433 * [1,2] result, and we need one more query to get element 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
434 */
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
435 for (int i =1, j = 0; j < de.entries.size(); i = i<<1, j++) {
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
436 int idx = de.headIndex + i;
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
437 Nodeid x = de.entries.get(j);
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
438 if (!queried.contains(x) && !scheduled.contains(x) && (rootIndex == -1 || rootIndex - de.headIndex > 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
439 /*queries for elements right before head is senseless, but unless we know head's index, do it anyway*/
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
440 toQuery.add(new DataEntry(x, idx, null));
cd3371670f0b Refactor incoming and outgoing code to be shared with RepositoryComparator. Placeholders for in/out commands. Refactor common remote lookup code
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
441 scheduled.add(x);
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
442 }
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
443 }
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
444 }
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
445 } while (!datas.isEmpty());
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
446 if (!toQuery.isEmpty()) {
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
447 totalQueries++;
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
448 }
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
449 // for each query, create an between request range, keep record Range->DataEntry to know range's start index
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
450 LinkedList<HgRemoteRepository.Range> betweenBatch = new LinkedList<HgRemoteRepository.Range>();
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
451 HashMap<HgRemoteRepository.Range, DataEntry> rangeToEntry = new HashMap<HgRemoteRepository.Range, DataEntry>();
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
452 for (DataEntry de : toQuery) {
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
453 queried.add(de.queryHead);
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
454 HgRemoteRepository.Range r = new HgRemoteRepository.Range(branchRoot, de.queryHead);
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
455 betweenBatch.add(r);
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
456 rangeToEntry.put(r, de);
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
457 }
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
458 if (!betweenBatch.isEmpty()) {
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
459 Map<Range, List<Nodeid>> between = remoteRepo.between(betweenBatch);
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
460 for (Entry<Range, List<Nodeid>> e : between.entrySet()) {
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
461 DataEntry de = rangeToEntry.get(e.getKey());
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
462 assert de != null;
cd3371670f0b Refactor incoming and outgoing code to be shared with RepositoryComparator. Placeholders for in/out commands. Refactor common remote lookup code
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
463 de.entries = e.getValue();
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
464 if (rootIndex == -1 && de.entries.size() == 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
465 // returned sequence of length 1 means we used element from [head-2] as root
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
466 int numberOfElementsExcludingRootAndHead = de.headIndex + 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
467 rootIndex = numberOfElementsExcludingRootAndHead + 1;
207
1bf0a5af2d5d Conditional debug printouts
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 206
diff changeset
468 if (debug) {
1bf0a5af2d5d Conditional debug printouts
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 206
diff changeset
469 System.out.printf("On query %d found out exact number of missing elements: %d\n", totalQueries, numberOfElementsExcludingRootAndHead);
1bf0a5af2d5d Conditional debug printouts
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 206
diff changeset
470 }
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
471 }
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
472 datas.add(de); // queue up to record result and construct further requests
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
473 }
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
474 betweenBatch.clear();
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
475 rangeToEntry.clear();
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
476 }
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
477 toQuery.clear();
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
478 }
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
479 if (rootIndex == -1) {
425
48f993aa2f41 FIXMEs: exceptions, javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 423
diff changeset
480 throw new HgInvalidStateException("Shall not happen, provided between output is correct");
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
481 }
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
482 result[rootIndex] = branchRoot;
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
483 boolean resultOk = true;
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
484 LinkedList<Nodeid> fromRootToHead = new LinkedList<Nodeid>();
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: 383
diff changeset
485 IntVector missing = new IntVector();
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
486 for (int i = 0; i <= rootIndex; i++) {
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
487 Nodeid n = result[i];
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
488 if (n == null) {
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: 383
diff changeset
489 missing.add(i);
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
490 resultOk = 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
491 }
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
492 fromRootToHead.addFirst(n); // reverse order
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
493 }
207
1bf0a5af2d5d Conditional debug printouts
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 206
diff changeset
494 if (debug) {
1bf0a5af2d5d Conditional debug printouts
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 206
diff changeset
495 System.out.println("Total queries:" + totalQueries);
1bf0a5af2d5d Conditional debug printouts
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 206
diff changeset
496 }
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
497 if (!resultOk) {
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: 383
diff changeset
498 assert missing.size() > 0;
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: 383
diff changeset
499 // TODO post-1.0 perhaps, there's better alternative than HgInvalidStateException, e.g. HgDataFormatException?
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: 383
diff changeset
500 throw new HgInvalidStateException(String.format("Missing elements with indexes: %s", Arrays.toString(missing.toArray())));
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
501 }
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
502 return fromRootToHead;
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
503 }
192
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 184
diff changeset
504
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 184
diff changeset
505 /**
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 184
diff changeset
506 * returns in order from branch root to head
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 184
diff changeset
507 * for a non-empty BranchChain, shall return modifiable list
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 184
diff changeset
508 */
295
981f9f50bb6c Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 274
diff changeset
509 public List<Nodeid> visitBranches(BranchChain bc) throws HgRemoteConnectionException {
192
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 184
diff changeset
510 if (bc == null) {
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 184
diff changeset
511 return Collections.emptyList();
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 184
diff changeset
512 }
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 184
diff changeset
513 List<Nodeid> mine = completeBranch(bc.branchRoot, bc.branchHead);
202
706bcc7cfee4 Basic test for HgIncomingCommand. Fix RepositoryComparator for cases when whole repository is unknown. Respect freshly initialized (empty) repositories in general.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 192
diff changeset
514 if (bc.isTerminal() || bc.isRepoStart()) {
192
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 184
diff changeset
515 return mine;
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 184
diff changeset
516 }
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 184
diff changeset
517 List<Nodeid> parentBranch1 = visitBranches(bc.p1);
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 184
diff changeset
518 List<Nodeid> parentBranch2 = visitBranches(bc.p2);
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 184
diff changeset
519 // merge
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 184
diff changeset
520 LinkedList<Nodeid> merged = new LinkedList<Nodeid>();
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 184
diff changeset
521 ListIterator<Nodeid> i1 = parentBranch1.listIterator(), i2 = parentBranch2.listIterator();
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 184
diff changeset
522 while (i1.hasNext() && i2.hasNext()) {
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 184
diff changeset
523 Nodeid n1 = i1.next();
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 184
diff changeset
524 Nodeid n2 = i2.next();
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 184
diff changeset
525 if (n1.equals(n2)) {
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 184
diff changeset
526 merged.addLast(n1);
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 184
diff changeset
527 } else {
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 184
diff changeset
528 // first different => add both, and continue adding both tails sequentially
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 184
diff changeset
529 merged.add(n2);
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 184
diff changeset
530 merged.add(n1);
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 184
diff changeset
531 break;
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 184
diff changeset
532 }
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 184
diff changeset
533 }
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 184
diff changeset
534 // copy rest of second parent branch
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 184
diff changeset
535 while (i2.hasNext()) {
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 184
diff changeset
536 merged.add(i2.next());
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 184
diff changeset
537 }
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 184
diff changeset
538 // copy rest of first parent branch
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 184
diff changeset
539 while (i1.hasNext()) {
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 184
diff changeset
540 merged.add(i1.next());
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 184
diff changeset
541 }
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 184
diff changeset
542 //
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 184
diff changeset
543 ArrayList<Nodeid> rv = new ArrayList<Nodeid>(mine.size() + merged.size());
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 184
diff changeset
544 rv.addAll(merged);
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 184
diff changeset
545 rv.addAll(mine);
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 184
diff changeset
546 return rv;
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 184
diff changeset
547 }
e5407b5a586a Incoming and Outgoing commands are alive
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 184
diff changeset
548
202
706bcc7cfee4 Basic test for HgIncomingCommand. Fix RepositoryComparator for cases when whole repository is unknown. Respect freshly initialized (empty) repositories in general.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 192
diff changeset
549 public void collectKnownRoots(BranchChain bc, Set<Nodeid> result) {
706bcc7cfee4 Basic test for HgIncomingCommand. Fix RepositoryComparator for cases when whole repository is unknown. Respect freshly initialized (empty) repositories in general.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 192
diff changeset
550 if (bc == null) {
706bcc7cfee4 Basic test for HgIncomingCommand. Fix RepositoryComparator for cases when whole repository is unknown. Respect freshly initialized (empty) repositories in general.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 192
diff changeset
551 return;
706bcc7cfee4 Basic test for HgIncomingCommand. Fix RepositoryComparator for cases when whole repository is unknown. Respect freshly initialized (empty) repositories in general.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 192
diff changeset
552 }
706bcc7cfee4 Basic test for HgIncomingCommand. Fix RepositoryComparator for cases when whole repository is unknown. Respect freshly initialized (empty) repositories in general.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 192
diff changeset
553 if (bc.isTerminal()) {
706bcc7cfee4 Basic test for HgIncomingCommand. Fix RepositoryComparator for cases when whole repository is unknown. Respect freshly initialized (empty) repositories in general.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 192
diff changeset
554 result.add(bc.branchRoot);
706bcc7cfee4 Basic test for HgIncomingCommand. Fix RepositoryComparator for cases when whole repository is unknown. Respect freshly initialized (empty) repositories in general.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 192
diff changeset
555 return;
706bcc7cfee4 Basic test for HgIncomingCommand. Fix RepositoryComparator for cases when whole repository is unknown. Respect freshly initialized (empty) repositories in general.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 192
diff changeset
556 }
706bcc7cfee4 Basic test for HgIncomingCommand. Fix RepositoryComparator for cases when whole repository is unknown. Respect freshly initialized (empty) repositories in general.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 192
diff changeset
557 if (bc.isRepoStart()) {
706bcc7cfee4 Basic test for HgIncomingCommand. Fix RepositoryComparator for cases when whole repository is unknown. Respect freshly initialized (empty) repositories in general.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 192
diff changeset
558 return;
706bcc7cfee4 Basic test for HgIncomingCommand. Fix RepositoryComparator for cases when whole repository is unknown. Respect freshly initialized (empty) repositories in general.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 192
diff changeset
559 }
706bcc7cfee4 Basic test for HgIncomingCommand. Fix RepositoryComparator for cases when whole repository is unknown. Respect freshly initialized (empty) repositories in general.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 192
diff changeset
560 collectKnownRoots(bc.p1, result);
706bcc7cfee4 Basic test for HgIncomingCommand. Fix RepositoryComparator for cases when whole repository is unknown. Respect freshly initialized (empty) repositories in general.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 192
diff changeset
561 collectKnownRoots(bc.p2, result);
706bcc7cfee4 Basic test for HgIncomingCommand. Fix RepositoryComparator for cases when whole repository is unknown. Respect freshly initialized (empty) repositories in general.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 192
diff changeset
562 }
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
563 }