Mercurial > hg4j
annotate src/org/tmatesoft/hg/repo/HgRemoteRepository.java @ 713:661e77dc88ba tip
Mac support: respect Mac alternatives of command-line arguments for common unix tools
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Sun, 03 Aug 2014 18:09:00 +0200 |
parents | a483b2b68a2e |
children |
rev | line source |
---|---|
170
71ddbf8603e8
Initial clone: populate given directory from a bundle. Everything but remote server access is there, albeit prototype code style
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
1 /* |
645
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
2 * Copyright (c) 2011-2013 TMate Software Ltd |
170
71ddbf8603e8
Initial clone: populate given directory from a bundle. Everything but remote server access is there, albeit prototype code style
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
3 * |
71ddbf8603e8
Initial clone: populate given directory from a bundle. Everything but remote server access is there, albeit prototype code style
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
4 * This program is free software; you can redistribute it and/or modify |
71ddbf8603e8
Initial clone: populate given directory from a bundle. Everything but remote server access is there, albeit prototype code style
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
5 * it under the terms of the GNU General Public License as published by |
71ddbf8603e8
Initial clone: populate given directory from a bundle. Everything but remote server access is there, albeit prototype code style
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
6 * the Free Software Foundation; version 2 of the License. |
71ddbf8603e8
Initial clone: populate given directory from a bundle. Everything but remote server access is there, albeit prototype code style
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
7 * |
71ddbf8603e8
Initial clone: populate given directory from a bundle. Everything but remote server access is there, albeit prototype code style
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
8 * This program is distributed in the hope that it will be useful, |
71ddbf8603e8
Initial clone: populate given directory from a bundle. Everything but remote server access is there, albeit prototype code style
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
71ddbf8603e8
Initial clone: populate given directory from a bundle. Everything but remote server access is there, albeit prototype code style
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
71ddbf8603e8
Initial clone: populate given directory from a bundle. Everything but remote server access is there, albeit prototype code style
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
11 * GNU General Public License for more details. |
71ddbf8603e8
Initial clone: populate given directory from a bundle. Everything but remote server access is there, albeit prototype code style
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
12 * |
71ddbf8603e8
Initial clone: populate given directory from a bundle. Everything but remote server access is there, albeit prototype code style
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
13 * For information on how to redistribute this software under |
71ddbf8603e8
Initial clone: populate given directory from a bundle. Everything but remote server access is there, albeit prototype code style
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
14 * the terms of a license other than GNU General Public License |
71ddbf8603e8
Initial clone: populate given directory from a bundle. Everything but remote server access is there, albeit prototype code style
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
15 * contact TMate Software at support@hg4j.com |
71ddbf8603e8
Initial clone: populate given directory from a bundle. Everything but remote server access is there, albeit prototype code style
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
16 */ |
71ddbf8603e8
Initial clone: populate given directory from a bundle. Everything but remote server access is there, albeit prototype code style
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
17 package org.tmatesoft.hg.repo; |
71ddbf8603e8
Initial clone: populate given directory from a bundle. Everything but remote server access is there, albeit prototype code style
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
18 |
687
9859fcea475d
Towards ssh remote repositories: refactor HgRemoteRepository - move http related code to HttpConnector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
685
diff
changeset
|
19 import static org.tmatesoft.hg.internal.remote.Connector.*; |
650
3b275cc2d2aa
Push: phase4 - settle local and remote phases, push updated phases regardless of server publishing state, do not push secret changesets
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
649
diff
changeset
|
20 import static org.tmatesoft.hg.util.Outcome.Kind.Failure; |
3b275cc2d2aa
Push: phase4 - settle local and remote phases, push updated phases regardless of server publishing state, do not push secret changesets
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
649
diff
changeset
|
21 import static org.tmatesoft.hg.util.Outcome.Kind.Success; |
456
909306e412e2
Refactor LogFacility and SessionContext, better API for both
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
441
diff
changeset
|
22 |
428
ead6c67f3319
Actual 'hello' check of the remote server/connection
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
425
diff
changeset
|
23 import java.io.BufferedReader; |
170
71ddbf8603e8
Initial clone: populate given directory from a bundle. Everything but remote server access is there, albeit prototype code style
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
24 import java.io.File; |
176
a8df7162ec75
Extracting complete branch using remote between call to detect incoming changes is done. Arguments reorderd in remote repo to better match Hg server ideology, not my mental convenience
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
172
diff
changeset
|
25 import java.io.IOException; |
179
da426c2fe1ec
Support for changegroup wire command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
178
diff
changeset
|
26 import java.io.InputStream; |
177
e10225daface
Use POST for long between queries. Batch between queries (pass multiple pairs to a server) to minimize number thereof
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
176
diff
changeset
|
27 import java.io.InputStreamReader; |
e10225daface
Use POST for long between queries. Batch between queries (pass multiple pairs to a server) to minimize number thereof
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
176
diff
changeset
|
28 import java.io.OutputStream; |
176
a8df7162ec75
Extracting complete branch using remote between call to detect incoming changes is done. Arguments reorderd in remote repo to better match Hg server ideology, not my mental convenience
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
172
diff
changeset
|
29 import java.io.StreamTokenizer; |
699
a483b2b68a2e
Provisional APIs and respective implementation for http, https and ssh remote repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
698
diff
changeset
|
30 import java.net.URI; |
178
62665d8f0686
Complete logic to discover all branches missing locally. Most of wire protocol in HgRemoteRepository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
177
diff
changeset
|
31 import java.util.ArrayList; |
428
ead6c67f3319
Actual 'hello' check of the remote server/connection
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
425
diff
changeset
|
32 import java.util.Arrays; |
176
a8df7162ec75
Extracting complete branch using remote between call to detect incoming changes is done. Arguments reorderd in remote repo to better match Hg server ideology, not my mental convenience
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
172
diff
changeset
|
33 import java.util.Collection; |
171
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
34 import java.util.Collections; |
428
ead6c67f3319
Actual 'hello' check of the remote server/connection
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
425
diff
changeset
|
35 import java.util.HashSet; |
177
e10225daface
Use POST for long between queries. Batch between queries (pass multiple pairs to a server) to minimize number thereof
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
176
diff
changeset
|
36 import java.util.Iterator; |
176
a8df7162ec75
Extracting complete branch using remote between call to detect incoming changes is done. Arguments reorderd in remote repo to better match Hg server ideology, not my mental convenience
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
172
diff
changeset
|
37 import java.util.LinkedHashMap; |
a8df7162ec75
Extracting complete branch using remote between call to detect incoming changes is done. Arguments reorderd in remote repo to better match Hg server ideology, not my mental convenience
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
172
diff
changeset
|
38 import java.util.LinkedList; |
170
71ddbf8603e8
Initial clone: populate given directory from a bundle. Everything but remote server access is there, albeit prototype code style
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
39 import java.util.List; |
176
a8df7162ec75
Extracting complete branch using remote between call to detect incoming changes is done. Arguments reorderd in remote repo to better match Hg server ideology, not my mental convenience
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
172
diff
changeset
|
40 import java.util.Map; |
428
ead6c67f3319
Actual 'hello' check of the remote server/connection
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
425
diff
changeset
|
41 import java.util.Set; |
176
a8df7162ec75
Extracting complete branch using remote between call to detect incoming changes is done. Arguments reorderd in remote repo to better match Hg server ideology, not my mental convenience
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
172
diff
changeset
|
42 |
699
a483b2b68a2e
Provisional APIs and respective implementation for http, https and ssh remote repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
698
diff
changeset
|
43 import org.tmatesoft.hg.auth.HgAuthFailedException; |
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:
179
diff
changeset
|
44 import org.tmatesoft.hg.core.HgBadArgumentException; |
645
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
45 import org.tmatesoft.hg.core.HgIOException; |
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
|
46 import org.tmatesoft.hg.core.HgRemoteConnectionException; |
425
48f993aa2f41
FIXMEs: exceptions, javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
423
diff
changeset
|
47 import org.tmatesoft.hg.core.HgRepositoryNotFoundException; |
170
71ddbf8603e8
Initial clone: populate given directory from a bundle. Everything but remote server access is there, albeit prototype code style
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
48 import org.tmatesoft.hg.core.Nodeid; |
295
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
274
diff
changeset
|
49 import org.tmatesoft.hg.core.SessionContext; |
687
9859fcea475d
Towards ssh remote repositories: refactor HgRemoteRepository - move http related code to HttpConnector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
685
diff
changeset
|
50 import org.tmatesoft.hg.internal.BundleSerializer; |
645
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
51 import org.tmatesoft.hg.internal.DataSerializer; |
650
3b275cc2d2aa
Push: phase4 - settle local and remote phases, push updated phases regardless of server publishing state, do not push secret changesets
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
649
diff
changeset
|
52 import org.tmatesoft.hg.internal.DataSerializer.OutputStreamSerializer; |
646
3b7d51ed4c65
Push: phase3 - update matching remote bookmarks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
645
diff
changeset
|
53 import org.tmatesoft.hg.internal.EncodingHelper; |
699
a483b2b68a2e
Provisional APIs and respective implementation for http, https and ssh remote repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
698
diff
changeset
|
54 import org.tmatesoft.hg.internal.Experimental; |
687
9859fcea475d
Towards ssh remote repositories: refactor HgRemoteRepository - move http related code to HttpConnector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
685
diff
changeset
|
55 import org.tmatesoft.hg.internal.FileUtils; |
645
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
56 import org.tmatesoft.hg.internal.Internals; |
456
909306e412e2
Refactor LogFacility and SessionContext, better API for both
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
441
diff
changeset
|
57 import org.tmatesoft.hg.internal.PropertyMarshal; |
687
9859fcea475d
Towards ssh remote repositories: refactor HgRemoteRepository - move http related code to HttpConnector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
685
diff
changeset
|
58 import org.tmatesoft.hg.internal.remote.Connector; |
698
822f3a83ff57
in, out and clone tests pass for ssh repositories. Infrastructure to decouple HgRemoteRepository from specific Connector implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
697
diff
changeset
|
59 import org.tmatesoft.hg.internal.remote.RemoteConnectorDescriptor; |
699
a483b2b68a2e
Provisional APIs and respective implementation for http, https and ssh remote repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
698
diff
changeset
|
60 import org.tmatesoft.hg.util.Adaptable; |
650
3b275cc2d2aa
Push: phase4 - settle local and remote phases, push updated phases regardless of server publishing state, do not push secret changesets
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
649
diff
changeset
|
61 import org.tmatesoft.hg.util.LogFacility.Severity; |
649
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
62 import org.tmatesoft.hg.util.Outcome; |
646
3b7d51ed4c65
Push: phase3 - update matching remote bookmarks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
645
diff
changeset
|
63 import org.tmatesoft.hg.util.Pair; |
170
71ddbf8603e8
Initial clone: populate given directory from a bundle. Everything but remote server access is there, albeit prototype code style
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
64 |
71ddbf8603e8
Initial clone: populate given directory from a bundle. Everything but remote server access is there, albeit prototype code style
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
65 /** |
71ddbf8603e8
Initial clone: populate given directory from a bundle. Everything but remote server access is there, albeit prototype code style
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
66 * WORK IN PROGRESS, DO NOT USE |
71ddbf8603e8
Initial clone: populate given directory from a bundle. Everything but remote server access is there, albeit prototype code style
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
67 * |
71ddbf8603e8
Initial clone: populate given directory from a bundle. Everything but remote server access is there, albeit prototype code style
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
68 * @see http://mercurial.selenic.com/wiki/WireProtocol |
646
3b7d51ed4c65
Push: phase3 - update matching remote bookmarks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
645
diff
changeset
|
69 * @see http://mercurial.selenic.com/wiki/HttpCommandProtocol |
170
71ddbf8603e8
Initial clone: populate given directory from a bundle. Everything but remote server access is there, albeit prototype code style
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
70 * |
71ddbf8603e8
Initial clone: populate given directory from a bundle. Everything but remote server access is there, albeit prototype code style
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
71 * @author Artem Tikhomirov |
71ddbf8603e8
Initial clone: populate given directory from a bundle. Everything but remote server access is there, albeit prototype code style
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
72 * @author TMate Software Ltd. |
71ddbf8603e8
Initial clone: populate given directory from a bundle. Everything but remote server access is there, albeit prototype code style
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
73 */ |
490
b3c16d1aede0
Refactoring: move HgRepository's implementation aspects to Internals (which is now its imlementation counterpart and primary repository class to be used by other parts of the library)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
456
diff
changeset
|
74 public class HgRemoteRepository implements SessionContext.Source { |
171
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
75 |
407
30922c728341
Better multiline log printout; options to tune default log output
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
383
diff
changeset
|
76 private final boolean debug; |
186
44a34baabea0
Clone refactored into a command. HgBundle needs means to control its lifecycle, to be deleted when no longer needed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
184
diff
changeset
|
77 private HgLookup lookupHelper; |
295
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
274
diff
changeset
|
78 private final SessionContext sessionContext; |
428
ead6c67f3319
Actual 'hello' check of the remote server/connection
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
425
diff
changeset
|
79 private Set<String> remoteCapabilities; |
687
9859fcea475d
Towards ssh remote repositories: refactor HgRemoteRepository - move http related code to HttpConnector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
685
diff
changeset
|
80 private Connector remote; |
428
ead6c67f3319
Actual 'hello' check of the remote server/connection
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
425
diff
changeset
|
81 |
698
822f3a83ff57
in, out and clone tests pass for ssh repositories. Infrastructure to decouple HgRemoteRepository from specific Connector implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
697
diff
changeset
|
82 HgRemoteRepository(SessionContext ctx, RemoteDescriptor rd) throws HgBadArgumentException { |
699
a483b2b68a2e
Provisional APIs and respective implementation for http, https and ssh remote repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
698
diff
changeset
|
83 RemoteConnectorDescriptor rcd = Adaptable.Factory.getAdapter(rd, RemoteConnectorDescriptor.class, null); |
a483b2b68a2e
Provisional APIs and respective implementation for http, https and ssh remote repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
698
diff
changeset
|
84 if (rcd == null) { |
698
822f3a83ff57
in, out and clone tests pass for ssh repositories. Infrastructure to decouple HgRemoteRepository from specific Connector implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
697
diff
changeset
|
85 throw new IllegalArgumentException(String.format("Present implementation supports remote connections via %s only", Connector.class.getName())); |
176
a8df7162ec75
Extracting complete branch using remote between call to detect incoming changes is done. Arguments reorderd in remote repo to better match Hg server ideology, not my mental convenience
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
172
diff
changeset
|
86 } |
295
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
274
diff
changeset
|
87 sessionContext = ctx; |
456
909306e412e2
Refactor LogFacility and SessionContext, better API for both
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
441
diff
changeset
|
88 debug = new PropertyMarshal(ctx).getBoolean("hg4j.remote.debug", false); |
699
a483b2b68a2e
Provisional APIs and respective implementation for http, https and ssh remote repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
698
diff
changeset
|
89 remote = rcd.createConnector(); |
a483b2b68a2e
Provisional APIs and respective implementation for http, https and ssh remote repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
698
diff
changeset
|
90 remote.init(rd /*sic! pass original*/, ctx, null); |
171
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
91 } |
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
92 |
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
|
93 public boolean isInvalid() throws HgRemoteConnectionException { |
646
3b7d51ed4c65
Push: phase3 - update matching remote bookmarks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
645
diff
changeset
|
94 initCapabilities(); |
428
ead6c67f3319
Actual 'hello' check of the remote server/connection
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
425
diff
changeset
|
95 return remoteCapabilities.isEmpty(); |
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:
179
diff
changeset
|
96 } |
cd3371670f0b
Refactor incoming and outgoing code to be shared with RepositoryComparator. Placeholders for in/out commands. Refactor common remote lookup code
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
179
diff
changeset
|
97 |
cd3371670f0b
Refactor incoming and outgoing code to be shared with RepositoryComparator. Placeholders for in/out commands. Refactor common remote lookup code
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
179
diff
changeset
|
98 /** |
cd3371670f0b
Refactor incoming and outgoing code to be shared with RepositoryComparator. Placeholders for in/out commands. Refactor common remote lookup code
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
179
diff
changeset
|
99 * @return human-readable address of the server, without user credentials or any other security information |
cd3371670f0b
Refactor incoming and outgoing code to be shared with RepositoryComparator. Placeholders for in/out commands. Refactor common remote lookup code
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
179
diff
changeset
|
100 */ |
cd3371670f0b
Refactor incoming and outgoing code to be shared with RepositoryComparator. Placeholders for in/out commands. Refactor common remote lookup code
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
179
diff
changeset
|
101 public String getLocation() { |
687
9859fcea475d
Towards ssh remote repositories: refactor HgRemoteRepository - move http related code to HttpConnector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
685
diff
changeset
|
102 return remote.getServerLocation(); |
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:
179
diff
changeset
|
103 } |
490
b3c16d1aede0
Refactoring: move HgRepository's implementation aspects to Internals (which is now its imlementation counterpart and primary repository class to be used by other parts of the library)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
456
diff
changeset
|
104 |
b3c16d1aede0
Refactoring: move HgRepository's implementation aspects to Internals (which is now its imlementation counterpart and primary repository class to be used by other parts of the library)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
456
diff
changeset
|
105 public SessionContext getSessionContext() { |
b3c16d1aede0
Refactoring: move HgRepository's implementation aspects to Internals (which is now its imlementation counterpart and primary repository class to be used by other parts of the library)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
456
diff
changeset
|
106 return sessionContext; |
b3c16d1aede0
Refactoring: move HgRepository's implementation aspects to Internals (which is now its imlementation counterpart and primary repository class to be used by other parts of the library)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
456
diff
changeset
|
107 } |
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:
179
diff
changeset
|
108 |
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
|
109 public List<Nodeid> heads() throws HgRemoteConnectionException { |
687
9859fcea475d
Towards ssh remote repositories: refactor HgRemoteRepository - move http related code to HttpConnector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
685
diff
changeset
|
110 if (isInvalid()) { |
9859fcea475d
Towards ssh remote repositories: refactor HgRemoteRepository - move http related code to HttpConnector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
685
diff
changeset
|
111 return Collections.emptyList(); |
9859fcea475d
Towards ssh remote repositories: refactor HgRemoteRepository - move http related code to HttpConnector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
685
diff
changeset
|
112 } |
178
62665d8f0686
Complete logic to discover all branches missing locally. Most of wire protocol in HgRemoteRepository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
177
diff
changeset
|
113 try { |
687
9859fcea475d
Towards ssh remote repositories: refactor HgRemoteRepository - move http related code to HttpConnector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
685
diff
changeset
|
114 remote.sessionBegin(); |
9859fcea475d
Towards ssh remote repositories: refactor HgRemoteRepository - move http related code to HttpConnector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
685
diff
changeset
|
115 InputStreamReader is = new InputStreamReader(remote.heads(), "US-ASCII"); |
178
62665d8f0686
Complete logic to discover all branches missing locally. Most of wire protocol in HgRemoteRepository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
177
diff
changeset
|
116 StreamTokenizer st = new StreamTokenizer(is); |
428
ead6c67f3319
Actual 'hello' check of the remote server/connection
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
425
diff
changeset
|
117 st.ordinaryChars('0', '9'); // wordChars performs |, hence need to 0 first |
178
62665d8f0686
Complete logic to discover all branches missing locally. Most of wire protocol in HgRemoteRepository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
177
diff
changeset
|
118 st.wordChars('0', '9'); |
62665d8f0686
Complete logic to discover all branches missing locally. Most of wire protocol in HgRemoteRepository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
177
diff
changeset
|
119 st.eolIsSignificant(false); |
62665d8f0686
Complete logic to discover all branches missing locally. Most of wire protocol in HgRemoteRepository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
177
diff
changeset
|
120 LinkedList<Nodeid> parseResult = new LinkedList<Nodeid>(); |
62665d8f0686
Complete logic to discover all branches missing locally. Most of wire protocol in HgRemoteRepository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
177
diff
changeset
|
121 while (st.nextToken() != StreamTokenizer.TT_EOF) { |
62665d8f0686
Complete logic to discover all branches missing locally. Most of wire protocol in HgRemoteRepository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
177
diff
changeset
|
122 parseResult.add(Nodeid.fromAscii(st.sval)); |
62665d8f0686
Complete logic to discover all branches missing locally. Most of wire protocol in HgRemoteRepository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
177
diff
changeset
|
123 } |
62665d8f0686
Complete logic to discover all branches missing locally. Most of wire protocol in HgRemoteRepository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
177
diff
changeset
|
124 return parseResult; |
62665d8f0686
Complete logic to discover all branches missing locally. Most of wire protocol in HgRemoteRepository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
177
diff
changeset
|
125 } catch (IOException ex) { |
687
9859fcea475d
Towards ssh remote repositories: refactor HgRemoteRepository - move http related code to HttpConnector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
685
diff
changeset
|
126 throw new HgRemoteConnectionException("Communication failure", ex).setRemoteCommand(CMD_HEADS).setServerInfo(getLocation()); |
645
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
127 } finally { |
687
9859fcea475d
Towards ssh remote repositories: refactor HgRemoteRepository - move http related code to HttpConnector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
685
diff
changeset
|
128 remote.sessionEnd(); |
178
62665d8f0686
Complete logic to discover all branches missing locally. Most of wire protocol in HgRemoteRepository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
177
diff
changeset
|
129 } |
171
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
130 } |
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
131 |
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
|
132 public List<Nodeid> between(Nodeid tip, Nodeid base) throws HgRemoteConnectionException { |
177
e10225daface
Use POST for long between queries. Batch between queries (pass multiple pairs to a server) to minimize number thereof
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
176
diff
changeset
|
133 Range r = new Range(base, tip); |
e10225daface
Use POST for long between queries. Batch between queries (pass multiple pairs to a server) to minimize number thereof
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
176
diff
changeset
|
134 // XXX shall handle errors like no range key in the returned map, not sure how. |
e10225daface
Use POST for long between queries. Batch between queries (pass multiple pairs to a server) to minimize number thereof
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
176
diff
changeset
|
135 return between(Collections.singletonList(r)).get(r); |
e10225daface
Use POST for long between queries. Batch between queries (pass multiple pairs to a server) to minimize number thereof
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
176
diff
changeset
|
136 } |
e10225daface
Use POST for long between queries. Batch between queries (pass multiple pairs to a server) to minimize number thereof
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
176
diff
changeset
|
137 |
e10225daface
Use POST for long between queries. Batch between queries (pass multiple pairs to a server) to minimize number thereof
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
176
diff
changeset
|
138 /** |
e10225daface
Use POST for long between queries. Batch between queries (pass multiple pairs to a server) to minimize number thereof
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
176
diff
changeset
|
139 * @param ranges |
e10225daface
Use POST for long between queries. Batch between queries (pass multiple pairs to a server) to minimize number thereof
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
176
diff
changeset
|
140 * @return map, where keys are input instances, values are corresponding server reply |
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
|
141 * @throws HgRemoteConnectionException |
177
e10225daface
Use POST for long between queries. Batch between queries (pass multiple pairs to a server) to minimize number thereof
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
176
diff
changeset
|
142 */ |
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
|
143 public Map<Range, List<Nodeid>> between(Collection<Range> ranges) throws HgRemoteConnectionException { |
687
9859fcea475d
Towards ssh remote repositories: refactor HgRemoteRepository - move http related code to HttpConnector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
685
diff
changeset
|
144 if (ranges.isEmpty() || isInvalid()) { |
177
e10225daface
Use POST for long between queries. Batch between queries (pass multiple pairs to a server) to minimize number thereof
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
176
diff
changeset
|
145 return Collections.emptyMap(); |
e10225daface
Use POST for long between queries. Batch between queries (pass multiple pairs to a server) to minimize number thereof
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
176
diff
changeset
|
146 } |
e10225daface
Use POST for long between queries. Batch between queries (pass multiple pairs to a server) to minimize number thereof
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
176
diff
changeset
|
147 LinkedHashMap<Range, List<Nodeid>> rv = new LinkedHashMap<HgRemoteRepository.Range, List<Nodeid>>(ranges.size() * 4 / 3); |
176
a8df7162ec75
Extracting complete branch using remote between call to detect incoming changes is done. Arguments reorderd in remote repo to better match Hg server ideology, not my mental convenience
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
172
diff
changeset
|
148 try { |
687
9859fcea475d
Towards ssh remote repositories: refactor HgRemoteRepository - move http related code to HttpConnector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
685
diff
changeset
|
149 remote.sessionBegin(); |
9859fcea475d
Towards ssh remote repositories: refactor HgRemoteRepository - move http related code to HttpConnector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
685
diff
changeset
|
150 InputStreamReader is = new InputStreamReader(remote.between(ranges), "US-ASCII"); |
176
a8df7162ec75
Extracting complete branch using remote between call to detect incoming changes is done. Arguments reorderd in remote repo to better match Hg server ideology, not my mental convenience
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
172
diff
changeset
|
151 StreamTokenizer st = new StreamTokenizer(is); |
a8df7162ec75
Extracting complete branch using remote between call to detect incoming changes is done. Arguments reorderd in remote repo to better match Hg server ideology, not my mental convenience
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
172
diff
changeset
|
152 st.ordinaryChars('0', '9'); |
a8df7162ec75
Extracting complete branch using remote between call to detect incoming changes is done. Arguments reorderd in remote repo to better match Hg server ideology, not my mental convenience
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
172
diff
changeset
|
153 st.wordChars('0', '9'); |
177
e10225daface
Use POST for long between queries. Batch between queries (pass multiple pairs to a server) to minimize number thereof
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
176
diff
changeset
|
154 st.eolIsSignificant(true); |
e10225daface
Use POST for long between queries. Batch between queries (pass multiple pairs to a server) to minimize number thereof
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
176
diff
changeset
|
155 Iterator<Range> rangeItr = ranges.iterator(); |
e10225daface
Use POST for long between queries. Batch between queries (pass multiple pairs to a server) to minimize number thereof
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
176
diff
changeset
|
156 LinkedList<Nodeid> currRangeList = null; |
e10225daface
Use POST for long between queries. Batch between queries (pass multiple pairs to a server) to minimize number thereof
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
176
diff
changeset
|
157 Range currRange = null; |
e10225daface
Use POST for long between queries. Batch between queries (pass multiple pairs to a server) to minimize number thereof
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
176
diff
changeset
|
158 boolean possiblyEmptyNextLine = true; |
176
a8df7162ec75
Extracting complete branch using remote between call to detect incoming changes is done. Arguments reorderd in remote repo to better match Hg server ideology, not my mental convenience
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
172
diff
changeset
|
159 while (st.nextToken() != StreamTokenizer.TT_EOF) { |
177
e10225daface
Use POST for long between queries. Batch between queries (pass multiple pairs to a server) to minimize number thereof
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
176
diff
changeset
|
160 if (st.ttype == StreamTokenizer.TT_EOL) { |
e10225daface
Use POST for long between queries. Batch between queries (pass multiple pairs to a server) to minimize number thereof
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
176
diff
changeset
|
161 if (possiblyEmptyNextLine) { |
e10225daface
Use POST for long between queries. Batch between queries (pass multiple pairs to a server) to minimize number thereof
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
176
diff
changeset
|
162 // newline follows newline; |
e10225daface
Use POST for long between queries. Batch between queries (pass multiple pairs to a server) to minimize number thereof
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
176
diff
changeset
|
163 assert currRange == null; |
e10225daface
Use POST for long between queries. Batch between queries (pass multiple pairs to a server) to minimize number thereof
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
176
diff
changeset
|
164 assert currRangeList == null; |
e10225daface
Use POST for long between queries. Batch between queries (pass multiple pairs to a server) to minimize number thereof
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
176
diff
changeset
|
165 if (!rangeItr.hasNext()) { |
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:
414
diff
changeset
|
166 throw new HgInvalidStateException("Internal error"); // TODO revisit-1.1 |
177
e10225daface
Use POST for long between queries. Batch between queries (pass multiple pairs to a server) to minimize number thereof
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
176
diff
changeset
|
167 } |
e10225daface
Use POST for long between queries. Batch between queries (pass multiple pairs to a server) to minimize number thereof
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
176
diff
changeset
|
168 rv.put(rangeItr.next(), Collections.<Nodeid>emptyList()); |
e10225daface
Use POST for long between queries. Batch between queries (pass multiple pairs to a server) to minimize number thereof
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
176
diff
changeset
|
169 } else { |
e10225daface
Use POST for long between queries. Batch between queries (pass multiple pairs to a server) to minimize number thereof
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
176
diff
changeset
|
170 if (currRange == null || currRangeList == 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:
414
diff
changeset
|
171 throw new HgInvalidStateException("Internal error"); // TODO revisit-1.1 |
177
e10225daface
Use POST for long between queries. Batch between queries (pass multiple pairs to a server) to minimize number thereof
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
176
diff
changeset
|
172 } |
e10225daface
Use POST for long between queries. Batch between queries (pass multiple pairs to a server) to minimize number thereof
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
176
diff
changeset
|
173 // indicate next range value is needed |
e10225daface
Use POST for long between queries. Batch between queries (pass multiple pairs to a server) to minimize number thereof
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
176
diff
changeset
|
174 currRange = null; |
e10225daface
Use POST for long between queries. Batch between queries (pass multiple pairs to a server) to minimize number thereof
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
176
diff
changeset
|
175 currRangeList = null; |
e10225daface
Use POST for long between queries. Batch between queries (pass multiple pairs to a server) to minimize number thereof
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
176
diff
changeset
|
176 possiblyEmptyNextLine = true; |
e10225daface
Use POST for long between queries. Batch between queries (pass multiple pairs to a server) to minimize number thereof
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
176
diff
changeset
|
177 } |
e10225daface
Use POST for long between queries. Batch between queries (pass multiple pairs to a server) to minimize number thereof
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
176
diff
changeset
|
178 } else { |
e10225daface
Use POST for long between queries. Batch between queries (pass multiple pairs to a server) to minimize number thereof
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
176
diff
changeset
|
179 possiblyEmptyNextLine = false; |
e10225daface
Use POST for long between queries. Batch between queries (pass multiple pairs to a server) to minimize number thereof
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
176
diff
changeset
|
180 if (currRange == null) { |
e10225daface
Use POST for long between queries. Batch between queries (pass multiple pairs to a server) to minimize number thereof
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
176
diff
changeset
|
181 if (!rangeItr.hasNext()) { |
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:
414
diff
changeset
|
182 throw new HgInvalidStateException("Internal error"); // TODO revisit-1.1 |
177
e10225daface
Use POST for long between queries. Batch between queries (pass multiple pairs to a server) to minimize number thereof
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
176
diff
changeset
|
183 } |
e10225daface
Use POST for long between queries. Batch between queries (pass multiple pairs to a server) to minimize number thereof
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
176
diff
changeset
|
184 currRange = rangeItr.next(); |
e10225daface
Use POST for long between queries. Batch between queries (pass multiple pairs to a server) to minimize number thereof
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
176
diff
changeset
|
185 currRangeList = new LinkedList<Nodeid>(); |
e10225daface
Use POST for long between queries. Batch between queries (pass multiple pairs to a server) to minimize number thereof
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
176
diff
changeset
|
186 rv.put(currRange, currRangeList); |
e10225daface
Use POST for long between queries. Batch between queries (pass multiple pairs to a server) to minimize number thereof
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
176
diff
changeset
|
187 } |
e10225daface
Use POST for long between queries. Batch between queries (pass multiple pairs to a server) to minimize number thereof
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
176
diff
changeset
|
188 Nodeid nid = Nodeid.fromAscii(st.sval); |
e10225daface
Use POST for long between queries. Batch between queries (pass multiple pairs to a server) to minimize number thereof
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
176
diff
changeset
|
189 currRangeList.addLast(nid); |
e10225daface
Use POST for long between queries. Batch between queries (pass multiple pairs to a server) to minimize number thereof
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
176
diff
changeset
|
190 } |
176
a8df7162ec75
Extracting complete branch using remote between call to detect incoming changes is done. Arguments reorderd in remote repo to better match Hg server ideology, not my mental convenience
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
172
diff
changeset
|
191 } |
a8df7162ec75
Extracting complete branch using remote between call to detect incoming changes is done. Arguments reorderd in remote repo to better match Hg server ideology, not my mental convenience
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
172
diff
changeset
|
192 is.close(); |
a8df7162ec75
Extracting complete branch using remote between call to detect incoming changes is done. Arguments reorderd in remote repo to better match Hg server ideology, not my mental convenience
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
172
diff
changeset
|
193 return rv; |
a8df7162ec75
Extracting complete branch using remote between call to detect incoming changes is done. Arguments reorderd in remote repo to better match Hg server ideology, not my mental convenience
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
172
diff
changeset
|
194 } catch (IOException ex) { |
687
9859fcea475d
Towards ssh remote repositories: refactor HgRemoteRepository - move http related code to HttpConnector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
685
diff
changeset
|
195 throw new HgRemoteConnectionException("Communication failure", ex).setRemoteCommand(CMD_BETWEEN).setServerInfo(getLocation()); |
645
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
196 } finally { |
687
9859fcea475d
Towards ssh remote repositories: refactor HgRemoteRepository - move http related code to HttpConnector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
685
diff
changeset
|
197 remote.sessionEnd(); |
176
a8df7162ec75
Extracting complete branch using remote between call to detect incoming changes is done. Arguments reorderd in remote repo to better match Hg server ideology, not my mental convenience
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
172
diff
changeset
|
198 } |
a8df7162ec75
Extracting complete branch using remote between call to detect incoming changes is done. Arguments reorderd in remote repo to better match Hg server ideology, not my mental convenience
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
172
diff
changeset
|
199 } |
a8df7162ec75
Extracting complete branch using remote between call to detect incoming changes is done. Arguments reorderd in remote repo to better match Hg server ideology, not my mental convenience
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
172
diff
changeset
|
200 |
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<RemoteBranch> branches(List<Nodeid> nodes) throws HgRemoteConnectionException { |
687
9859fcea475d
Towards ssh remote repositories: refactor HgRemoteRepository - move http related code to HttpConnector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
685
diff
changeset
|
202 if (isInvalid()) { |
9859fcea475d
Towards ssh remote repositories: refactor HgRemoteRepository - move http related code to HttpConnector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
685
diff
changeset
|
203 return Collections.emptyList(); |
9859fcea475d
Towards ssh remote repositories: refactor HgRemoteRepository - move http related code to HttpConnector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
685
diff
changeset
|
204 } |
178
62665d8f0686
Complete logic to discover all branches missing locally. Most of wire protocol in HgRemoteRepository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
177
diff
changeset
|
205 try { |
687
9859fcea475d
Towards ssh remote repositories: refactor HgRemoteRepository - move http related code to HttpConnector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
685
diff
changeset
|
206 remote.sessionBegin(); |
9859fcea475d
Towards ssh remote repositories: refactor HgRemoteRepository - move http related code to HttpConnector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
685
diff
changeset
|
207 InputStreamReader is = new InputStreamReader(remote.branches(nodes), "US-ASCII"); |
178
62665d8f0686
Complete logic to discover all branches missing locally. Most of wire protocol in HgRemoteRepository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
177
diff
changeset
|
208 StreamTokenizer st = new StreamTokenizer(is); |
62665d8f0686
Complete logic to discover all branches missing locally. Most of wire protocol in HgRemoteRepository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
177
diff
changeset
|
209 st.ordinaryChars('0', '9'); |
62665d8f0686
Complete logic to discover all branches missing locally. Most of wire protocol in HgRemoteRepository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
177
diff
changeset
|
210 st.wordChars('0', '9'); |
62665d8f0686
Complete logic to discover all branches missing locally. Most of wire protocol in HgRemoteRepository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
177
diff
changeset
|
211 st.eolIsSignificant(false); |
62665d8f0686
Complete logic to discover all branches missing locally. Most of wire protocol in HgRemoteRepository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
177
diff
changeset
|
212 ArrayList<Nodeid> parseResult = new ArrayList<Nodeid>(nodes.size() * 4); |
62665d8f0686
Complete logic to discover all branches missing locally. Most of wire protocol in HgRemoteRepository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
177
diff
changeset
|
213 while (st.nextToken() != StreamTokenizer.TT_EOF) { |
62665d8f0686
Complete logic to discover all branches missing locally. Most of wire protocol in HgRemoteRepository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
177
diff
changeset
|
214 parseResult.add(Nodeid.fromAscii(st.sval)); |
62665d8f0686
Complete logic to discover all branches missing locally. Most of wire protocol in HgRemoteRepository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
177
diff
changeset
|
215 } |
62665d8f0686
Complete logic to discover all branches missing locally. Most of wire protocol in HgRemoteRepository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
177
diff
changeset
|
216 if (parseResult.size() != nodes.size() * 4) { |
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
|
217 throw new HgRemoteConnectionException(String.format("Bad number of nodeids in result (shall be factor 4), expected %d, got %d", nodes.size()*4, parseResult.size())); |
178
62665d8f0686
Complete logic to discover all branches missing locally. Most of wire protocol in HgRemoteRepository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
177
diff
changeset
|
218 } |
62665d8f0686
Complete logic to discover all branches missing locally. Most of wire protocol in HgRemoteRepository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
177
diff
changeset
|
219 ArrayList<RemoteBranch> rv = new ArrayList<RemoteBranch>(nodes.size()); |
62665d8f0686
Complete logic to discover all branches missing locally. Most of wire protocol in HgRemoteRepository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
177
diff
changeset
|
220 for (int i = 0; i < nodes.size(); i++) { |
62665d8f0686
Complete logic to discover all branches missing locally. Most of wire protocol in HgRemoteRepository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
177
diff
changeset
|
221 RemoteBranch rb = new RemoteBranch(parseResult.get(i*4), parseResult.get(i*4 + 1), parseResult.get(i*4 + 2), parseResult.get(i*4 + 3)); |
62665d8f0686
Complete logic to discover all branches missing locally. Most of wire protocol in HgRemoteRepository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
177
diff
changeset
|
222 rv.add(rb); |
62665d8f0686
Complete logic to discover all branches missing locally. Most of wire protocol in HgRemoteRepository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
177
diff
changeset
|
223 } |
62665d8f0686
Complete logic to discover all branches missing locally. Most of wire protocol in HgRemoteRepository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
177
diff
changeset
|
224 return rv; |
62665d8f0686
Complete logic to discover all branches missing locally. Most of wire protocol in HgRemoteRepository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
177
diff
changeset
|
225 } catch (IOException ex) { |
687
9859fcea475d
Towards ssh remote repositories: refactor HgRemoteRepository - move http related code to HttpConnector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
685
diff
changeset
|
226 throw new HgRemoteConnectionException("Communication failure", ex).setRemoteCommand(CMD_BRANCHES).setServerInfo(getLocation()); |
645
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
227 } finally { |
687
9859fcea475d
Towards ssh remote repositories: refactor HgRemoteRepository - move http related code to HttpConnector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
685
diff
changeset
|
228 remote.sessionEnd(); |
178
62665d8f0686
Complete logic to discover all branches missing locally. Most of wire protocol in HgRemoteRepository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
177
diff
changeset
|
229 } |
171
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
230 } |
170
71ddbf8603e8
Initial clone: populate given directory from a bundle. Everything but remote server access is there, albeit prototype code style
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
231 |
186
44a34baabea0
Clone refactored into a command. HgBundle needs means to control its lifecycle, to be deleted when no longer needed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
184
diff
changeset
|
232 /* |
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:
190
diff
changeset
|
233 * XXX need to describe behavior when roots arg is empty; our RepositoryComparator code currently returns empty lists when |
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:
190
diff
changeset
|
234 * no common elements found, which in turn means we need to query changes starting with NULL nodeid. |
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:
190
diff
changeset
|
235 * |
186
44a34baabea0
Clone refactored into a command. HgBundle needs means to control its lifecycle, to be deleted when no longer needed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
184
diff
changeset
|
236 * WireProtocol wiki: roots = a list of the latest nodes on every service side changeset branch that both the client and server know about. |
44a34baabea0
Clone refactored into a command. HgBundle needs means to control its lifecycle, to be deleted when no longer needed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
184
diff
changeset
|
237 * |
44a34baabea0
Clone refactored into a command. HgBundle needs means to control its lifecycle, to be deleted when no longer needed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
184
diff
changeset
|
238 * Perhaps, shall be named 'changegroup' |
44a34baabea0
Clone refactored into a command. HgBundle needs means to control its lifecycle, to be deleted when no longer needed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
184
diff
changeset
|
239 |
44a34baabea0
Clone refactored into a command. HgBundle needs means to control its lifecycle, to be deleted when no longer needed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
184
diff
changeset
|
240 * Changegroup: |
44a34baabea0
Clone refactored into a command. HgBundle needs means to control its lifecycle, to be deleted when no longer needed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
184
diff
changeset
|
241 * http://mercurial.selenic.com/wiki/Merge |
44a34baabea0
Clone refactored into a command. HgBundle needs means to control its lifecycle, to be deleted when no longer needed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
184
diff
changeset
|
242 * http://mercurial.selenic.com/wiki/WireProtocol |
44a34baabea0
Clone refactored into a command. HgBundle needs means to control its lifecycle, to be deleted when no longer needed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
184
diff
changeset
|
243 * |
44a34baabea0
Clone refactored into a command. HgBundle needs means to control its lifecycle, to be deleted when no longer needed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
184
diff
changeset
|
244 * according to latter, bundleformat data is sent through zlib |
44a34baabea0
Clone refactored into a command. HgBundle needs means to control its lifecycle, to be deleted when no longer needed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
184
diff
changeset
|
245 * (there's no header like HG10?? with the server output, though, |
44a34baabea0
Clone refactored into a command. HgBundle needs means to control its lifecycle, to be deleted when no longer needed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
184
diff
changeset
|
246 * as one may expect according to http://mercurial.selenic.com/wiki/BundleFormat) |
44a34baabea0
Clone refactored into a command. HgBundle needs means to control its lifecycle, to be deleted when no longer needed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
184
diff
changeset
|
247 */ |
425
48f993aa2f41
FIXMEs: exceptions, javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
423
diff
changeset
|
248 public HgBundle getChanges(List<Nodeid> roots) throws HgRemoteConnectionException, HgRuntimeException { |
687
9859fcea475d
Towards ssh remote repositories: refactor HgRemoteRepository - move http related code to HttpConnector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
685
diff
changeset
|
249 if (isInvalid()) { |
9859fcea475d
Towards ssh remote repositories: refactor HgRemoteRepository - move http related code to HttpConnector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
685
diff
changeset
|
250 return null; // XXX valid retval??? |
9859fcea475d
Towards ssh remote repositories: refactor HgRemoteRepository - move http related code to HttpConnector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
685
diff
changeset
|
251 } |
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:
190
diff
changeset
|
252 List<Nodeid> _roots = roots.isEmpty() ? Collections.singletonList(Nodeid.NULL) : roots; |
179
da426c2fe1ec
Support for changegroup wire command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
178
diff
changeset
|
253 try { |
687
9859fcea475d
Towards ssh remote repositories: refactor HgRemoteRepository - move http related code to HttpConnector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
685
diff
changeset
|
254 remote.sessionBegin(); |
697
24f4efedc9d5
Respect the fact ssh and http protocols use different compression approach to sent changegroup data
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
687
diff
changeset
|
255 File tf = writeBundle(remote.changegroup(_roots)); |
179
da426c2fe1ec
Support for changegroup wire command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
178
diff
changeset
|
256 if (debug) { |
687
9859fcea475d
Towards ssh remote repositories: refactor HgRemoteRepository - move http related code to HttpConnector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
685
diff
changeset
|
257 System.out.printf("Wrote bundle %s for roots %s\n", tf, roots); |
190
9b99d27aeddc
More debug printouts
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
186
diff
changeset
|
258 } |
186
44a34baabea0
Clone refactored into a command. HgBundle needs means to control its lifecycle, to be deleted when no longer needed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
184
diff
changeset
|
259 return getLookupHelper().loadBundle(tf); |
179
da426c2fe1ec
Support for changegroup wire command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
178
diff
changeset
|
260 } catch (IOException ex) { |
687
9859fcea475d
Towards ssh remote repositories: refactor HgRemoteRepository - move http related code to HttpConnector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
685
diff
changeset
|
261 throw new HgRemoteConnectionException("Communication failure", ex).setRemoteCommand(CMD_CHANGEGROUP).setServerInfo(getLocation()); |
425
48f993aa2f41
FIXMEs: exceptions, javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
423
diff
changeset
|
262 } catch (HgRepositoryNotFoundException ex) { |
687
9859fcea475d
Towards ssh remote repositories: refactor HgRemoteRepository - move http related code to HttpConnector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
685
diff
changeset
|
263 throw new HgRemoteConnectionException("Communication failure", ex).setRemoteCommand(CMD_CHANGEGROUP).setServerInfo(getLocation()); |
645
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
264 } finally { |
687
9859fcea475d
Towards ssh remote repositories: refactor HgRemoteRepository - move http related code to HttpConnector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
685
diff
changeset
|
265 remote.sessionEnd(); |
645
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
266 } |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
267 } |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
268 |
646
3b7d51ed4c65
Push: phase3 - update matching remote bookmarks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
645
diff
changeset
|
269 public void unbundle(HgBundle bundle, List<Nodeid> remoteHeads) throws HgRemoteConnectionException, HgRuntimeException { |
3b7d51ed4c65
Push: phase3 - update matching remote bookmarks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
645
diff
changeset
|
270 if (remoteHeads == null) { |
645
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
271 // TODO collect heads from bundle: |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
272 // bundle.inspectChangelog(new HeadCollector(for each c : if collected has c.p1 or c.p2, remove them. Add c)) |
646
3b7d51ed4c65
Push: phase3 - update matching remote bookmarks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
645
diff
changeset
|
273 // or get from remote server??? |
645
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
274 throw Internals.notImplemented(); |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
275 } |
687
9859fcea475d
Towards ssh remote repositories: refactor HgRemoteRepository - move http related code to HttpConnector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
685
diff
changeset
|
276 if (isInvalid()) { |
9859fcea475d
Towards ssh remote repositories: refactor HgRemoteRepository - move http related code to HttpConnector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
685
diff
changeset
|
277 return; |
9859fcea475d
Towards ssh remote repositories: refactor HgRemoteRepository - move http related code to HttpConnector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
685
diff
changeset
|
278 } |
673
545b1d4cc11d
Refactor HgBundle.GroupElement (clear experimental mark), resolve few technical debt issues
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
652
diff
changeset
|
279 DataSerializer.DataSource bundleData = BundleSerializer.newInstance(sessionContext, bundle); |
687
9859fcea475d
Towards ssh remote repositories: refactor HgRemoteRepository - move http related code to HttpConnector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
685
diff
changeset
|
280 OutputStream os = null; |
645
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
281 try { |
687
9859fcea475d
Towards ssh remote repositories: refactor HgRemoteRepository - move http related code to HttpConnector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
685
diff
changeset
|
282 remote.sessionBegin(); |
9859fcea475d
Towards ssh remote repositories: refactor HgRemoteRepository - move http related code to HttpConnector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
685
diff
changeset
|
283 os = remote.unbundle(bundleData.serializeLength(), remoteHeads); |
645
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
284 bundleData.serialize(new OutputStreamSerializer(os)); |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
285 os.flush(); |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
286 os.close(); |
687
9859fcea475d
Towards ssh remote repositories: refactor HgRemoteRepository - move http related code to HttpConnector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
685
diff
changeset
|
287 os = null; |
645
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
288 } catch (IOException ex) { |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
289 throw new HgRemoteConnectionException("Communication failure", ex).setRemoteCommand("unbundle").setServerInfo(getLocation()); |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
290 } catch (HgIOException ex) { |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
291 throw new HgRemoteConnectionException("Communication failure", ex).setRemoteCommand("unbundle").setServerInfo(getLocation()); |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
292 } finally { |
687
9859fcea475d
Towards ssh remote repositories: refactor HgRemoteRepository - move http related code to HttpConnector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
685
diff
changeset
|
293 new FileUtils(sessionContext.getLog(), this).closeQuietly(os); |
9859fcea475d
Towards ssh remote repositories: refactor HgRemoteRepository - move http related code to HttpConnector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
685
diff
changeset
|
294 remote.sessionEnd(); |
179
da426c2fe1ec
Support for changegroup wire command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
178
diff
changeset
|
295 } |
170
71ddbf8603e8
Initial clone: populate given directory from a bundle. Everything but remote server access is there, albeit prototype code style
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
296 } |
186
44a34baabea0
Clone refactored into a command. HgBundle needs means to control its lifecycle, to be deleted when no longer needed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
184
diff
changeset
|
297 |
649
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
298 public Bookmarks getBookmarks() throws HgRemoteConnectionException, HgRuntimeException { |
687
9859fcea475d
Towards ssh remote repositories: refactor HgRemoteRepository - move http related code to HttpConnector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
685
diff
changeset
|
299 initCapabilities(); |
9859fcea475d
Towards ssh remote repositories: refactor HgRemoteRepository - move http related code to HttpConnector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
685
diff
changeset
|
300 if (!remoteCapabilities.contains(CMD_PUSHKEY)) { // (sic!) listkeys is available when pushkey in caps |
9859fcea475d
Towards ssh remote repositories: refactor HgRemoteRepository - move http related code to HttpConnector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
685
diff
changeset
|
301 return new Bookmarks(Collections.<Pair<String, Nodeid>>emptyList()); |
9859fcea475d
Towards ssh remote repositories: refactor HgRemoteRepository - move http related code to HttpConnector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
685
diff
changeset
|
302 } |
646
3b7d51ed4c65
Push: phase3 - update matching remote bookmarks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
645
diff
changeset
|
303 final String actionName = "Get remote bookmarks"; |
3b7d51ed4c65
Push: phase3 - update matching remote bookmarks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
645
diff
changeset
|
304 final List<Pair<String, String>> values = listkeys("bookmarks", actionName); |
3b7d51ed4c65
Push: phase3 - update matching remote bookmarks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
645
diff
changeset
|
305 ArrayList<Pair<String, Nodeid>> rv = new ArrayList<Pair<String, Nodeid>>(); |
3b7d51ed4c65
Push: phase3 - update matching remote bookmarks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
645
diff
changeset
|
306 for (Pair<String, String> l : values) { |
3b7d51ed4c65
Push: phase3 - update matching remote bookmarks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
645
diff
changeset
|
307 if (l.second().length() != Nodeid.SIZE_ASCII) { |
3b7d51ed4c65
Push: phase3 - update matching remote bookmarks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
645
diff
changeset
|
308 sessionContext.getLog().dump(getClass(), Severity.Warn, "%s: bad nodeid '%s', ignored", actionName, l.second()); |
3b7d51ed4c65
Push: phase3 - update matching remote bookmarks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
645
diff
changeset
|
309 continue; |
3b7d51ed4c65
Push: phase3 - update matching remote bookmarks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
645
diff
changeset
|
310 } |
3b7d51ed4c65
Push: phase3 - update matching remote bookmarks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
645
diff
changeset
|
311 Nodeid n = Nodeid.fromAscii(l.second()); |
3b7d51ed4c65
Push: phase3 - update matching remote bookmarks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
645
diff
changeset
|
312 String bm = new String(l.first()); |
3b7d51ed4c65
Push: phase3 - update matching remote bookmarks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
645
diff
changeset
|
313 rv.add(new Pair<String, Nodeid>(bm, n)); |
3b7d51ed4c65
Push: phase3 - update matching remote bookmarks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
645
diff
changeset
|
314 } |
649
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
315 return new Bookmarks(rv); |
646
3b7d51ed4c65
Push: phase3 - update matching remote bookmarks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
645
diff
changeset
|
316 } |
3b7d51ed4c65
Push: phase3 - update matching remote bookmarks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
645
diff
changeset
|
317 |
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:
651
diff
changeset
|
318 public Outcome updateBookmark(String name, Nodeid oldRev, Nodeid newRev) throws HgRemoteConnectionException, HgRuntimeException { |
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:
651
diff
changeset
|
319 initCapabilities(); |
687
9859fcea475d
Towards ssh remote repositories: refactor HgRemoteRepository - move http related code to HttpConnector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
685
diff
changeset
|
320 if (!remoteCapabilities.contains(CMD_PUSHKEY)) { |
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:
651
diff
changeset
|
321 return new Outcome(Failure, "Server doesn't support pushkey protocol"); |
646
3b7d51ed4c65
Push: phase3 - update matching remote bookmarks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
645
diff
changeset
|
322 } |
687
9859fcea475d
Towards ssh remote repositories: refactor HgRemoteRepository - move http related code to HttpConnector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
685
diff
changeset
|
323 if (pushkey("Update remote bookmark", NS_BOOKMARKS, name, oldRev.toString(), newRev.toString())) { |
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:
651
diff
changeset
|
324 return new Outcome(Success, String.format("Bookmark %s updated to %s", name, newRev.shortNotation())); |
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:
651
diff
changeset
|
325 } |
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:
651
diff
changeset
|
326 return new Outcome(Failure, String.format("Bookmark update (%s: %s -> %s) failed", name, oldRev.shortNotation(), newRev.shortNotation())); |
646
3b7d51ed4c65
Push: phase3 - update matching remote bookmarks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
645
diff
changeset
|
327 } |
3b7d51ed4c65
Push: phase3 - update matching remote bookmarks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
645
diff
changeset
|
328 |
649
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
329 public Phases getPhases() throws HgRemoteConnectionException, HgRuntimeException { |
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
330 initCapabilities(); |
687
9859fcea475d
Towards ssh remote repositories: refactor HgRemoteRepository - move http related code to HttpConnector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
685
diff
changeset
|
331 if (!remoteCapabilities.contains(CMD_PUSHKEY)) { |
649
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
332 // old server defaults to publishing |
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
333 return new Phases(true, Collections.<Nodeid>emptyList()); |
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
334 } |
687
9859fcea475d
Towards ssh remote repositories: refactor HgRemoteRepository - move http related code to HttpConnector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
685
diff
changeset
|
335 final List<Pair<String, String>> values = listkeys(NS_PHASES, "Get remote phases"); |
650
3b275cc2d2aa
Push: phase4 - settle local and remote phases, push updated phases regardless of server publishing state, do not push secret changesets
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
649
diff
changeset
|
336 boolean publishing = false; |
649
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
337 ArrayList<Nodeid> draftRoots = new ArrayList<Nodeid>(); |
646
3b7d51ed4c65
Push: phase3 - update matching remote bookmarks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
645
diff
changeset
|
338 for (Pair<String, String> l : values) { |
649
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
339 if ("publishing".equalsIgnoreCase(l.first())) { |
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
340 publishing = Boolean.parseBoolean(l.second()); |
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
341 continue; |
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
342 } |
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
343 Nodeid root = Nodeid.fromAscii(l.first()); |
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
344 int ph = Integer.parseInt(l.second()); |
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
345 if (ph == HgPhase.Draft.mercurialOrdinal()) { |
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
346 draftRoots.add(root); |
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
347 } else { |
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
348 assert false; |
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
349 sessionContext.getLog().dump(getClass(), Severity.Error, "Unexpected phase value %d for revision %s", ph, root); |
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
350 } |
646
3b7d51ed4c65
Push: phase3 - update matching remote bookmarks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
645
diff
changeset
|
351 } |
649
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
352 return new Phases(publishing, draftRoots); |
646
3b7d51ed4c65
Push: phase3 - update matching remote bookmarks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
645
diff
changeset
|
353 } |
3b7d51ed4c65
Push: phase3 - update matching remote bookmarks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
645
diff
changeset
|
354 |
649
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
355 public Outcome updatePhase(HgPhase from, HgPhase to, Nodeid n) throws HgRemoteConnectionException, HgRuntimeException { |
650
3b275cc2d2aa
Push: phase4 - settle local and remote phases, push updated phases regardless of server publishing state, do not push secret changesets
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
649
diff
changeset
|
356 initCapabilities(); |
687
9859fcea475d
Towards ssh remote repositories: refactor HgRemoteRepository - move http related code to HttpConnector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
685
diff
changeset
|
357 if (!remoteCapabilities.contains(CMD_PUSHKEY)) { |
650
3b275cc2d2aa
Push: phase4 - settle local and remote phases, push updated phases regardless of server publishing state, do not push secret changesets
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
649
diff
changeset
|
358 return new Outcome(Failure, "Server doesn't support pushkey protocol"); |
3b275cc2d2aa
Push: phase4 - settle local and remote phases, push updated phases regardless of server publishing state, do not push secret changesets
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
649
diff
changeset
|
359 } |
687
9859fcea475d
Towards ssh remote repositories: refactor HgRemoteRepository - move http related code to HttpConnector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
685
diff
changeset
|
360 if (pushkey("Update remote phases", NS_PHASES, n.toString(), String.valueOf(from.mercurialOrdinal()), String.valueOf(to.mercurialOrdinal()))) { |
650
3b275cc2d2aa
Push: phase4 - settle local and remote phases, push updated phases regardless of server publishing state, do not push secret changesets
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
649
diff
changeset
|
361 return new Outcome(Success, String.format("Phase of %s updated to %s", n.shortNotation(), to.name())); |
649
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
362 } |
650
3b275cc2d2aa
Push: phase4 - settle local and remote phases, push updated phases regardless of server publishing state, do not push secret changesets
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
649
diff
changeset
|
363 return new Outcome(Failure, String.format("Phase update (%s: %s -> %s) failed", n.shortNotation(), from.name(), to.name())); |
649
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
364 } |
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
365 |
203
66fd2c73c56f
Basic test for HgOutgoingCommand. Handle cases with no outgoing changes in RepositoryComparator
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
202
diff
changeset
|
366 @Override |
66fd2c73c56f
Basic test for HgOutgoingCommand. Handle cases with no outgoing changes in RepositoryComparator
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
202
diff
changeset
|
367 public String toString() { |
66fd2c73c56f
Basic test for HgOutgoingCommand. Handle cases with no outgoing changes in RepositoryComparator
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
202
diff
changeset
|
368 return getClass().getSimpleName() + '[' + getLocation() + ']'; |
66fd2c73c56f
Basic test for HgOutgoingCommand. Handle cases with no outgoing changes in RepositoryComparator
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
202
diff
changeset
|
369 } |
646
3b7d51ed4c65
Push: phase3 - update matching remote bookmarks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
645
diff
changeset
|
370 |
3b7d51ed4c65
Push: phase3 - update matching remote bookmarks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
645
diff
changeset
|
371 |
3b7d51ed4c65
Push: phase3 - update matching remote bookmarks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
645
diff
changeset
|
372 private void initCapabilities() throws HgRemoteConnectionException { |
687
9859fcea475d
Towards ssh remote repositories: refactor HgRemoteRepository - move http related code to HttpConnector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
685
diff
changeset
|
373 if (remoteCapabilities != null) { |
9859fcea475d
Towards ssh remote repositories: refactor HgRemoteRepository - move http related code to HttpConnector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
685
diff
changeset
|
374 return; |
9859fcea475d
Towards ssh remote repositories: refactor HgRemoteRepository - move http related code to HttpConnector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
685
diff
changeset
|
375 } |
699
a483b2b68a2e
Provisional APIs and respective implementation for http, https and ssh remote repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
698
diff
changeset
|
376 try { |
a483b2b68a2e
Provisional APIs and respective implementation for http, https and ssh remote repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
698
diff
changeset
|
377 remote.connect(); |
a483b2b68a2e
Provisional APIs and respective implementation for http, https and ssh remote repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
698
diff
changeset
|
378 } catch (HgAuthFailedException ex) { |
a483b2b68a2e
Provisional APIs and respective implementation for http, https and ssh remote repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
698
diff
changeset
|
379 throw new HgRemoteConnectionException("Failed to authenticate", ex).setServerInfo(remote.getServerLocation()); |
a483b2b68a2e
Provisional APIs and respective implementation for http, https and ssh remote repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
698
diff
changeset
|
380 } |
687
9859fcea475d
Towards ssh remote repositories: refactor HgRemoteRepository - move http related code to HttpConnector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
685
diff
changeset
|
381 try { |
9859fcea475d
Towards ssh remote repositories: refactor HgRemoteRepository - move http related code to HttpConnector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
685
diff
changeset
|
382 remote.sessionBegin(); |
9859fcea475d
Towards ssh remote repositories: refactor HgRemoteRepository - move http related code to HttpConnector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
685
diff
changeset
|
383 String capsLine = remote.getCapabilities(); |
9859fcea475d
Towards ssh remote repositories: refactor HgRemoteRepository - move http related code to HttpConnector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
685
diff
changeset
|
384 String[] caps = capsLine.split("\\s"); |
9859fcea475d
Towards ssh remote repositories: refactor HgRemoteRepository - move http related code to HttpConnector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
685
diff
changeset
|
385 remoteCapabilities = new HashSet<String>(Arrays.asList(caps)); |
9859fcea475d
Towards ssh remote repositories: refactor HgRemoteRepository - move http related code to HttpConnector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
685
diff
changeset
|
386 } finally { |
9859fcea475d
Towards ssh remote repositories: refactor HgRemoteRepository - move http related code to HttpConnector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
685
diff
changeset
|
387 remote.sessionEnd(); |
646
3b7d51ed4c65
Push: phase3 - update matching remote bookmarks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
645
diff
changeset
|
388 } |
3b7d51ed4c65
Push: phase3 - update matching remote bookmarks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
645
diff
changeset
|
389 } |
203
66fd2c73c56f
Basic test for HgOutgoingCommand. Handle cases with no outgoing changes in RepositoryComparator
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
202
diff
changeset
|
390 |
186
44a34baabea0
Clone refactored into a command. HgBundle needs means to control its lifecycle, to be deleted when no longer needed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
184
diff
changeset
|
391 private HgLookup getLookupHelper() { |
44a34baabea0
Clone refactored into a command. HgBundle needs means to control its lifecycle, to be deleted when no longer needed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
184
diff
changeset
|
392 if (lookupHelper == null) { |
295
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
274
diff
changeset
|
393 lookupHelper = new HgLookup(sessionContext); |
186
44a34baabea0
Clone refactored into a command. HgBundle needs means to control its lifecycle, to be deleted when no longer needed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
184
diff
changeset
|
394 } |
44a34baabea0
Clone refactored into a command. HgBundle needs means to control its lifecycle, to be deleted when no longer needed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
184
diff
changeset
|
395 return lookupHelper; |
44a34baabea0
Clone refactored into a command. HgBundle needs means to control its lifecycle, to be deleted when no longer needed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
184
diff
changeset
|
396 } |
646
3b7d51ed4c65
Push: phase3 - update matching remote bookmarks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
645
diff
changeset
|
397 |
3b7d51ed4c65
Push: phase3 - update matching remote bookmarks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
645
diff
changeset
|
398 private List<Pair<String,String>> listkeys(String namespace, String actionName) throws HgRemoteConnectionException, HgRuntimeException { |
3b7d51ed4c65
Push: phase3 - update matching remote bookmarks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
645
diff
changeset
|
399 try { |
687
9859fcea475d
Towards ssh remote repositories: refactor HgRemoteRepository - move http related code to HttpConnector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
685
diff
changeset
|
400 remote.sessionBegin(); |
646
3b7d51ed4c65
Push: phase3 - update matching remote bookmarks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
645
diff
changeset
|
401 ArrayList<Pair<String, String>> rv = new ArrayList<Pair<String, String>>(); |
687
9859fcea475d
Towards ssh remote repositories: refactor HgRemoteRepository - move http related code to HttpConnector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
685
diff
changeset
|
402 InputStream response = remote.listkeys(namespace, actionName); |
685
9897cbfd2790
Towards ssh remote repositories: use ganymed library for ssh transport
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
673
diff
changeset
|
403 // output of listkeys is encoded with UTF-8 |
687
9859fcea475d
Towards ssh remote repositories: refactor HgRemoteRepository - move http related code to HttpConnector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
685
diff
changeset
|
404 BufferedReader r = new BufferedReader(new InputStreamReader(response, EncodingHelper.getUTF8())); |
646
3b7d51ed4c65
Push: phase3 - update matching remote bookmarks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
645
diff
changeset
|
405 String l; |
3b7d51ed4c65
Push: phase3 - update matching remote bookmarks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
645
diff
changeset
|
406 while ((l = r.readLine()) != null) { |
3b7d51ed4c65
Push: phase3 - update matching remote bookmarks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
645
diff
changeset
|
407 int sep = l.indexOf('\t'); |
3b7d51ed4c65
Push: phase3 - update matching remote bookmarks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
645
diff
changeset
|
408 if (sep == -1) { |
3b7d51ed4c65
Push: phase3 - update matching remote bookmarks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
645
diff
changeset
|
409 sessionContext.getLog().dump(getClass(), Severity.Warn, "%s: bad line '%s', ignored", actionName, l); |
3b7d51ed4c65
Push: phase3 - update matching remote bookmarks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
645
diff
changeset
|
410 continue; |
3b7d51ed4c65
Push: phase3 - update matching remote bookmarks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
645
diff
changeset
|
411 } |
3b7d51ed4c65
Push: phase3 - update matching remote bookmarks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
645
diff
changeset
|
412 rv.add(new Pair<String,String>(l.substring(0, sep), l.substring(sep+1))); |
3b7d51ed4c65
Push: phase3 - update matching remote bookmarks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
645
diff
changeset
|
413 } |
3b7d51ed4c65
Push: phase3 - update matching remote bookmarks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
645
diff
changeset
|
414 r.close(); |
3b7d51ed4c65
Push: phase3 - update matching remote bookmarks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
645
diff
changeset
|
415 return rv; |
3b7d51ed4c65
Push: phase3 - update matching remote bookmarks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
645
diff
changeset
|
416 } catch (IOException ex) { |
687
9859fcea475d
Towards ssh remote repositories: refactor HgRemoteRepository - move http related code to HttpConnector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
685
diff
changeset
|
417 throw new HgRemoteConnectionException("Communication failure", ex).setRemoteCommand(CMD_LISTKEYS).setServerInfo(getLocation()); |
646
3b7d51ed4c65
Push: phase3 - update matching remote bookmarks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
645
diff
changeset
|
418 } finally { |
687
9859fcea475d
Towards ssh remote repositories: refactor HgRemoteRepository - move http related code to HttpConnector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
685
diff
changeset
|
419 remote.sessionEnd(); |
646
3b7d51ed4c65
Push: phase3 - update matching remote bookmarks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
645
diff
changeset
|
420 } |
3b7d51ed4c65
Push: phase3 - update matching remote bookmarks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
645
diff
changeset
|
421 } |
176
a8df7162ec75
Extracting complete branch using remote between call to detect incoming changes is done. Arguments reorderd in remote repo to better match Hg server ideology, not my mental convenience
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
172
diff
changeset
|
422 |
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:
651
diff
changeset
|
423 private boolean pushkey(String opName, String namespace, String key, String oldValue, String newValue) throws HgRemoteConnectionException, HgRuntimeException { |
649
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
424 try { |
687
9859fcea475d
Towards ssh remote repositories: refactor HgRemoteRepository - move http related code to HttpConnector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
685
diff
changeset
|
425 remote.sessionBegin(); |
9859fcea475d
Towards ssh remote repositories: refactor HgRemoteRepository - move http related code to HttpConnector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
685
diff
changeset
|
426 final InputStream is = remote.pushkey(opName, namespace, key, oldValue, newValue); |
649
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
427 int rv = is.read(); |
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
428 is.close(); |
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
429 return rv == '1'; |
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
430 } catch (IOException ex) { |
687
9859fcea475d
Towards ssh remote repositories: refactor HgRemoteRepository - move http related code to HttpConnector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
685
diff
changeset
|
431 throw new HgRemoteConnectionException("Communication failure", ex).setRemoteCommand(CMD_PUSHKEY).setServerInfo(getLocation()); |
649
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
432 } finally { |
687
9859fcea475d
Towards ssh remote repositories: refactor HgRemoteRepository - move http related code to HttpConnector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
685
diff
changeset
|
433 remote.sessionEnd(); |
645
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
434 } |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
435 } |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
436 |
697
24f4efedc9d5
Respect the fact ssh and http protocols use different compression approach to sent changegroup data
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
687
diff
changeset
|
437 private File writeBundle(InputStream is) throws IOException { |
646
3b7d51ed4c65
Push: phase3 - update matching remote bookmarks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
645
diff
changeset
|
438 File tf = File.createTempFile("hg4j-bundle-", null); |
697
24f4efedc9d5
Respect the fact ssh and http protocols use different compression approach to sent changegroup data
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
687
diff
changeset
|
439 new FileUtils(sessionContext.getLog(), this).write(is, tf); |
24f4efedc9d5
Respect the fact ssh and http protocols use different compression approach to sent changegroup data
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
687
diff
changeset
|
440 is.close(); |
179
da426c2fe1ec
Support for changegroup wire command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
178
diff
changeset
|
441 return tf; |
da426c2fe1ec
Support for changegroup wire command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
178
diff
changeset
|
442 } |
da426c2fe1ec
Support for changegroup wire command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
178
diff
changeset
|
443 |
178
62665d8f0686
Complete logic to discover all branches missing locally. Most of wire protocol in HgRemoteRepository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
177
diff
changeset
|
444 |
176
a8df7162ec75
Extracting complete branch using remote between call to detect incoming changes is done. Arguments reorderd in remote repo to better match Hg server ideology, not my mental convenience
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
172
diff
changeset
|
445 public static final class Range { |
a8df7162ec75
Extracting complete branch using remote between call to detect incoming changes is done. Arguments reorderd in remote repo to better match Hg server ideology, not my mental convenience
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
172
diff
changeset
|
446 /** |
a8df7162ec75
Extracting complete branch using remote between call to detect incoming changes is done. Arguments reorderd in remote repo to better match Hg server ideology, not my mental convenience
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
172
diff
changeset
|
447 * Root of the range, earlier revision |
a8df7162ec75
Extracting complete branch using remote between call to detect incoming changes is done. Arguments reorderd in remote repo to better match Hg server ideology, not my mental convenience
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
172
diff
changeset
|
448 */ |
a8df7162ec75
Extracting complete branch using remote between call to detect incoming changes is done. Arguments reorderd in remote repo to better match Hg server ideology, not my mental convenience
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
172
diff
changeset
|
449 public final Nodeid start; |
a8df7162ec75
Extracting complete branch using remote between call to detect incoming changes is done. Arguments reorderd in remote repo to better match Hg server ideology, not my mental convenience
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
172
diff
changeset
|
450 /** |
a8df7162ec75
Extracting complete branch using remote between call to detect incoming changes is done. Arguments reorderd in remote repo to better match Hg server ideology, not my mental convenience
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
172
diff
changeset
|
451 * Head of the range, later revision. |
a8df7162ec75
Extracting complete branch using remote between call to detect incoming changes is done. Arguments reorderd in remote repo to better match Hg server ideology, not my mental convenience
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
172
diff
changeset
|
452 */ |
a8df7162ec75
Extracting complete branch using remote between call to detect incoming changes is done. Arguments reorderd in remote repo to better match Hg server ideology, not my mental convenience
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
172
diff
changeset
|
453 public final Nodeid end; |
a8df7162ec75
Extracting complete branch using remote between call to detect incoming changes is done. Arguments reorderd in remote repo to better match Hg server ideology, not my mental convenience
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
172
diff
changeset
|
454 |
a8df7162ec75
Extracting complete branch using remote between call to detect incoming changes is done. Arguments reorderd in remote repo to better match Hg server ideology, not my mental convenience
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
172
diff
changeset
|
455 /** |
a8df7162ec75
Extracting complete branch using remote between call to detect incoming changes is done. Arguments reorderd in remote repo to better match Hg server ideology, not my mental convenience
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
172
diff
changeset
|
456 * @param from - root/base revision |
a8df7162ec75
Extracting complete branch using remote between call to detect incoming changes is done. Arguments reorderd in remote repo to better match Hg server ideology, not my mental convenience
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
172
diff
changeset
|
457 * @param to - head/tip revision |
a8df7162ec75
Extracting complete branch using remote between call to detect incoming changes is done. Arguments reorderd in remote repo to better match Hg server ideology, not my mental convenience
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
172
diff
changeset
|
458 */ |
a8df7162ec75
Extracting complete branch using remote between call to detect incoming changes is done. Arguments reorderd in remote repo to better match Hg server ideology, not my mental convenience
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
172
diff
changeset
|
459 public Range(Nodeid from, Nodeid to) { |
a8df7162ec75
Extracting complete branch using remote between call to detect incoming changes is done. Arguments reorderd in remote repo to better match Hg server ideology, not my mental convenience
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
172
diff
changeset
|
460 start = from; |
a8df7162ec75
Extracting complete branch using remote between call to detect incoming changes is done. Arguments reorderd in remote repo to better match Hg server ideology, not my mental convenience
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
172
diff
changeset
|
461 end = to; |
a8df7162ec75
Extracting complete branch using remote between call to detect incoming changes is done. Arguments reorderd in remote repo to better match Hg server ideology, not my mental convenience
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
172
diff
changeset
|
462 } |
685
9897cbfd2790
Towards ssh remote repositories: use ganymed library for ssh transport
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
673
diff
changeset
|
463 |
9897cbfd2790
Towards ssh remote repositories: use ganymed library for ssh transport
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
673
diff
changeset
|
464 /** |
9897cbfd2790
Towards ssh remote repositories: use ganymed library for ssh transport
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
673
diff
changeset
|
465 * Append this range as pair of values 'end-start' to the supplied buffer and return the buffer. |
9897cbfd2790
Towards ssh remote repositories: use ganymed library for ssh transport
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
673
diff
changeset
|
466 */ |
9897cbfd2790
Towards ssh remote repositories: use ganymed library for ssh transport
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
673
diff
changeset
|
467 public StringBuilder append(StringBuilder sb) { |
9897cbfd2790
Towards ssh remote repositories: use ganymed library for ssh transport
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
673
diff
changeset
|
468 sb.append(end.toString()); |
9897cbfd2790
Towards ssh remote repositories: use ganymed library for ssh transport
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
673
diff
changeset
|
469 sb.append('-'); |
9897cbfd2790
Towards ssh remote repositories: use ganymed library for ssh transport
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
673
diff
changeset
|
470 sb.append(start.toString()); |
9897cbfd2790
Towards ssh remote repositories: use ganymed library for ssh transport
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
673
diff
changeset
|
471 return sb; |
9897cbfd2790
Towards ssh remote repositories: use ganymed library for ssh transport
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
673
diff
changeset
|
472 } |
176
a8df7162ec75
Extracting complete branch using remote between call to detect incoming changes is done. Arguments reorderd in remote repo to better match Hg server ideology, not my mental convenience
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
172
diff
changeset
|
473 } |
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
|
474 |
171
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
475 public static final class RemoteBranch { |
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
476 public final Nodeid head, root, p1, p2; |
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
477 |
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
478 public RemoteBranch(Nodeid h, Nodeid r, Nodeid parent1, Nodeid parent2) { |
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
479 head = h; |
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
480 root = r; |
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
481 p1 = parent1; |
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
482 p2 = parent2; |
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
483 } |
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
484 |
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
485 @Override |
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
486 public boolean equals(Object obj) { |
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
487 if (this == obj) { |
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
488 return true; |
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
489 } |
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
490 if (false == obj instanceof RemoteBranch) { |
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
491 return false; |
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
492 } |
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
493 RemoteBranch o = (RemoteBranch) obj; |
274
9fb50c04f03c
Use Nodeid.isNull check instead of NULL.equals
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
215
diff
changeset
|
494 // in fact, p1 and p2 are not supposed to be null, ever (at least for RemoteBranch created from server output) |
171
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
495 return head.equals(o.head) && root.equals(o.root) && (p1 == null && o.p1 == null || p1.equals(o.p1)) && (p2 == null && o.p2 == null || p2.equals(o.p2)); |
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
496 } |
698
822f3a83ff57
in, out and clone tests pass for ssh repositories. Infrastructure to decouple HgRemoteRepository from specific Connector implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
697
diff
changeset
|
497 |
822f3a83ff57
in, out and clone tests pass for ssh repositories. Infrastructure to decouple HgRemoteRepository from specific Connector implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
697
diff
changeset
|
498 @Override |
822f3a83ff57
in, out and clone tests pass for ssh repositories. Infrastructure to decouple HgRemoteRepository from specific Connector implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
697
diff
changeset
|
499 public int hashCode() { |
822f3a83ff57
in, out and clone tests pass for ssh repositories. Infrastructure to decouple HgRemoteRepository from specific Connector implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
697
diff
changeset
|
500 return head.hashCode() ^ root.hashCode(); |
822f3a83ff57
in, out and clone tests pass for ssh repositories. Infrastructure to decouple HgRemoteRepository from specific Connector implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
697
diff
changeset
|
501 } |
822f3a83ff57
in, out and clone tests pass for ssh repositories. Infrastructure to decouple HgRemoteRepository from specific Connector implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
697
diff
changeset
|
502 |
822f3a83ff57
in, out and clone tests pass for ssh repositories. Infrastructure to decouple HgRemoteRepository from specific Connector implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
697
diff
changeset
|
503 @Override |
822f3a83ff57
in, out and clone tests pass for ssh repositories. Infrastructure to decouple HgRemoteRepository from specific Connector implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
697
diff
changeset
|
504 public String toString() { |
822f3a83ff57
in, out and clone tests pass for ssh repositories. Infrastructure to decouple HgRemoteRepository from specific Connector implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
697
diff
changeset
|
505 String none = String.valueOf(-1); |
822f3a83ff57
in, out and clone tests pass for ssh repositories. Infrastructure to decouple HgRemoteRepository from specific Connector implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
697
diff
changeset
|
506 String s1 = p1 == null || p1.isNull() ? none : p1.shortNotation(); |
822f3a83ff57
in, out and clone tests pass for ssh repositories. Infrastructure to decouple HgRemoteRepository from specific Connector implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
697
diff
changeset
|
507 String s2 = p2 == null || p2.isNull() ? none : p2.shortNotation(); |
822f3a83ff57
in, out and clone tests pass for ssh repositories. Infrastructure to decouple HgRemoteRepository from specific Connector implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
697
diff
changeset
|
508 return String.format("RemoteBranch[root: %s, head:%s, p1:%s, p2:%s]", root.shortNotation(), head.shortNotation(), s1, s2); |
822f3a83ff57
in, out and clone tests pass for ssh repositories. Infrastructure to decouple HgRemoteRepository from specific Connector implementation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
697
diff
changeset
|
509 } |
171
2c3e96674e2a
Towards outgoing changes - initial detection logic, get connected with remote repo stub
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
510 } |
649
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
511 |
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
512 public static final class Bookmarks implements Iterable<Pair<String, Nodeid>> { |
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
513 private final List<Pair<String, Nodeid>> bm; |
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
514 |
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
515 private Bookmarks(List<Pair<String, Nodeid>> bookmarks) { |
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
516 bm = bookmarks; |
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
517 } |
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
518 |
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
519 public Iterator<Pair<String, Nodeid>> iterator() { |
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
520 return bm.iterator(); |
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
521 } |
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
522 } |
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
523 |
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
524 public static final class Phases { |
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
525 private final boolean pub; |
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
526 private final List<Nodeid> droots; |
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
527 |
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
528 private Phases(boolean publishing, List<Nodeid> draftRoots) { |
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
529 pub = publishing; |
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
530 droots = draftRoots; |
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
531 } |
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
532 |
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
533 /** |
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
534 * Non-publishing servers may (shall?) respond with a list of draft roots. |
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
535 * This method doesn't make sense when {@link #isPublishingServer()} is <code>true</code> |
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
536 * |
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
537 * @return list of draft roots on remote server |
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
538 */ |
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
539 public List<Nodeid> draftRoots() { |
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
540 return droots; |
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
541 } |
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
542 |
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
543 /** |
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
544 * @return <code>true</code> if revisions on remote server shall be deemed published (either |
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
545 * old server w/o explicit setting, or a new one with <code>phases.publish == true</code>) |
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
546 */ |
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
547 public boolean isPublishingServer() { |
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
548 return pub; |
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
549 } |
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
550 } |
699
a483b2b68a2e
Provisional APIs and respective implementation for http, https and ssh remote repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
698
diff
changeset
|
551 |
a483b2b68a2e
Provisional APIs and respective implementation for http, https and ssh remote repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
698
diff
changeset
|
552 /** |
a483b2b68a2e
Provisional APIs and respective implementation for http, https and ssh remote repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
698
diff
changeset
|
553 * Session context ({@link SessionContext#getRemoteDescriptor(URI)} gives descriptor of remote when asked. |
a483b2b68a2e
Provisional APIs and respective implementation for http, https and ssh remote repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
698
diff
changeset
|
554 * Clients may supply own descriptors e.g. if need to pass extra information into Authenticator. |
a483b2b68a2e
Provisional APIs and respective implementation for http, https and ssh remote repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
698
diff
changeset
|
555 * Present implementation of {@link HgRemoteRepository} will be happy with any {@link RemoteDescriptor} subclass |
a483b2b68a2e
Provisional APIs and respective implementation for http, https and ssh remote repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
698
diff
changeset
|
556 * as long as it's {@link Adaptable adaptable} to {@link RemoteConnectorDescriptor} |
a483b2b68a2e
Provisional APIs and respective implementation for http, https and ssh remote repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
698
diff
changeset
|
557 * @since 1.2 |
a483b2b68a2e
Provisional APIs and respective implementation for http, https and ssh remote repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
698
diff
changeset
|
558 */ |
a483b2b68a2e
Provisional APIs and respective implementation for http, https and ssh remote repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
698
diff
changeset
|
559 @Experimental(reason="Provisional API. Work in progress") |
a483b2b68a2e
Provisional APIs and respective implementation for http, https and ssh remote repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
698
diff
changeset
|
560 public interface RemoteDescriptor { |
a483b2b68a2e
Provisional APIs and respective implementation for http, https and ssh remote repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
698
diff
changeset
|
561 /** |
a483b2b68a2e
Provisional APIs and respective implementation for http, https and ssh remote repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
698
diff
changeset
|
562 * @return remote location, never <code>null</code> |
a483b2b68a2e
Provisional APIs and respective implementation for http, https and ssh remote repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
698
diff
changeset
|
563 */ |
a483b2b68a2e
Provisional APIs and respective implementation for http, https and ssh remote repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
698
diff
changeset
|
564 URI getURI(); |
a483b2b68a2e
Provisional APIs and respective implementation for http, https and ssh remote repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
698
diff
changeset
|
565 } |
170
71ddbf8603e8
Initial clone: populate given directory from a bundle. Everything but remote server access is there, albeit prototype code style
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
566 } |