int (VcsRevisionNumber o) { // boundary cases if (this == o) { return 0; } if (!(o instanceof HgRevisionNumber other)) { return -1; } if (changeset.equals(other.changeset)) { return 0; } // One of the revisions is local. Local is "greater" than any from the history. if (changeset.isEmpty()) { return 1; } if (other.changeset.isEmpty()) { return -1; } // compare revision numbers. final int revCompare = java.lang.Long.valueOf(getRevisionNumber()).compareTo(java.lang.Long.valueOf(other.getRevisionNumber())); if (revCompare != 0) { return revCompare; } else if (getShortHash(changeset).equals(getShortHash(other.changeset))) { //if local revision numbers are equal then it's enough to compare 12 symbols hash; collisions couldn't occur return 0; } // If they are equal, the working revision is greater. if (isWorkingVersion) { return other.isWorkingVersion ? 0 : 1; } else { return other.isWorkingVersion ? -1 : 0; } }