diff src/org/tmatesoft/hg/core/Nodeid.java @ 170:71ddbf8603e8

Initial clone: populate given directory from a bundle. Everything but remote server access is there, albeit prototype code style
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Wed, 23 Mar 2011 20:46:00 +0100
parents 1a7a9a20e1f9
children 3a7696fb457c
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/core/Nodeid.java	Wed Mar 23 14:13:11 2011 +0100
+++ b/src/org/tmatesoft/hg/core/Nodeid.java	Wed Mar 23 20:46:00 2011 +0100
@@ -30,7 +30,7 @@
  * @author TMate Software Ltd.
  *
  */
-public final class Nodeid {
+public final class Nodeid implements Comparable<Nodeid> {
 	
 	/**
 	 * <b>nullid</b>, empty root revision.
@@ -72,6 +72,18 @@
 		return Arrays.equals(this.binaryData, buf);
 	}
 	
+	public int compareTo(Nodeid o) {
+		if (this == o) {
+			return 0;
+		}
+		for (int i = 0; i < 20; i++) {
+			if (binaryData[i] != o.binaryData[i]) {
+				return binaryData[i] < o.binaryData[i] ? -1 : 1;
+			}
+		}
+		return 0;
+	}
+	
 	@Override
 	public String toString() {
 		// XXX may want to output just single 0 for the NULL id?