annotate src/org/tmatesoft/hg/repo/Revlog.java @ 133:4a948ec83980

core.Path to util.Path as it's not Hg repo dependant
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Wed, 16 Feb 2011 20:59:39 +0100
parents c0cc2535462c
children 3959bffb14e9
rev   line source
22
603806cd2dc6 Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 21
diff changeset
1 /*
74
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 56
diff changeset
2 * Copyright (c) 2010-2011 TMate Software Ltd
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 56
diff changeset
3 *
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 56
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: 56
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: 56
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: 56
diff changeset
7 *
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 56
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: 56
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: 56
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: 56
diff changeset
11 * GNU General Public License for more details.
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 56
diff changeset
12 *
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 56
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: 56
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: 88
diff changeset
15 * contact TMate Software at support@hg4j.com
2
08db726a0fb7 Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
16 */
74
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 56
diff changeset
17 package org.tmatesoft.hg.repo;
2
08db726a0fb7 Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
18
80
4222b04f34ee Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 77
diff changeset
19 import static org.tmatesoft.hg.repo.HgRepository.BAD_REVISION;
74
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 56
diff changeset
20 import static org.tmatesoft.hg.repo.HgRepository.TIP;
56
576d6e8a09f6 Analog of 'hg status --change' command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 49
diff changeset
21
576d6e8a09f6 Analog of 'hg status --change' command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 49
diff changeset
22 import java.util.Arrays;
29
6cce719bbb62 Collector for nodes and their parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 24
diff changeset
23 import java.util.Collection;
6cce719bbb62 Collector for nodes and their parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 24
diff changeset
24 import java.util.Collections;
6cce719bbb62 Collector for nodes and their parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 24
diff changeset
25 import java.util.HashMap;
6cce719bbb62 Collector for nodes and their parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 24
diff changeset
26 import java.util.LinkedHashSet;
6cce719bbb62 Collector for nodes and their parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 24
diff changeset
27 import java.util.Map;
6cce719bbb62 Collector for nodes and their parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 24
diff changeset
28 import java.util.Set;
6cce719bbb62 Collector for nodes and their parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 24
diff changeset
29
74
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 56
diff changeset
30 import org.tmatesoft.hg.core.Nodeid;
77
c677e1593919 Moved RevlogStream implementation into .internal
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 74
diff changeset
31 import org.tmatesoft.hg.internal.RevlogStream;
74
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 56
diff changeset
32
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 56
diff changeset
33
2
08db726a0fb7 Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
34 /**
08db726a0fb7 Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
35 *
74
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 56
diff changeset
36 * @author Artem Tikhomirov
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 56
diff changeset
37 * @author TMate Software Ltd.
2
08db726a0fb7 Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
38 */
74
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 56
diff changeset
39 abstract class Revlog {
2
08db726a0fb7 Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
40
115
c0cc2535462c Introduced channels to pipeline (and easily filter) data streams
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
41 private final HgRepository repo;
21
e929cecae4e1 Refactor to move revlog content to base class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 3
diff changeset
42 protected final RevlogStream content;
2
08db726a0fb7 Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
43
115
c0cc2535462c Introduced channels to pipeline (and easily filter) data streams
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
44 protected Revlog(HgRepository hgRepo, RevlogStream contentStream) {
2
08db726a0fb7 Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
45 if (hgRepo == null) {
74
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 56
diff changeset
46 throw new IllegalArgumentException();
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 56
diff changeset
47 }
115
c0cc2535462c Introduced channels to pipeline (and easily filter) data streams
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
48 if (contentStream == null) {
74
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 56
diff changeset
49 throw new IllegalArgumentException();
2
08db726a0fb7 Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
50 }
115
c0cc2535462c Introduced channels to pipeline (and easily filter) data streams
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
51 repo = hgRepo;
c0cc2535462c Introduced channels to pipeline (and easily filter) data streams
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
52 content = contentStream;
c0cc2535462c Introduced channels to pipeline (and easily filter) data streams
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
53 }
c0cc2535462c Introduced channels to pipeline (and easily filter) data streams
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
54
c0cc2535462c Introduced channels to pipeline (and easily filter) data streams
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
55 // invalid Revlog
c0cc2535462c Introduced channels to pipeline (and easily filter) data streams
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
56 protected Revlog(HgRepository hgRepo) {
c0cc2535462c Introduced channels to pipeline (and easily filter) data streams
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
57 repo = hgRepo;
c0cc2535462c Introduced channels to pipeline (and easily filter) data streams
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
58 content = null;
2
08db726a0fb7 Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
59 }
08db726a0fb7 Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
60
08db726a0fb7 Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
61 public final HgRepository getRepo() {
115
c0cc2535462c Introduced channels to pipeline (and easily filter) data streams
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
62 return repo;
2
08db726a0fb7 Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
63 }
08db726a0fb7 Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
64
21
e929cecae4e1 Refactor to move revlog content to base class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 3
diff changeset
65 public int getRevisionCount() {
e929cecae4e1 Refactor to move revlog content to base class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 3
diff changeset
66 return content.revisionCount();
e929cecae4e1 Refactor to move revlog content to base class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 3
diff changeset
67 }
80
4222b04f34ee Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 77
diff changeset
68
88
61eedab3eb3e Status between two revisions to recognize copy/rename
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 80
diff changeset
69 public Nodeid getRevision(int revision) {
80
4222b04f34ee Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 77
diff changeset
70 // XXX cache nodeids?
4222b04f34ee Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 77
diff changeset
71 return Nodeid.fromBinary(content.nodeid(revision), 0);
4222b04f34ee Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 77
diff changeset
72 }
37
e45e75e22523 Parse changesets from bundle's changelog group. Refactor Revlog to provide access to revision's raw content
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 31
diff changeset
73
88
61eedab3eb3e Status between two revisions to recognize copy/rename
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 80
diff changeset
74 public int getLocalRevision(Nodeid nid) {
49
26e3eeaa3962 branch and user filtering for log operation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 39
diff changeset
75 int revision = content.findLocalRevisionNumber(nid);
80
4222b04f34ee Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 77
diff changeset
76 if (revision == BAD_REVISION) {
49
26e3eeaa3962 branch and user filtering for log operation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 39
diff changeset
77 throw new IllegalArgumentException(String.format("%s doesn't represent a revision of %s", nid.toString(), this /*XXX HgDataFile.getPath might be more suitable here*/));
26e3eeaa3962 branch and user filtering for log operation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 39
diff changeset
78 }
26e3eeaa3962 branch and user filtering for log operation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 39
diff changeset
79 return revision;
26e3eeaa3962 branch and user filtering for log operation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 39
diff changeset
80 }
26e3eeaa3962 branch and user filtering for log operation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 39
diff changeset
81
39
4e9b66b07a28 Check changelog group starts with proper (known) base
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 37
diff changeset
82 // Till now, i follow approach that NULL nodeid is never part of revlog
4e9b66b07a28 Check changelog group starts with proper (known) base
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 37
diff changeset
83 public boolean isKnown(Nodeid nodeid) {
49
26e3eeaa3962 branch and user filtering for log operation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 39
diff changeset
84 final int rn = content.findLocalRevisionNumber(nodeid);
26e3eeaa3962 branch and user filtering for log operation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 39
diff changeset
85 if (Integer.MIN_VALUE == rn) {
39
4e9b66b07a28 Check changelog group starts with proper (known) base
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 37
diff changeset
86 return false;
4e9b66b07a28 Check changelog group starts with proper (known) base
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 37
diff changeset
87 }
49
26e3eeaa3962 branch and user filtering for log operation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 39
diff changeset
88 if (rn < 0 || rn >= content.revisionCount()) {
26e3eeaa3962 branch and user filtering for log operation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 39
diff changeset
89 // Sanity check
26e3eeaa3962 branch and user filtering for log operation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 39
diff changeset
90 throw new IllegalStateException();
26e3eeaa3962 branch and user filtering for log operation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 39
diff changeset
91 }
26e3eeaa3962 branch and user filtering for log operation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 39
diff changeset
92 return true;
39
4e9b66b07a28 Check changelog group starts with proper (known) base
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 37
diff changeset
93 }
49
26e3eeaa3962 branch and user filtering for log operation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 39
diff changeset
94
37
e45e75e22523 Parse changesets from bundle's changelog group. Refactor Revlog to provide access to revision's raw content
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 31
diff changeset
95 /**
e45e75e22523 Parse changesets from bundle's changelog group. Refactor Revlog to provide access to revision's raw content
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 31
diff changeset
96 * Access to revision data as is (decompressed, but otherwise unprocessed, i.e. not parsed for e.g. changeset or manifest entries)
e45e75e22523 Parse changesets from bundle's changelog group. Refactor Revlog to provide access to revision's raw content
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 31
diff changeset
97 * @param nodeid
e45e75e22523 Parse changesets from bundle's changelog group. Refactor Revlog to provide access to revision's raw content
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 31
diff changeset
98 */
e45e75e22523 Parse changesets from bundle's changelog group. Refactor Revlog to provide access to revision's raw content
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 31
diff changeset
99 public byte[] content(Nodeid nodeid) {
88
61eedab3eb3e Status between two revisions to recognize copy/rename
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 80
diff changeset
100 return content(getLocalRevision(nodeid));
37
e45e75e22523 Parse changesets from bundle's changelog group. Refactor Revlog to provide access to revision's raw content
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 31
diff changeset
101 }
29
6cce719bbb62 Collector for nodes and their parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 24
diff changeset
102
37
e45e75e22523 Parse changesets from bundle's changelog group. Refactor Revlog to provide access to revision's raw content
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 31
diff changeset
103 /**
e45e75e22523 Parse changesets from bundle's changelog group. Refactor Revlog to provide access to revision's raw content
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 31
diff changeset
104 * @param revision - repo-local index of this file change (not a changelog revision number!)
e45e75e22523 Parse changesets from bundle's changelog group. Refactor Revlog to provide access to revision's raw content
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 31
diff changeset
105 */
e45e75e22523 Parse changesets from bundle's changelog group. Refactor Revlog to provide access to revision's raw content
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 31
diff changeset
106 public byte[] content(int revision) {
e45e75e22523 Parse changesets from bundle's changelog group. Refactor Revlog to provide access to revision's raw content
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 31
diff changeset
107 final byte[][] dataPtr = new byte[1][];
77
c677e1593919 Moved RevlogStream implementation into .internal
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 74
diff changeset
108 RevlogStream.Inspector insp = new RevlogStream.Inspector() {
37
e45e75e22523 Parse changesets from bundle's changelog group. Refactor Revlog to provide access to revision's raw content
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 31
diff changeset
109 public void next(int revisionNumber, int actualLen, int baseRevision, int linkRevision, int parent1Revision, int parent2Revision, byte[] nodeid, byte[] data) {
e45e75e22523 Parse changesets from bundle's changelog group. Refactor Revlog to provide access to revision's raw content
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 31
diff changeset
110 dataPtr[0] = data;
e45e75e22523 Parse changesets from bundle's changelog group. Refactor Revlog to provide access to revision's raw content
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 31
diff changeset
111 }
e45e75e22523 Parse changesets from bundle's changelog group. Refactor Revlog to provide access to revision's raw content
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 31
diff changeset
112 };
e45e75e22523 Parse changesets from bundle's changelog group. Refactor Revlog to provide access to revision's raw content
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 31
diff changeset
113 content.iterate(revision, revision, true, insp);
e45e75e22523 Parse changesets from bundle's changelog group. Refactor Revlog to provide access to revision's raw content
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 31
diff changeset
114 return dataPtr[0];
e45e75e22523 Parse changesets from bundle's changelog group. Refactor Revlog to provide access to revision's raw content
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 31
diff changeset
115 }
e45e75e22523 Parse changesets from bundle's changelog group. Refactor Revlog to provide access to revision's raw content
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 31
diff changeset
116
56
576d6e8a09f6 Analog of 'hg status --change' command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 49
diff changeset
117 /**
576d6e8a09f6 Analog of 'hg status --change' command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 49
diff changeset
118 * XXX perhaps, return value Nodeid[2] and boolean needNodeids is better (and higher level) API for this query?
576d6e8a09f6 Analog of 'hg status --change' command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 49
diff changeset
119 *
576d6e8a09f6 Analog of 'hg status --change' command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 49
diff changeset
120 * @param revision - revision to query parents, or {@link HgRepository#TIP}
576d6e8a09f6 Analog of 'hg status --change' command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 49
diff changeset
121 * @param parentRevisions - int[2] to get local revision numbers of parents (e.g. {6, -1})
576d6e8a09f6 Analog of 'hg status --change' command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 49
diff changeset
122 * @param parent1 - byte[20] or null, if parent's nodeid is not needed
576d6e8a09f6 Analog of 'hg status --change' command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 49
diff changeset
123 * @param parent2 - byte[20] or null, if second parent's nodeid is not needed
576d6e8a09f6 Analog of 'hg status --change' command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 49
diff changeset
124 * @return
576d6e8a09f6 Analog of 'hg status --change' command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 49
diff changeset
125 */
576d6e8a09f6 Analog of 'hg status --change' command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 49
diff changeset
126 public void parents(int revision, int[] parentRevisions, byte[] parent1, byte[] parent2) {
576d6e8a09f6 Analog of 'hg status --change' command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 49
diff changeset
127 if (revision != TIP && !(revision >= 0 && revision < content.revisionCount())) {
576d6e8a09f6 Analog of 'hg status --change' command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 49
diff changeset
128 throw new IllegalArgumentException(String.valueOf(revision));
576d6e8a09f6 Analog of 'hg status --change' command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 49
diff changeset
129 }
576d6e8a09f6 Analog of 'hg status --change' command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 49
diff changeset
130 if (parentRevisions == null || parentRevisions.length < 2) {
576d6e8a09f6 Analog of 'hg status --change' command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 49
diff changeset
131 throw new IllegalArgumentException(String.valueOf(parentRevisions));
576d6e8a09f6 Analog of 'hg status --change' command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 49
diff changeset
132 }
576d6e8a09f6 Analog of 'hg status --change' command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 49
diff changeset
133 if (parent1 != null && parent1.length < 20) {
576d6e8a09f6 Analog of 'hg status --change' command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 49
diff changeset
134 throw new IllegalArgumentException(parent1.toString());
576d6e8a09f6 Analog of 'hg status --change' command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 49
diff changeset
135 }
576d6e8a09f6 Analog of 'hg status --change' command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 49
diff changeset
136 if (parent2 != null && parent2.length < 20) {
576d6e8a09f6 Analog of 'hg status --change' command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 49
diff changeset
137 throw new IllegalArgumentException(parent2.toString());
576d6e8a09f6 Analog of 'hg status --change' command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 49
diff changeset
138 }
77
c677e1593919 Moved RevlogStream implementation into .internal
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 74
diff changeset
139 class ParentCollector implements RevlogStream.Inspector {
56
576d6e8a09f6 Analog of 'hg status --change' command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 49
diff changeset
140 public int p1 = -1;
576d6e8a09f6 Analog of 'hg status --change' command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 49
diff changeset
141 public int p2 = -1;
576d6e8a09f6 Analog of 'hg status --change' command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 49
diff changeset
142 public byte[] nodeid;
576d6e8a09f6 Analog of 'hg status --change' command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 49
diff changeset
143
576d6e8a09f6 Analog of 'hg status --change' command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 49
diff changeset
144 public void next(int revisionNumber, int actualLen, int baseRevision, int linkRevision, int parent1Revision, int parent2Revision, byte[] nodeid, byte[] data) {
576d6e8a09f6 Analog of 'hg status --change' command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 49
diff changeset
145 p1 = parent1Revision;
576d6e8a09f6 Analog of 'hg status --change' command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 49
diff changeset
146 p2 = parent2Revision;
576d6e8a09f6 Analog of 'hg status --change' command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 49
diff changeset
147 this.nodeid = new byte[20];
576d6e8a09f6 Analog of 'hg status --change' command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 49
diff changeset
148 // nodeid arg now comes in 32 byte from (as in file format description), however upper 12 bytes are zeros.
576d6e8a09f6 Analog of 'hg status --change' command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 49
diff changeset
149 System.arraycopy(nodeid, nodeid.length > 20 ? nodeid.length - 20 : 0, this.nodeid, 0, 20);
576d6e8a09f6 Analog of 'hg status --change' command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 49
diff changeset
150 }
576d6e8a09f6 Analog of 'hg status --change' command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 49
diff changeset
151 };
576d6e8a09f6 Analog of 'hg status --change' command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 49
diff changeset
152 ParentCollector pc = new ParentCollector();
576d6e8a09f6 Analog of 'hg status --change' command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 49
diff changeset
153 content.iterate(revision, revision, false, pc);
576d6e8a09f6 Analog of 'hg status --change' command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 49
diff changeset
154 parentRevisions[0] = pc.p1;
576d6e8a09f6 Analog of 'hg status --change' command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 49
diff changeset
155 parentRevisions[1] = pc.p2;
576d6e8a09f6 Analog of 'hg status --change' command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 49
diff changeset
156 if (parent1 != null) {
576d6e8a09f6 Analog of 'hg status --change' command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 49
diff changeset
157 if (parentRevisions[0] == -1) {
576d6e8a09f6 Analog of 'hg status --change' command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 49
diff changeset
158 Arrays.fill(parent1, 0, 20, (byte) 0);
576d6e8a09f6 Analog of 'hg status --change' command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 49
diff changeset
159 } else {
576d6e8a09f6 Analog of 'hg status --change' command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 49
diff changeset
160 content.iterate(parentRevisions[0], parentRevisions[0], false, pc);
576d6e8a09f6 Analog of 'hg status --change' command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 49
diff changeset
161 System.arraycopy(pc.nodeid, 0, parent1, 0, 20);
576d6e8a09f6 Analog of 'hg status --change' command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 49
diff changeset
162 }
576d6e8a09f6 Analog of 'hg status --change' command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 49
diff changeset
163 }
576d6e8a09f6 Analog of 'hg status --change' command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 49
diff changeset
164 if (parent2 != null) {
576d6e8a09f6 Analog of 'hg status --change' command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 49
diff changeset
165 if (parentRevisions[1] == -1) {
576d6e8a09f6 Analog of 'hg status --change' command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 49
diff changeset
166 Arrays.fill(parent2, 0, 20, (byte) 0);
576d6e8a09f6 Analog of 'hg status --change' command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 49
diff changeset
167 } else {
576d6e8a09f6 Analog of 'hg status --change' command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 49
diff changeset
168 content.iterate(parentRevisions[1], parentRevisions[1], false, pc);
576d6e8a09f6 Analog of 'hg status --change' command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 49
diff changeset
169 System.arraycopy(pc.nodeid, 0, parent2, 0, 20);
576d6e8a09f6 Analog of 'hg status --change' command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 49
diff changeset
170 }
576d6e8a09f6 Analog of 'hg status --change' command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 49
diff changeset
171 }
576d6e8a09f6 Analog of 'hg status --change' command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 49
diff changeset
172 }
576d6e8a09f6 Analog of 'hg status --change' command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 49
diff changeset
173
29
6cce719bbb62 Collector for nodes and their parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 24
diff changeset
174 /*
6cce719bbb62 Collector for nodes and their parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 24
diff changeset
175 * XXX think over if it's better to do either:
6cce719bbb62 Collector for nodes and their parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 24
diff changeset
176 * pw = getChangelog().new ParentWalker(); pw.init() and pass pw instance around as needed
6cce719bbb62 Collector for nodes and their parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 24
diff changeset
177 * or
6cce719bbb62 Collector for nodes and their parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 24
diff changeset
178 * add Revlog#getParentWalker(), static class, make cons() and #init package-local, and keep SoftReference to allow walker reuse.
6cce719bbb62 Collector for nodes and their parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 24
diff changeset
179 *
6cce719bbb62 Collector for nodes and their parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 24
diff changeset
180 * and yes, walker is not a proper name
6cce719bbb62 Collector for nodes and their parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 24
diff changeset
181 */
6cce719bbb62 Collector for nodes and their parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 24
diff changeset
182 public final class ParentWalker {
6cce719bbb62 Collector for nodes and their parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 24
diff changeset
183 private Map<Nodeid, Nodeid> firstParent;
6cce719bbb62 Collector for nodes and their parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 24
diff changeset
184 private Map<Nodeid, Nodeid> secondParent;
6cce719bbb62 Collector for nodes and their parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 24
diff changeset
185 private Set<Nodeid> allNodes;
6cce719bbb62 Collector for nodes and their parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 24
diff changeset
186
6cce719bbb62 Collector for nodes and their parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 24
diff changeset
187 public ParentWalker() {
6cce719bbb62 Collector for nodes and their parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 24
diff changeset
188 firstParent = secondParent = Collections.emptyMap();
6cce719bbb62 Collector for nodes and their parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 24
diff changeset
189 allNodes = Collections.emptySet();
6cce719bbb62 Collector for nodes and their parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 24
diff changeset
190 }
6cce719bbb62 Collector for nodes and their parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 24
diff changeset
191
6cce719bbb62 Collector for nodes and their parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 24
diff changeset
192 public void init() {
6cce719bbb62 Collector for nodes and their parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 24
diff changeset
193 final RevlogStream stream = Revlog.this.content;
6cce719bbb62 Collector for nodes and their parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 24
diff changeset
194 final int revisionCount = stream.revisionCount();
6cce719bbb62 Collector for nodes and their parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 24
diff changeset
195 firstParent = new HashMap<Nodeid, Nodeid>(revisionCount);
6cce719bbb62 Collector for nodes and their parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 24
diff changeset
196 secondParent = new HashMap<Nodeid, Nodeid>(firstParent.size() >> 1); // assume branches/merges are less frequent
6cce719bbb62 Collector for nodes and their parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 24
diff changeset
197 allNodes = new LinkedHashSet<Nodeid>();
6cce719bbb62 Collector for nodes and their parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 24
diff changeset
198
77
c677e1593919 Moved RevlogStream implementation into .internal
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 74
diff changeset
199 RevlogStream.Inspector insp = new RevlogStream.Inspector() {
29
6cce719bbb62 Collector for nodes and their parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 24
diff changeset
200 final Nodeid[] sequentialRevisionNodeids = new Nodeid[revisionCount];
6cce719bbb62 Collector for nodes and their parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 24
diff changeset
201 int ix = 0;
6cce719bbb62 Collector for nodes and their parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 24
diff changeset
202 public void next(int revisionNumber, int actualLen, int baseRevision, int linkRevision, int parent1Revision, int parent2Revision, byte[] nodeid, byte[] data) {
6cce719bbb62 Collector for nodes and their parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 24
diff changeset
203 if (ix != revisionNumber) {
6cce719bbb62 Collector for nodes and their parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 24
diff changeset
204 // XXX temp code, just to make sure I understand what's going on here
6cce719bbb62 Collector for nodes and their parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 24
diff changeset
205 throw new IllegalStateException();
6cce719bbb62 Collector for nodes and their parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 24
diff changeset
206 }
6cce719bbb62 Collector for nodes and their parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 24
diff changeset
207 if (parent1Revision >= revisionNumber || parent2Revision >= revisionNumber) {
6cce719bbb62 Collector for nodes and their parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 24
diff changeset
208 throw new IllegalStateException(); // sanity, revisions are sequential
6cce719bbb62 Collector for nodes and their parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 24
diff changeset
209 }
6cce719bbb62 Collector for nodes and their parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 24
diff changeset
210 final Nodeid nid = new Nodeid(nodeid, true);
6cce719bbb62 Collector for nodes and their parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 24
diff changeset
211 sequentialRevisionNodeids[ix++] = nid;
6cce719bbb62 Collector for nodes and their parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 24
diff changeset
212 allNodes.add(nid);
6cce719bbb62 Collector for nodes and their parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 24
diff changeset
213 if (parent1Revision != -1) {
6cce719bbb62 Collector for nodes and their parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 24
diff changeset
214 firstParent.put(nid, sequentialRevisionNodeids[parent1Revision]);
6cce719bbb62 Collector for nodes and their parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 24
diff changeset
215 if (parent2Revision != -1) {
6cce719bbb62 Collector for nodes and their parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 24
diff changeset
216 secondParent.put(nid, sequentialRevisionNodeids[parent2Revision]);
6cce719bbb62 Collector for nodes and their parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 24
diff changeset
217 }
6cce719bbb62 Collector for nodes and their parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 24
diff changeset
218 }
6cce719bbb62 Collector for nodes and their parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 24
diff changeset
219 }
6cce719bbb62 Collector for nodes and their parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 24
diff changeset
220 };
6cce719bbb62 Collector for nodes and their parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 24
diff changeset
221 stream.iterate(0, -1, false, insp);
6cce719bbb62 Collector for nodes and their parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 24
diff changeset
222 }
6cce719bbb62 Collector for nodes and their parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 24
diff changeset
223
6cce719bbb62 Collector for nodes and their parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 24
diff changeset
224 public Set<Nodeid> allNodes() {
6cce719bbb62 Collector for nodes and their parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 24
diff changeset
225 return Collections.unmodifiableSet(allNodes);
6cce719bbb62 Collector for nodes and their parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 24
diff changeset
226 }
31
346b66add79d Basic lookup for incoming changes
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 29
diff changeset
227
346b66add79d Basic lookup for incoming changes
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 29
diff changeset
228 // FIXME need to decide whether Nodeid(00 * 20) is always known or not
346b66add79d Basic lookup for incoming changes
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 29
diff changeset
229 public boolean knownNode(Nodeid nid) {
346b66add79d Basic lookup for incoming changes
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 29
diff changeset
230 return allNodes.contains(nid);
346b66add79d Basic lookup for incoming changes
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 29
diff changeset
231 }
29
6cce719bbb62 Collector for nodes and their parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 24
diff changeset
232
6cce719bbb62 Collector for nodes and their parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 24
diff changeset
233 // null if none
6cce719bbb62 Collector for nodes and their parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 24
diff changeset
234 public Nodeid firstParent(Nodeid nid) {
6cce719bbb62 Collector for nodes and their parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 24
diff changeset
235 return firstParent.get(nid);
6cce719bbb62 Collector for nodes and their parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 24
diff changeset
236 }
49
26e3eeaa3962 branch and user filtering for log operation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 39
diff changeset
237
26e3eeaa3962 branch and user filtering for log operation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 39
diff changeset
238 // never null, Nodeid.NULL if none known
26e3eeaa3962 branch and user filtering for log operation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 39
diff changeset
239 public Nodeid safeFirstParent(Nodeid nid) {
26e3eeaa3962 branch and user filtering for log operation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 39
diff changeset
240 Nodeid rv = firstParent(nid);
26e3eeaa3962 branch and user filtering for log operation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 39
diff changeset
241 return rv == null ? Nodeid.NULL : rv;
26e3eeaa3962 branch and user filtering for log operation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 39
diff changeset
242 }
29
6cce719bbb62 Collector for nodes and their parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 24
diff changeset
243
6cce719bbb62 Collector for nodes and their parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 24
diff changeset
244 public Nodeid secondParent(Nodeid nid) {
6cce719bbb62 Collector for nodes and their parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 24
diff changeset
245 return secondParent.get(nid);
6cce719bbb62 Collector for nodes and their parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 24
diff changeset
246 }
6cce719bbb62 Collector for nodes and their parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 24
diff changeset
247
49
26e3eeaa3962 branch and user filtering for log operation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 39
diff changeset
248 public Nodeid safeSecondParent(Nodeid nid) {
26e3eeaa3962 branch and user filtering for log operation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 39
diff changeset
249 Nodeid rv = secondParent(nid);
26e3eeaa3962 branch and user filtering for log operation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 39
diff changeset
250 return rv == null ? Nodeid.NULL : rv;
26e3eeaa3962 branch and user filtering for log operation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 39
diff changeset
251 }
26e3eeaa3962 branch and user filtering for log operation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 39
diff changeset
252
29
6cce719bbb62 Collector for nodes and their parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 24
diff changeset
253 public boolean appendParentsOf(Nodeid nid, Collection<Nodeid> c) {
6cce719bbb62 Collector for nodes and their parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 24
diff changeset
254 Nodeid p1 = firstParent(nid);
6cce719bbb62 Collector for nodes and their parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 24
diff changeset
255 boolean modified = false;
6cce719bbb62 Collector for nodes and their parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 24
diff changeset
256 if (p1 != null) {
6cce719bbb62 Collector for nodes and their parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 24
diff changeset
257 modified = c.add(p1);
6cce719bbb62 Collector for nodes and their parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 24
diff changeset
258 Nodeid p2 = secondParent(nid);
6cce719bbb62 Collector for nodes and their parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 24
diff changeset
259 if (p2 != null) {
6cce719bbb62 Collector for nodes and their parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 24
diff changeset
260 modified = c.add(p2) || modified;
6cce719bbb62 Collector for nodes and their parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 24
diff changeset
261 }
6cce719bbb62 Collector for nodes and their parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 24
diff changeset
262 }
6cce719bbb62 Collector for nodes and their parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 24
diff changeset
263 return modified;
6cce719bbb62 Collector for nodes and their parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 24
diff changeset
264 }
6cce719bbb62 Collector for nodes and their parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 24
diff changeset
265 }
2
08db726a0fb7 Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
266 }