annotate src/org/tmatesoft/hg/core/Nodeid.java @ 672:d2552e6a5af6

Effective update of HgParentChildMap when repository got few revisions added
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Fri, 12 Jul 2013 16:29:06 +0200
parents d29d9dc6c128
children
rev   line source
20
11cfabe692b3 Status operation for two repository revisions (no local dir involved)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 13
diff changeset
1 /*
535
d9c07e1432c4 Issue 42: tolerate lines in .hgtags that do not conform to its format specification
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 500
diff changeset
2 * Copyright (c) 2010-2013 TMate Software Ltd
74
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 46
diff changeset
3 *
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 46
diff changeset
4 * This program is free software; you can redistribute it and/or modify
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 46
diff changeset
5 * it under the terms of the GNU General Public License as published by
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 46
diff changeset
6 * the Free Software Foundation; version 2 of the License.
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 46
diff changeset
7 *
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 46
diff changeset
8 * This program is distributed in the hope that it will be useful,
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 46
diff changeset
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 46
diff changeset
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 46
diff changeset
11 * GNU General Public License for more details.
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 46
diff changeset
12 *
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 46
diff changeset
13 * For information on how to redistribute this software under
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 46
diff changeset
14 * the terms of a license other than GNU General Public License
102
a3a2e5deb320 Updated contact address to support@hg4j.com
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 78
diff changeset
15 * contact TMate Software at support@hg4j.com
0
dbd663faec1f Basic changelog parsing
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
16 */
74
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 46
diff changeset
17 package org.tmatesoft.hg.core;
0
dbd663faec1f Basic changelog parsing
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
18
74
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 46
diff changeset
19 import static org.tmatesoft.hg.internal.DigestHelper.toHexString;
31
346b66add79d Basic lookup for incoming changes
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 28
diff changeset
20
24
d4fdd1845b3f Nodeid with array of exactly 20 bytes
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 22
diff changeset
21 import java.util.Arrays;
d4fdd1845b3f Nodeid with array of exactly 20 bytes
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 22
diff changeset
22
266
0a2f445de774 Improve manifest parsing: reduce number of arrays instantiated for Nodeid
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 262
diff changeset
23 import org.tmatesoft.hg.internal.DigestHelper;
0a2f445de774 Improve manifest parsing: reduce number of arrays instantiated for Nodeid
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 262
diff changeset
24
20
11cfabe692b3 Status operation for two repository revisions (no local dir involved)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 13
diff changeset
25
0
dbd663faec1f Basic changelog parsing
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
26
dbd663faec1f Basic changelog parsing
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
27 /**
74
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 46
diff changeset
28 * A 20-bytes (40 characters) long hash value to identify a revision.
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 46
diff changeset
29 * @see http://mercurial.selenic.com/wiki/Nodeid
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 46
diff changeset
30 *
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 46
diff changeset
31 * @author Artem Tikhomirov
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 46
diff changeset
32 * @author TMate Software Ltd.
0
dbd663faec1f Basic changelog parsing
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
33 *
dbd663faec1f Basic changelog parsing
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
34 */
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: 148
diff changeset
35 public final class Nodeid implements Comparable<Nodeid> {
598
d29d9dc6c128 Utilize the fact nodeids are very different and are read anyway to speed up reverse lookup
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 535
diff changeset
36
d29d9dc6c128 Utilize the fact nodeids are very different and are read anyway to speed up reverse lookup
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 535
diff changeset
37 /**
d29d9dc6c128 Utilize the fact nodeids are very different and are read anyway to speed up reverse lookup
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 535
diff changeset
38 * Length of the nodeid in bytes
d29d9dc6c128 Utilize the fact nodeids are very different and are read anyway to speed up reverse lookup
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 535
diff changeset
39 */
d29d9dc6c128 Utilize the fact nodeids are very different and are read anyway to speed up reverse lookup
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 535
diff changeset
40 public static final int SIZE = 20;
d29d9dc6c128 Utilize the fact nodeids are very different and are read anyway to speed up reverse lookup
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 535
diff changeset
41
d29d9dc6c128 Utilize the fact nodeids are very different and are read anyway to speed up reverse lookup
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 535
diff changeset
42 /**
d29d9dc6c128 Utilize the fact nodeids are very different and are read anyway to speed up reverse lookup
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 535
diff changeset
43 * Length of nodeid string representation, in bytes
d29d9dc6c128 Utilize the fact nodeids are very different and are read anyway to speed up reverse lookup
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 535
diff changeset
44 */
d29d9dc6c128 Utilize the fact nodeids are very different and are read anyway to speed up reverse lookup
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 535
diff changeset
45 public static final int SIZE_ASCII = 40;
d29d9dc6c128 Utilize the fact nodeids are very different and are read anyway to speed up reverse lookup
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 535
diff changeset
46
74
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 46
diff changeset
47 /**
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 46
diff changeset
48 * <b>nullid</b>, empty root revision.
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 46
diff changeset
49 */
598
d29d9dc6c128 Utilize the fact nodeids are very different and are read anyway to speed up reverse lookup
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 535
diff changeset
50 public static final Nodeid NULL = new Nodeid(new byte[SIZE], false);
74
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 46
diff changeset
51
0
dbd663faec1f Basic changelog parsing
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
52 private final byte[] binaryData;
dbd663faec1f Basic changelog parsing
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
53
24
d4fdd1845b3f Nodeid with array of exactly 20 bytes
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 22
diff changeset
54 /**
74
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 46
diff changeset
55 * @param binaryRepresentation - array of exactly 20 bytes
148
1a7a9a20e1f9 Exceptions, javadoc. Initial cancel and progress support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 125
diff changeset
56 * @param shallClone - true if array is subject to future modification and shall be copied, not referenced
500
465316bf97e8 Tailored subclass of IAE for malformed Nodeids:HgBadNodeidFormatException
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 304
diff changeset
57 * @throws HgBadNodeidFormatException custom {@link IllegalArgumentException} subclass if supplied binary representation doesn't correspond to 20 bytes of sha1 digest
24
d4fdd1845b3f Nodeid with array of exactly 20 bytes
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 22
diff changeset
58 */
28
b2251b7a9823 Explicit cons arg for clone is more error-prone
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 24
diff changeset
59 public Nodeid(byte[] binaryRepresentation, boolean shallClone) {
0
dbd663faec1f Basic changelog parsing
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
60 // 5 int fields => 32 bytes
197
3a7696fb457c Investigate optimization options to allow fast processing of huge repositories. Fix defect in StatusCollector that lead to wrong result comparing first revision to empty repo (-1 to 0), due to same TIP constant value
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 170
diff changeset
61 // byte[20] => 48 bytes (16 bytes is Nodeid with one field, 32 bytes for byte[20]
598
d29d9dc6c128 Utilize the fact nodeids are very different and are read anyway to speed up reverse lookup
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 535
diff changeset
62 if (binaryRepresentation == null || binaryRepresentation.length != SIZE) {
500
465316bf97e8 Tailored subclass of IAE for malformed Nodeids:HgBadNodeidFormatException
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 304
diff changeset
63 throw new HgBadNodeidFormatException(String.format("Bad value: %s", String.valueOf(binaryRepresentation)));
24
d4fdd1845b3f Nodeid with array of exactly 20 bytes
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 22
diff changeset
64 }
197
3a7696fb457c Investigate optimization options to allow fast processing of huge repositories. Fix defect in StatusCollector that lead to wrong result comparing first revision to empty repo (-1 to 0), due to same TIP constant value
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 170
diff changeset
65 /*
3a7696fb457c Investigate optimization options to allow fast processing of huge repositories. Fix defect in StatusCollector that lead to wrong result comparing first revision to empty repo (-1 to 0), due to same TIP constant value
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 170
diff changeset
66 * byte[].clone() is not reflected when ran with -agentlib:hprof=heap=sites
3a7696fb457c Investigate optimization options to allow fast processing of huge repositories. Fix defect in StatusCollector that lead to wrong result comparing first revision to empty repo (-1 to 0), due to same TIP constant value
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 170
diff changeset
67 * thus not to get puzzled why there are N Nodeids and much less byte[] instances,
3a7696fb457c Investigate optimization options to allow fast processing of huge repositories. Fix defect in StatusCollector that lead to wrong result comparing first revision to empty repo (-1 to 0), due to same TIP constant value
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 170
diff changeset
68 * may use following code to see N byte[] as well.
3a7696fb457c Investigate optimization options to allow fast processing of huge repositories. Fix defect in StatusCollector that lead to wrong result comparing first revision to empty repo (-1 to 0), due to same TIP constant value
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 170
diff changeset
69 *
3a7696fb457c Investigate optimization options to allow fast processing of huge repositories. Fix defect in StatusCollector that lead to wrong result comparing first revision to empty repo (-1 to 0), due to same TIP constant value
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 170
diff changeset
70 if (shallClone) {
3a7696fb457c Investigate optimization options to allow fast processing of huge repositories. Fix defect in StatusCollector that lead to wrong result comparing first revision to empty repo (-1 to 0), due to same TIP constant value
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 170
diff changeset
71 binaryData = new byte[20];
3a7696fb457c Investigate optimization options to allow fast processing of huge repositories. Fix defect in StatusCollector that lead to wrong result comparing first revision to empty repo (-1 to 0), due to same TIP constant value
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 170
diff changeset
72 System.arraycopy(binaryRepresentation, 0, binaryData, 0, 20);
3a7696fb457c Investigate optimization options to allow fast processing of huge repositories. Fix defect in StatusCollector that lead to wrong result comparing first revision to empty repo (-1 to 0), due to same TIP constant value
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 170
diff changeset
73 } else {
3a7696fb457c Investigate optimization options to allow fast processing of huge repositories. Fix defect in StatusCollector that lead to wrong result comparing first revision to empty repo (-1 to 0), due to same TIP constant value
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 170
diff changeset
74 binaryData = binaryRepresentation;
3a7696fb457c Investigate optimization options to allow fast processing of huge repositories. Fix defect in StatusCollector that lead to wrong result comparing first revision to empty repo (-1 to 0), due to same TIP constant value
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 170
diff changeset
75 }
3a7696fb457c Investigate optimization options to allow fast processing of huge repositories. Fix defect in StatusCollector that lead to wrong result comparing first revision to empty repo (-1 to 0), due to same TIP constant value
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 170
diff changeset
76 */
3a7696fb457c Investigate optimization options to allow fast processing of huge repositories. Fix defect in StatusCollector that lead to wrong result comparing first revision to empty repo (-1 to 0), due to same TIP constant value
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 170
diff changeset
77 binaryData = shallClone ? binaryRepresentation.clone() : binaryRepresentation;
0
dbd663faec1f Basic changelog parsing
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
78 }
dbd663faec1f Basic changelog parsing
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
79
24
d4fdd1845b3f Nodeid with array of exactly 20 bytes
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 22
diff changeset
80 @Override
d4fdd1845b3f Nodeid with array of exactly 20 bytes
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 22
diff changeset
81 public int hashCode() {
598
d29d9dc6c128 Utilize the fact nodeids are very different and are read anyway to speed up reverse lookup
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 535
diff changeset
82 return hashCode(binaryData);
d29d9dc6c128 Utilize the fact nodeids are very different and are read anyway to speed up reverse lookup
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 535
diff changeset
83 }
d29d9dc6c128 Utilize the fact nodeids are very different and are read anyway to speed up reverse lookup
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 535
diff changeset
84
d29d9dc6c128 Utilize the fact nodeids are very different and are read anyway to speed up reverse lookup
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 535
diff changeset
85 /**
d29d9dc6c128 Utilize the fact nodeids are very different and are read anyway to speed up reverse lookup
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 535
diff changeset
86 * Handy alternative to calculate hashcode without need to get {@link Nodeid} instance
d29d9dc6c128 Utilize the fact nodeids are very different and are read anyway to speed up reverse lookup
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 535
diff changeset
87 * @param binaryNodeid array of exactly 20 bytes
d29d9dc6c128 Utilize the fact nodeids are very different and are read anyway to speed up reverse lookup
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 535
diff changeset
88 * @return same value as <code>new Nodeid(binaryNodeid, false).hashCode()</code>
d29d9dc6c128 Utilize the fact nodeids are very different and are read anyway to speed up reverse lookup
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 535
diff changeset
89 */
d29d9dc6c128 Utilize the fact nodeids are very different and are read anyway to speed up reverse lookup
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 535
diff changeset
90 public static int hashCode(byte[] binaryNodeid) {
d29d9dc6c128 Utilize the fact nodeids are very different and are read anyway to speed up reverse lookup
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 535
diff changeset
91 assert binaryNodeid.length == SIZE;
46
4022c34a4804 Better hashCode impl
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 41
diff changeset
92 // digest (part thereof) seems to be nice candidate for the hashCode
598
d29d9dc6c128 Utilize the fact nodeids are very different and are read anyway to speed up reverse lookup
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 535
diff changeset
93 byte[] b = binaryNodeid;
46
4022c34a4804 Better hashCode impl
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 41
diff changeset
94 return b[0] << 24 | (b[1] & 0xFF) << 16 | (b[2] & 0xFF) << 8 | (b[3] & 0xFF);
24
d4fdd1845b3f Nodeid with array of exactly 20 bytes
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 22
diff changeset
95 }
d4fdd1845b3f Nodeid with array of exactly 20 bytes
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 22
diff changeset
96
d4fdd1845b3f Nodeid with array of exactly 20 bytes
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 22
diff changeset
97 @Override
d4fdd1845b3f Nodeid with array of exactly 20 bytes
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 22
diff changeset
98 public boolean equals(Object o) {
304
85b8efde5586 Use memory-friendly set implementation to canonicalize filenames and nodeids
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 301
diff changeset
99 if (o == this) {
85b8efde5586 Use memory-friendly set implementation to canonicalize filenames and nodeids
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 301
diff changeset
100 return true;
85b8efde5586 Use memory-friendly set implementation to canonicalize filenames and nodeids
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 301
diff changeset
101 }
24
d4fdd1845b3f Nodeid with array of exactly 20 bytes
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 22
diff changeset
102 if (o instanceof Nodeid) {
304
85b8efde5586 Use memory-friendly set implementation to canonicalize filenames and nodeids
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 301
diff changeset
103 return equalsTo(((Nodeid) o).binaryData);
24
d4fdd1845b3f Nodeid with array of exactly 20 bytes
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 22
diff changeset
104 }
d4fdd1845b3f Nodeid with array of exactly 20 bytes
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 22
diff changeset
105 return false;
22
603806cd2dc6 Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 20
diff changeset
106 }
603806cd2dc6 Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 20
diff changeset
107
603806cd2dc6 Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 20
diff changeset
108 public boolean equalsTo(byte[] buf) {
24
d4fdd1845b3f Nodeid with array of exactly 20 bytes
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 22
diff changeset
109 return Arrays.equals(this.binaryData, buf);
22
603806cd2dc6 Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 20
diff changeset
110 }
603806cd2dc6 Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 20
diff changeset
111
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: 148
diff changeset
112 public int compareTo(Nodeid o) {
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: 148
diff changeset
113 if (this == o) {
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: 148
diff changeset
114 return 0;
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: 148
diff changeset
115 }
598
d29d9dc6c128 Utilize the fact nodeids are very different and are read anyway to speed up reverse lookup
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 535
diff changeset
116 for (int i = 0; i < SIZE; i++) {
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: 148
diff changeset
117 if (binaryData[i] != o.binaryData[i]) {
301
88c58edc0857 Remarks about sorting order
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 266
diff changeset
118 // if we need truly ascending sort, need to respect byte sign
88c58edc0857 Remarks about sorting order
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 266
diff changeset
119 // return (binaryData[i] & 0xFF) < (o.binaryData[i] & 0xFF) ? -1 : 1;
88c58edc0857 Remarks about sorting order
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 266
diff changeset
120 // however, for our purposes partial sort is pretty enough
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: 148
diff changeset
121 return binaryData[i] < o.binaryData[i] ? -1 : 1;
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: 148
diff changeset
122 }
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: 148
diff changeset
123 }
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: 148
diff changeset
124 return 0;
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: 148
diff changeset
125 }
244
4b661efb9374 Use updated location of cache files (cache/ folder instead of .cache filename extension). Provide means to update (write down) cache for subsequent uses
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 197
diff changeset
126
4b661efb9374 Use updated location of cache files (cache/ folder instead of .cache filename extension). Provide means to update (write down) cache for subsequent uses
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 197
diff changeset
127 /**
4b661efb9374 Use updated location of cache files (cache/ folder instead of .cache filename extension). Provide means to update (write down) cache for subsequent uses
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 197
diff changeset
128 * Complete string representation of this Nodeid.
4b661efb9374 Use updated location of cache files (cache/ folder instead of .cache filename extension). Provide means to update (write down) cache for subsequent uses
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 197
diff changeset
129 */
0
dbd663faec1f Basic changelog parsing
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
130 @Override
dbd663faec1f Basic changelog parsing
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
131 public String toString() {
34
51bc56c0addd Static Nodeid creation methods to reuse NULL id
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 31
diff changeset
132 // XXX may want to output just single 0 for the NULL id?
31
346b66add79d Basic lookup for incoming changes
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 28
diff changeset
133 return toHexString(binaryData, 0, binaryData.length);
0
dbd663faec1f Basic changelog parsing
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
134 }
31
346b66add79d Basic lookup for incoming changes
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 28
diff changeset
135
346b66add79d Basic lookup for incoming changes
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 28
diff changeset
136 public String shortNotation() {
346b66add79d Basic lookup for incoming changes
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 28
diff changeset
137 return toHexString(binaryData, 0, 6);
346b66add79d Basic lookup for incoming changes
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 28
diff changeset
138 }
34
51bc56c0addd Static Nodeid creation methods to reuse NULL id
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 31
diff changeset
139
51bc56c0addd Static Nodeid creation methods to reuse NULL id
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 31
diff changeset
140 public boolean isNull() {
51bc56c0addd Static Nodeid creation methods to reuse NULL id
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 31
diff changeset
141 if (this == NULL) {
51bc56c0addd Static Nodeid creation methods to reuse NULL id
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 31
diff changeset
142 return true;
51bc56c0addd Static Nodeid creation methods to reuse NULL id
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 31
diff changeset
143 }
598
d29d9dc6c128 Utilize the fact nodeids are very different and are read anyway to speed up reverse lookup
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 535
diff changeset
144 for (int i = 0; i < SIZE; i++) {
34
51bc56c0addd Static Nodeid creation methods to reuse NULL id
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 31
diff changeset
145 if (this.binaryData[i] != 0) {
51bc56c0addd Static Nodeid creation methods to reuse NULL id
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 31
diff changeset
146 return false;
51bc56c0addd Static Nodeid creation methods to reuse NULL id
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 31
diff changeset
147 }
51bc56c0addd Static Nodeid creation methods to reuse NULL id
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 31
diff changeset
148 }
51bc56c0addd Static Nodeid creation methods to reuse NULL id
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 31
diff changeset
149 return true;
51bc56c0addd Static Nodeid creation methods to reuse NULL id
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 31
diff changeset
150 }
51bc56c0addd Static Nodeid creation methods to reuse NULL id
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 31
diff changeset
151
74
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 46
diff changeset
152 // copy
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 46
diff changeset
153 public byte[] toByteArray() {
41
858d1b2458cb Check integrity for bundle changelog. Sort nodeids when calculating hash
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 34
diff changeset
154 return binaryData.clone();
858d1b2458cb Check integrity for bundle changelog. Sort nodeids when calculating hash
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 34
diff changeset
155 }
858d1b2458cb Check integrity for bundle changelog. Sort nodeids when calculating hash
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 34
diff changeset
156
148
1a7a9a20e1f9 Exceptions, javadoc. Initial cancel and progress support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 125
diff changeset
157 /**
1a7a9a20e1f9 Exceptions, javadoc. Initial cancel and progress support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 125
diff changeset
158 * Factory for {@link Nodeid Nodeids}.
1a7a9a20e1f9 Exceptions, javadoc. Initial cancel and progress support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 125
diff changeset
159 * Primary difference with cons is handling of NULL id (this method returns constant) and control over array
1a7a9a20e1f9 Exceptions, javadoc. Initial cancel and progress support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 125
diff changeset
160 * duplication - this method always makes a copy of an array passed
1a7a9a20e1f9 Exceptions, javadoc. Initial cancel and progress support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 125
diff changeset
161 * @param binaryRepresentation - byte array of a length at least offset + 20
1a7a9a20e1f9 Exceptions, javadoc. Initial cancel and progress support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 125
diff changeset
162 * @param offset - index in the array to start from
500
465316bf97e8 Tailored subclass of IAE for malformed Nodeids:HgBadNodeidFormatException
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 304
diff changeset
163 * @throws HgBadNodeidFormatException custom {@link IllegalArgumentException} subclass when arguments don't select 20 bytes
148
1a7a9a20e1f9 Exceptions, javadoc. Initial cancel and progress support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 125
diff changeset
164 */
34
51bc56c0addd Static Nodeid creation methods to reuse NULL id
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 31
diff changeset
165 public static Nodeid fromBinary(byte[] binaryRepresentation, int offset) {
598
d29d9dc6c128 Utilize the fact nodeids are very different and are read anyway to speed up reverse lookup
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 535
diff changeset
166 if (binaryRepresentation == null || binaryRepresentation.length - offset < SIZE) {
500
465316bf97e8 Tailored subclass of IAE for malformed Nodeids:HgBadNodeidFormatException
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 304
diff changeset
167 throw new HgBadNodeidFormatException(String.format("Bad value: %s", String.valueOf(binaryRepresentation)));
34
51bc56c0addd Static Nodeid creation methods to reuse NULL id
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 31
diff changeset
168 }
51bc56c0addd Static Nodeid creation methods to reuse NULL id
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 31
diff changeset
169 int i = 0;
598
d29d9dc6c128 Utilize the fact nodeids are very different and are read anyway to speed up reverse lookup
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 535
diff changeset
170 while (i < SIZE && binaryRepresentation[offset+i] == 0) i++;
d29d9dc6c128 Utilize the fact nodeids are very different and are read anyway to speed up reverse lookup
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 535
diff changeset
171 if (i == SIZE) {
34
51bc56c0addd Static Nodeid creation methods to reuse NULL id
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 31
diff changeset
172 return NULL;
51bc56c0addd Static Nodeid creation methods to reuse NULL id
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 31
diff changeset
173 }
598
d29d9dc6c128 Utilize the fact nodeids are very different and are read anyway to speed up reverse lookup
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 535
diff changeset
174 if (offset == 0 && binaryRepresentation.length == SIZE) {
34
51bc56c0addd Static Nodeid creation methods to reuse NULL id
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 31
diff changeset
175 return new Nodeid(binaryRepresentation, true);
51bc56c0addd Static Nodeid creation methods to reuse NULL id
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 31
diff changeset
176 }
598
d29d9dc6c128 Utilize the fact nodeids are very different and are read anyway to speed up reverse lookup
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 535
diff changeset
177 byte[] b = new byte[SIZE]; // create new instance if no other reasonable guesses possible
d29d9dc6c128 Utilize the fact nodeids are very different and are read anyway to speed up reverse lookup
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 535
diff changeset
178 System.arraycopy(binaryRepresentation, offset, b, 0, SIZE);
34
51bc56c0addd Static Nodeid creation methods to reuse NULL id
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 31
diff changeset
179 return new Nodeid(b, false);
51bc56c0addd Static Nodeid creation methods to reuse NULL id
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 31
diff changeset
180 }
31
346b66add79d Basic lookup for incoming changes
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 28
diff changeset
181
148
1a7a9a20e1f9 Exceptions, javadoc. Initial cancel and progress support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 125
diff changeset
182 /**
1a7a9a20e1f9 Exceptions, javadoc. Initial cancel and progress support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 125
diff changeset
183 * Parse encoded representation.
1a7a9a20e1f9 Exceptions, javadoc. Initial cancel and progress support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 125
diff changeset
184 *
1a7a9a20e1f9 Exceptions, javadoc. Initial cancel and progress support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 125
diff changeset
185 * @param asciiRepresentation - encoded form of the Nodeid.
1a7a9a20e1f9 Exceptions, javadoc. Initial cancel and progress support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 125
diff changeset
186 * @return object representation
500
465316bf97e8 Tailored subclass of IAE for malformed Nodeids:HgBadNodeidFormatException
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 304
diff changeset
187 * @throws HgBadNodeidFormatException custom {@link IllegalArgumentException} subclass when argument doesn't match encoded form of 20-bytes sha1 digest.
148
1a7a9a20e1f9 Exceptions, javadoc. Initial cancel and progress support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 125
diff changeset
188 */
535
d9c07e1432c4 Issue 42: tolerate lines in .hgtags that do not conform to its format specification
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 500
diff changeset
189 public static Nodeid fromAscii(String asciiRepresentation) throws HgBadNodeidFormatException {
598
d29d9dc6c128 Utilize the fact nodeids are very different and are read anyway to speed up reverse lookup
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 535
diff changeset
190 if (asciiRepresentation.length() != SIZE_ASCII) {
500
465316bf97e8 Tailored subclass of IAE for malformed Nodeids:HgBadNodeidFormatException
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 304
diff changeset
191 throw new HgBadNodeidFormatException(String.format("Bad value: %s", asciiRepresentation));
78
c25c5c348d1b Skip metadata in the beginning of a file content. Parse metadata, recognize copies/renames
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 74
diff changeset
192 }
c25c5c348d1b Skip metadata in the beginning of a file content. Parse metadata, recognize copies/renames
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 74
diff changeset
193 // XXX is better impl for String possible?
598
d29d9dc6c128 Utilize the fact nodeids are very different and are read anyway to speed up reverse lookup
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 535
diff changeset
194 return fromAscii(asciiRepresentation.toCharArray(), 0, SIZE_ASCII);
78
c25c5c348d1b Skip metadata in the beginning of a file content. Parse metadata, recognize copies/renames
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 74
diff changeset
195 }
261
436bb5f65ce1 Avoid redundant calls to library when converting a char to hex digit
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 244
diff changeset
196
148
1a7a9a20e1f9 Exceptions, javadoc. Initial cancel and progress support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 125
diff changeset
197 /**
1a7a9a20e1f9 Exceptions, javadoc. Initial cancel and progress support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 125
diff changeset
198 * Parse encoded representation. Similar to {@link #fromAscii(String)}.
500
465316bf97e8 Tailored subclass of IAE for malformed Nodeids:HgBadNodeidFormatException
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 304
diff changeset
199 * @throws HgBadNodeidFormatException custom {@link IllegalArgumentException} subclass when bytes are not hex digits or number of bytes != 40 (160 bits)
148
1a7a9a20e1f9 Exceptions, javadoc. Initial cancel and progress support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 125
diff changeset
200 */
535
d9c07e1432c4 Issue 42: tolerate lines in .hgtags that do not conform to its format specification
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 500
diff changeset
201 public static Nodeid fromAscii(byte[] asciiRepresentation, int offset, int length) throws HgBadNodeidFormatException {
598
d29d9dc6c128 Utilize the fact nodeids are very different and are read anyway to speed up reverse lookup
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 535
diff changeset
202 if (length != SIZE_ASCII) {
d29d9dc6c128 Utilize the fact nodeids are very different and are read anyway to speed up reverse lookup
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 535
diff changeset
203 throw new HgBadNodeidFormatException(String.format("Expected %d hex characters for nodeid, not %d", SIZE_ASCII, length));
24
d4fdd1845b3f Nodeid with array of exactly 20 bytes
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 22
diff changeset
204 }
500
465316bf97e8 Tailored subclass of IAE for malformed Nodeids:HgBadNodeidFormatException
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 304
diff changeset
205 try {
598
d29d9dc6c128 Utilize the fact nodeids are very different and are read anyway to speed up reverse lookup
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 535
diff changeset
206 byte[] data = new byte[SIZE];
500
465316bf97e8 Tailored subclass of IAE for malformed Nodeids:HgBadNodeidFormatException
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 304
diff changeset
207 boolean zeroBytes = DigestHelper.ascii2bin(asciiRepresentation, offset, length, data);
465316bf97e8 Tailored subclass of IAE for malformed Nodeids:HgBadNodeidFormatException
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 304
diff changeset
208 if (zeroBytes) {
465316bf97e8 Tailored subclass of IAE for malformed Nodeids:HgBadNodeidFormatException
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 304
diff changeset
209 return NULL;
465316bf97e8 Tailored subclass of IAE for malformed Nodeids:HgBadNodeidFormatException
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 304
diff changeset
210 }
465316bf97e8 Tailored subclass of IAE for malformed Nodeids:HgBadNodeidFormatException
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 304
diff changeset
211 return new Nodeid(data, false);
535
d9c07e1432c4 Issue 42: tolerate lines in .hgtags that do not conform to its format specification
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 500
diff changeset
212 } catch (HgBadNodeidFormatException ex) {
d9c07e1432c4 Issue 42: tolerate lines in .hgtags that do not conform to its format specification
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 500
diff changeset
213 throw ex;
500
465316bf97e8 Tailored subclass of IAE for malformed Nodeids:HgBadNodeidFormatException
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 304
diff changeset
214 } catch (IllegalArgumentException ex) {
465316bf97e8 Tailored subclass of IAE for malformed Nodeids:HgBadNodeidFormatException
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 304
diff changeset
215 throw new HgBadNodeidFormatException(ex.getMessage());
0
dbd663faec1f Basic changelog parsing
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
216 }
dbd663faec1f Basic changelog parsing
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
217 }
262
3dcd3dd90c77 Improve manifest parsing: decode bytes to chars once, minimize arraycopy on String instantiation, keep set of file revisions from previous manifest only
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 261
diff changeset
218
3dcd3dd90c77 Improve manifest parsing: decode bytes to chars once, minimize arraycopy on String instantiation, keep set of file revisions from previous manifest only
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 261
diff changeset
219 public static Nodeid fromAscii(char[] asciiRepresentation, int offset, int length) {
3dcd3dd90c77 Improve manifest parsing: decode bytes to chars once, minimize arraycopy on String instantiation, keep set of file revisions from previous manifest only
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 261
diff changeset
220 byte[] b = new byte[length];
3dcd3dd90c77 Improve manifest parsing: decode bytes to chars once, minimize arraycopy on String instantiation, keep set of file revisions from previous manifest only
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 261
diff changeset
221 for (int i = 0; i < b.length; i++) {
3dcd3dd90c77 Improve manifest parsing: decode bytes to chars once, minimize arraycopy on String instantiation, keep set of file revisions from previous manifest only
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 261
diff changeset
222 b[i] = (byte) asciiRepresentation[offset+i];
3dcd3dd90c77 Improve manifest parsing: decode bytes to chars once, minimize arraycopy on String instantiation, keep set of file revisions from previous manifest only
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 261
diff changeset
223 }
3dcd3dd90c77 Improve manifest parsing: decode bytes to chars once, minimize arraycopy on String instantiation, keep set of file revisions from previous manifest only
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 261
diff changeset
224 return fromAscii(b, 0, b.length);
3dcd3dd90c77 Improve manifest parsing: decode bytes to chars once, minimize arraycopy on String instantiation, keep set of file revisions from previous manifest only
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 261
diff changeset
225 }
0
dbd663faec1f Basic changelog parsing
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
226 }