comparison cmdline/org/tmatesoft/hg/console/Incoming.java @ 171:2c3e96674e2a

Towards outgoing changes - initial detection logic, get connected with remote repo stub
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Fri, 25 Mar 2011 00:05:52 +0100
parents a3a2e5deb320
children 4bf061a7c001
comparison
equal deleted inserted replaced
170:71ddbf8603e8 171:2c3e96674e2a
14 * the terms of a license other than GNU General Public License 14 * the terms of a license other than GNU General Public License
15 * contact TMate Software at support@hg4j.com 15 * contact TMate Software at support@hg4j.com
16 */ 16 */
17 package org.tmatesoft.hg.console; 17 package org.tmatesoft.hg.console;
18 18
19 import static org.tmatesoft.hg.core.Nodeid.NULL;
20
19 import java.util.Collection; 21 import java.util.Collection;
20 import java.util.HashSet; 22 import java.util.HashSet;
21 import java.util.LinkedHashSet; 23 import java.util.LinkedHashSet;
22 import java.util.LinkedList; 24 import java.util.LinkedList;
23 import java.util.List; 25 import java.util.List;
24 26
25 import org.tmatesoft.hg.core.Nodeid; 27 import org.tmatesoft.hg.core.Nodeid;
26 import org.tmatesoft.hg.repo.HgChangelog; 28 import org.tmatesoft.hg.repo.HgChangelog;
29 import org.tmatesoft.hg.repo.HgRemoteRepository.RemoteBranch;
27 import org.tmatesoft.hg.repo.HgRepository; 30 import org.tmatesoft.hg.repo.HgRepository;
28 31
29 32
30 /** 33 /**
31 * WORK IN PROGRESS, DO NOT USE 34 * WORK IN PROGRESS, DO NOT USE
139 } 142 }
140 } 143 }
141 144
142 } 145 }
143 146
144 static final class RemoteBranch {
145 public Nodeid head, root, p1, p2;
146
147 @Override
148 public boolean equals(Object obj) {
149 if (this == obj) {
150 return true;
151 }
152 if (false == obj instanceof RemoteBranch) {
153 return false;
154 }
155 RemoteBranch o = (RemoteBranch) obj;
156 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));
157 }
158 }
159 147
160 private static void remoteBranches(Collection<Nodeid> unknownRemoteHeads, List<RemoteBranch> remoteBranches) { 148 private static void remoteBranches(Collection<Nodeid> unknownRemoteHeads, List<RemoteBranch> remoteBranches) {
161 // discovery.findcommonincoming:
162 // unknown = remote.branches(remote.heads);
163 // sent: cmd=branches&roots=d6d2a630f4a6d670c90a5ca909150f2b426ec88f+
164 // received: d6d2a630f4a6d670c90a5ca909150f2b426ec88f dbd663faec1f0175619cf7668bddc6350548b8d6 0000000000000000000000000000000000000000 0000000000000000000000000000000000000000
165 // head, root, first parent, second parent
166 // 149 //
167 // TODO implement this with remote access 150 // TODO implement this with remote access
168 // 151 //
169 RemoteBranch rb = new RemoteBranch(); 152 RemoteBranch rb = new RemoteBranch(unknownRemoteHeads.iterator().next(), Nodeid.fromAscii("dbd663faec1f0175619cf7668bddc6350548b8d6"), NULL, NULL);
170 rb.head = unknownRemoteHeads.iterator().next();
171 rb.root = Nodeid.fromAscii("dbd663faec1f0175619cf7668bddc6350548b8d6".getBytes(), 0, 40);
172 remoteBranches.add(rb); 153 remoteBranches.add(rb);
173 } 154 }
174 155
175 private static List<Nodeid> remoteBetween(Nodeid nodeid1, Nodeid nodeid2, List<Nodeid> list) { 156 private static List<Nodeid> remoteBetween(Nodeid nodeid1, Nodeid nodeid2, List<Nodeid> list) {
176 // sent: cmd=between&pairs=d6d2a630f4a6d670c90a5ca909150f2b426ec88f-dbd663faec1f0175619cf7668bddc6350548b8d6 157 // sent: cmd=between&pairs=d6d2a630f4a6d670c90a5ca909150f2b426ec88f-dbd663faec1f0175619cf7668bddc6350548b8d6