diff src/org/tmatesoft/hg/repo/HgRemoteRepository.java @ 202:706bcc7cfee4

Basic test for HgIncomingCommand. Fix RepositoryComparator for cases when whole repository is unknown. Respect freshly initialized (empty) repositories in general.
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Tue, 26 Apr 2011 02:50:06 +0200
parents 9b99d27aeddc
children 66fd2c73c56f
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/repo/HgRemoteRepository.java	Thu Apr 21 19:16:45 2011 +0200
+++ b/src/org/tmatesoft/hg/repo/HgRemoteRepository.java	Tue Apr 26 02:50:06 2011 +0200
@@ -303,6 +303,9 @@
 	}
 
 	/*
+	 * XXX need to describe behavior when roots arg is empty; our RepositoryComparator code currently returns empty lists when
+	 * no common elements found, which in turn means we need to query changes starting with NULL nodeid.
+	 * 
 	 * WireProtocol wiki: roots = a list of the latest nodes on every service side changeset branch that both the client and server know about.
 	 * 
 	 * Perhaps, shall be named 'changegroup'
@@ -316,9 +319,10 @@
 	 * as one may expect according to http://mercurial.selenic.com/wiki/BundleFormat)
 	 */
 	public HgBundle getChanges(List<Nodeid> roots) throws HgException {
-		StringBuilder sb = new StringBuilder(20 + roots.size() * 41);
+		List<Nodeid> _roots = roots.isEmpty() ? Collections.singletonList(Nodeid.NULL) : roots;
+		StringBuilder sb = new StringBuilder(20 + _roots.size() * 41);
 		sb.append("roots=");
-		for (Nodeid n : roots) {
+		for (Nodeid n : _roots) {
 			sb.append(n.toString());
 			sb.append('+');
 		}