Mercurial > hg4j
annotate src/org/tmatesoft/hg/core/HgChangeset.java @ 422:5d1cc7366d04
Added tag v0.8.5 for changeset fdd7d756dea0. Point before major exceptions refactoring
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Fri, 23 Mar 2012 21:26:01 +0100 |
parents | ee8264d80747 |
children | 9c9c442b5f2e |
rev | line source |
---|---|
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
1 /* |
403
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
2 * Copyright (c) 2011-2012 TMate Software Ltd |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
3 * |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
4 * This program is free software; you can redistribute it and/or modify |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
5 * it under the terms of the GNU General Public License as published by |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
6 * the Free Software Foundation; version 2 of the License. |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
7 * |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
8 * This program is distributed in the hope that it will be useful, |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
11 * GNU General Public License for more details. |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
12 * |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
13 * For information on how to redistribute this software under |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
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:
94
diff
changeset
|
15 * contact TMate Software at support@hg4j.com |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
16 */ |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
17 package org.tmatesoft.hg.core; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
18 |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
19 import java.util.ArrayList; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
20 import java.util.Collections; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
21 import java.util.List; |
316
ee6b467c1a5f
Supply HGFileRevision with copy information when possible, calculate it otherwise
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
274
diff
changeset
|
22 import java.util.Map; |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
23 |
154
ba2bf656f00f
Changeset => RawChangeset
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
148
diff
changeset
|
24 import org.tmatesoft.hg.repo.HgChangelog.RawChangeset; |
195
c9b305df0b89
Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
154
diff
changeset
|
25 import org.tmatesoft.hg.repo.HgChangelog; |
74
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
65
diff
changeset
|
26 import org.tmatesoft.hg.repo.HgRepository; |
94
af1f3b78b918
*StatusCollector renamed to Hg*StatusCollector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
93
diff
changeset
|
27 import org.tmatesoft.hg.repo.HgStatusCollector; |
133
4a948ec83980
core.Path to util.Path as it's not Hg repo dependant
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
131
diff
changeset
|
28 import org.tmatesoft.hg.util.Path; |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
29 |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
30 |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
31 /** |
131
aa1629f36482
Renamed .core classes to start with Hg prefix
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
129
diff
changeset
|
32 * Record in the Mercurial changelog, describing single commit. |
aa1629f36482
Renamed .core classes to start with Hg prefix
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
129
diff
changeset
|
33 * |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
34 * Not thread-safe, don't try to read from different threads |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
35 * |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
36 * @author Artem Tikhomirov |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
37 * @author TMate Software Ltd. |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
38 */ |
129
645829962785
core.Cset renamed to HgChangeset; repo.Changeset moved into HgChangelog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
125
diff
changeset
|
39 public class HgChangeset implements Cloneable { |
94
af1f3b78b918
*StatusCollector renamed to Hg*StatusCollector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
93
diff
changeset
|
40 private final HgStatusCollector statusHelper; |
142
37a34044e6bd
More reasonable use of path normalizer and path.source
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
41 private final Path.Source pathHelper; |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
42 |
195
c9b305df0b89
Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
154
diff
changeset
|
43 private HgChangelog.ParentWalker parentHelper; |
c9b305df0b89
Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
154
diff
changeset
|
44 |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
45 // |
154
ba2bf656f00f
Changeset => RawChangeset
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
148
diff
changeset
|
46 private RawChangeset changeset; |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
47 private Nodeid nodeid; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
48 |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
49 // |
231
1792b37650f2
Introduced access to conflict resolution information (merge state)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
211
diff
changeset
|
50 private List<HgFileRevision> modifiedFiles, addedFiles; |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
51 private List<Path> deletedFiles; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
52 private int revNumber; |
195
c9b305df0b89
Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
154
diff
changeset
|
53 private byte[] parent1, parent2; |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
54 |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
55 // XXX consider CommandContext with StatusCollector, PathPool etc. Commands optionally get CC through a cons or create new |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
56 // and pass it around |
142
37a34044e6bd
More reasonable use of path normalizer and path.source
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
57 /*package-local*/HgChangeset(HgStatusCollector statusCollector, Path.Source pathFactory) { |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
58 statusHelper = statusCollector; |
142
37a34044e6bd
More reasonable use of path normalizer and path.source
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
59 pathHelper = pathFactory; |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
60 } |
195
c9b305df0b89
Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
154
diff
changeset
|
61 |
c9b305df0b89
Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
154
diff
changeset
|
62 /*package-local*/ void init(int localRevNumber, Nodeid nid, RawChangeset rawChangeset) { |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
63 revNumber = localRevNumber; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
64 nodeid = nid; |
196
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
195
diff
changeset
|
65 changeset = rawChangeset.clone(); |
65
e21df6259f83
Log commandline sample updated to use LogCommand
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
64
diff
changeset
|
66 modifiedFiles = addedFiles = null; |
e21df6259f83
Log commandline sample updated to use LogCommand
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
64
diff
changeset
|
67 deletedFiles = null; |
195
c9b305df0b89
Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
154
diff
changeset
|
68 parent1 = parent2 = null; |
c9b305df0b89
Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
154
diff
changeset
|
69 // keep references to parentHelper, statusHelper and pathHelper |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
70 } |
195
c9b305df0b89
Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
154
diff
changeset
|
71 |
c9b305df0b89
Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
154
diff
changeset
|
72 /*package-local*/ void setParentHelper(HgChangelog.ParentWalker pw) { |
c9b305df0b89
Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
154
diff
changeset
|
73 parentHelper = pw; |
c9b305df0b89
Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
154
diff
changeset
|
74 if (parentHelper != null) { |
c9b305df0b89
Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
154
diff
changeset
|
75 if (parentHelper.getRepo() != statusHelper.getRepo()) { |
c9b305df0b89
Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
154
diff
changeset
|
76 throw new IllegalArgumentException(); |
c9b305df0b89
Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
154
diff
changeset
|
77 } |
c9b305df0b89
Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
154
diff
changeset
|
78 } |
c9b305df0b89
Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
154
diff
changeset
|
79 } |
c9b305df0b89
Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
154
diff
changeset
|
80 |
403
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
81 /** |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
82 * Index of the changeset in local repository. Note, this number is relevant only for local repositories/operations, use |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
83 * {@link Nodeid nodeid} to uniquely identify a revision. |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
84 * |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
85 * @return index of the changeset revision |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
86 */ |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
87 public int getRevisionIndex() { |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
88 return revNumber; |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
89 } |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
90 |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
91 /** |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
92 * @deprecated use {@link #getRevisionIndex()} |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
93 */ |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
94 @Deprecated |
65
e21df6259f83
Log commandline sample updated to use LogCommand
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
64
diff
changeset
|
95 public int getRevision() { |
e21df6259f83
Log commandline sample updated to use LogCommand
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
64
diff
changeset
|
96 return revNumber; |
e21df6259f83
Log commandline sample updated to use LogCommand
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
64
diff
changeset
|
97 } |
403
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
98 |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
99 /** |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
100 * Unique identity of this changeset revision |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
101 * @return revision identifier, never <code>null</code> |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
102 */ |
65
e21df6259f83
Log commandline sample updated to use LogCommand
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
64
diff
changeset
|
103 public Nodeid getNodeid() { |
e21df6259f83
Log commandline sample updated to use LogCommand
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
64
diff
changeset
|
104 return nodeid; |
e21df6259f83
Log commandline sample updated to use LogCommand
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
64
diff
changeset
|
105 } |
403
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
106 |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
107 /** |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
108 * Name of the user who made this commit |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
109 * @return author of the commit, never <code>null</code> |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
110 */ |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
111 public String getUser() { |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
112 return changeset.user(); |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
113 } |
403
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
114 |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
115 /** |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
116 * Commit description |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
117 * @return content of the corresponding field in changeset record; empty string if none specified. |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
118 */ |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
119 public String getComment() { |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
120 return changeset.comment(); |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
121 } |
403
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
122 |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
123 /** |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
124 * Name of the branch this commit was made in. Returns "default" for main branch. |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
125 * @return name of the branch, non-empty string |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
126 */ |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
127 public String getBranch() { |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
128 return changeset.branch(); |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
129 } |
211
644ee58c9f16
Compound HgDate object to provide flexible access to change date/time information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
130 |
644ee58c9f16
Compound HgDate object to provide flexible access to change date/time information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
131 /** |
644ee58c9f16
Compound HgDate object to provide flexible access to change date/time information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
132 * @return used to be String, now {@link HgDate}, use {@link HgDate#toString()} to get same result as before |
644ee58c9f16
Compound HgDate object to provide flexible access to change date/time information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
133 */ |
644ee58c9f16
Compound HgDate object to provide flexible access to change date/time information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
134 public HgDate getDate() { |
644ee58c9f16
Compound HgDate object to provide flexible access to change date/time information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
135 return new HgDate(changeset.date().getTime(), changeset.timezone()); |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
136 } |
403
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
137 |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
138 /** |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
139 * Indicates revision of manifest that tracks state of repository at the moment of this commit. |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
140 * Note, may be {@link Nodeid#NULL} in certain scenarios (e.g. first changeset in an empty repository, usually by bogus tools) |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
141 * |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
142 * @return revision identifier, never <code>null</code> |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
143 */ |
65
e21df6259f83
Log commandline sample updated to use LogCommand
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
64
diff
changeset
|
144 public Nodeid getManifestRevision() { |
e21df6259f83
Log commandline sample updated to use LogCommand
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
64
diff
changeset
|
145 return changeset.manifest(); |
e21df6259f83
Log commandline sample updated to use LogCommand
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
64
diff
changeset
|
146 } |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
147 |
403
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
148 /** |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
149 * Lists names of files affected by this commit, as recorded in the changeset itself. Unlike {@link #getAddedFiles()}, |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
150 * {@link #getModifiedFiles()} and {@link #getRemovedFiles()}, this method doesn't analyze actual changes done |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
151 * in the commit, rather extracts value from the changeset record. |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
152 * |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
153 * List returned by this method may be empty, while aforementioned methods may produce non-empty result. |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
154 * |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
155 * @return list of filenames, never <code>null</code> |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
156 */ |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
157 public List<Path> getAffectedFiles() { |
87
25f2e5d1cd8b
Fix IAE when changeset has no files listed (merged revision)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
158 // reports files as recorded in changelog. Note, merge revisions may have no |
25f2e5d1cd8b
Fix IAE when changeset has no files listed (merged revision)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
159 // files listed, and thus this method would return empty list, while |
25f2e5d1cd8b
Fix IAE when changeset has no files listed (merged revision)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
160 // #getModifiedFiles() would return list with merged file(s) (because it uses status to get 'em, not |
25f2e5d1cd8b
Fix IAE when changeset has no files listed (merged revision)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
161 // what #files() gives). |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
162 ArrayList<Path> rv = new ArrayList<Path>(changeset.files().size()); |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
163 for (String name : changeset.files()) { |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
164 rv.add(pathHelper.path(name)); |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
165 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
166 return rv; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
167 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
168 |
403
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
169 /** |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
170 * Figures out files and specific revisions thereof that were modified in this commit |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
171 * |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
172 * @return revisions of files modified in this commit |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
173 * @throws HgInvalidControlFileException if access to revlog index/data entry failed |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
174 * @throws HgException in case of some other library issue |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
175 */ |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
176 public List<HgFileRevision> getModifiedFiles() throws HgException { |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
177 if (modifiedFiles == null) { |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
178 initFileChanges(); |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
179 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
180 return modifiedFiles; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
181 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
182 |
403
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
183 /** |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
184 * Figures out files added in this commit |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
185 * |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
186 * @return revisions of files added in this commit |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
187 * @throws HgInvalidControlFileException if access to revlog index/data entry failed |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
188 * @throws HgException in case of some other library issue |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
189 */ |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
190 public List<HgFileRevision> getAddedFiles() throws HgException { |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
191 if (addedFiles == null) { |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
192 initFileChanges(); |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
193 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
194 return addedFiles; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
195 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
196 |
403
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
197 /** |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
198 * Figures out files that were deleted as part of this commit |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
199 * |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
200 * @return revisions of files deleted in this commit |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
201 * @throws HgInvalidControlFileException if access to revlog index/data entry failed |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
202 * @throws HgException in case of some other library issue |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
203 */ |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
204 public List<Path> getRemovedFiles() throws HgException { |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
205 if (deletedFiles == null) { |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
206 initFileChanges(); |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
207 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
208 return deletedFiles; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
209 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
210 |
366
189dc6dc1c3e
Use exceptions to expose errors reading mercurial data
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
316
diff
changeset
|
211 public boolean isMerge() throws HgInvalidControlFileException { |
195
c9b305df0b89
Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
154
diff
changeset
|
212 // p1 == -1 and p2 != -1 is legitimate case |
274
9fb50c04f03c
Use Nodeid.isNull check instead of NULL.equals
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
231
diff
changeset
|
213 return !(getFirstParentRevision().isNull() || getSecondParentRevision().isNull()); |
125
26ad21b250e4
Explicit op to tell merge revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
124
diff
changeset
|
214 } |
124
cea84c5995e6
Changeset to access parent nodeids
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
215 |
274
9fb50c04f03c
Use Nodeid.isNull check instead of NULL.equals
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
231
diff
changeset
|
216 /** |
9fb50c04f03c
Use Nodeid.isNull check instead of NULL.equals
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
231
diff
changeset
|
217 * @return never <code>null</code> |
380
9517df1ef7ec
Comments/javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
366
diff
changeset
|
218 * @throws HgInvalidControlFileException if access to revlog index/data entry failed |
274
9fb50c04f03c
Use Nodeid.isNull check instead of NULL.equals
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
231
diff
changeset
|
219 */ |
366
189dc6dc1c3e
Use exceptions to expose errors reading mercurial data
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
316
diff
changeset
|
220 public Nodeid getFirstParentRevision() throws HgInvalidControlFileException { |
195
c9b305df0b89
Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
154
diff
changeset
|
221 if (parentHelper != null) { |
c9b305df0b89
Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
154
diff
changeset
|
222 return parentHelper.safeFirstParent(nodeid); |
c9b305df0b89
Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
154
diff
changeset
|
223 } |
c9b305df0b89
Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
154
diff
changeset
|
224 // read once for both p1 and p2 |
c9b305df0b89
Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
154
diff
changeset
|
225 if (parent1 == null) { |
c9b305df0b89
Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
154
diff
changeset
|
226 parent1 = new byte[20]; |
c9b305df0b89
Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
154
diff
changeset
|
227 parent2 = new byte[20]; |
c9b305df0b89
Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
154
diff
changeset
|
228 statusHelper.getRepo().getChangelog().parents(revNumber, new int[2], parent1, parent2); |
c9b305df0b89
Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
154
diff
changeset
|
229 } |
c9b305df0b89
Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
154
diff
changeset
|
230 return Nodeid.fromBinary(parent1, 0); |
124
cea84c5995e6
Changeset to access parent nodeids
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
231 } |
cea84c5995e6
Changeset to access parent nodeids
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
232 |
274
9fb50c04f03c
Use Nodeid.isNull check instead of NULL.equals
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
231
diff
changeset
|
233 /** |
9fb50c04f03c
Use Nodeid.isNull check instead of NULL.equals
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
231
diff
changeset
|
234 * @return never <code>null</code> |
380
9517df1ef7ec
Comments/javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
366
diff
changeset
|
235 * @throws HgInvalidControlFileException if access to revlog index/data entry failed |
274
9fb50c04f03c
Use Nodeid.isNull check instead of NULL.equals
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
231
diff
changeset
|
236 */ |
366
189dc6dc1c3e
Use exceptions to expose errors reading mercurial data
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
316
diff
changeset
|
237 public Nodeid getSecondParentRevision() throws HgInvalidControlFileException { |
195
c9b305df0b89
Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
154
diff
changeset
|
238 if (parentHelper != null) { |
c9b305df0b89
Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
154
diff
changeset
|
239 return parentHelper.safeSecondParent(nodeid); |
c9b305df0b89
Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
154
diff
changeset
|
240 } |
c9b305df0b89
Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
154
diff
changeset
|
241 if (parent2 == null) { |
c9b305df0b89
Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
154
diff
changeset
|
242 parent1 = new byte[20]; |
c9b305df0b89
Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
154
diff
changeset
|
243 parent2 = new byte[20]; |
c9b305df0b89
Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
154
diff
changeset
|
244 statusHelper.getRepo().getChangelog().parents(revNumber, new int[2], parent1, parent2); |
c9b305df0b89
Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
154
diff
changeset
|
245 } |
c9b305df0b89
Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
154
diff
changeset
|
246 return Nodeid.fromBinary(parent2, 0); |
124
cea84c5995e6
Changeset to access parent nodeids
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
247 } |
cea84c5995e6
Changeset to access parent nodeids
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
248 |
403
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
249 /** |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
250 * Create a copy of this changeset |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
251 */ |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
252 @Override |
129
645829962785
core.Cset renamed to HgChangeset; repo.Changeset moved into HgChangelog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
125
diff
changeset
|
253 public HgChangeset clone() { |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
254 try { |
129
645829962785
core.Cset renamed to HgChangeset; repo.Changeset moved into HgChangelog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
125
diff
changeset
|
255 HgChangeset copy = (HgChangeset) super.clone(); |
196
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
195
diff
changeset
|
256 // copy.changeset references this.changeset, doesn't need own copy |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
257 return copy; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
258 } catch (CloneNotSupportedException ex) { |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
259 throw new InternalError(ex.toString()); |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
260 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
261 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
262 |
403
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
263 private /*synchronized*/ void initFileChanges() throws HgException { |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
264 ArrayList<Path> deleted = new ArrayList<Path>(); |
231
1792b37650f2
Introduced access to conflict resolution information (merge state)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
211
diff
changeset
|
265 ArrayList<HgFileRevision> modified = new ArrayList<HgFileRevision>(); |
1792b37650f2
Introduced access to conflict resolution information (merge state)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
211
diff
changeset
|
266 ArrayList<HgFileRevision> added = new ArrayList<HgFileRevision>(); |
94
af1f3b78b918
*StatusCollector renamed to Hg*StatusCollector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
93
diff
changeset
|
267 HgStatusCollector.Record r = new HgStatusCollector.Record(); |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
268 statusHelper.change(revNumber, r); |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
269 final HgRepository repo = statusHelper.getRepo(); |
93
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
87
diff
changeset
|
270 for (Path s : r.getModified()) { |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
271 Nodeid nid = r.nodeidAfterChange(s); |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
272 if (nid == null) { |
403
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
273 throw new HgException(String.format("For the file %s recorded as modified couldn't find revision after change", s)); |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
274 } |
415
ee8264d80747
Explicit constant for regular file flags, access to flags for a given file revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
403
diff
changeset
|
275 modified.add(new HgFileRevision(repo, nid, null, s, null)); |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
276 } |
316
ee6b467c1a5f
Supply HGFileRevision with copy information when possible, calculate it otherwise
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
274
diff
changeset
|
277 final Map<Path, Path> copied = r.getCopied(); |
93
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
87
diff
changeset
|
278 for (Path s : r.getAdded()) { |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
279 Nodeid nid = r.nodeidAfterChange(s); |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
280 if (nid == null) { |
403
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
281 throw new HgException(String.format("For the file %s recorded as added couldn't find revision after change", s)); |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
282 } |
415
ee8264d80747
Explicit constant for regular file flags, access to flags for a given file revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
403
diff
changeset
|
283 added.add(new HgFileRevision(repo, nid, null, s, copied.get(s))); |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
284 } |
93
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
87
diff
changeset
|
285 for (Path s : r.getRemoved()) { |
124
cea84c5995e6
Changeset to access parent nodeids
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
286 // with Path from getRemoved, may just copy |
93
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
87
diff
changeset
|
287 deleted.add(s); |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
288 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
289 modified.trimToSize(); |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
290 added.trimToSize(); |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
291 deleted.trimToSize(); |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
292 modifiedFiles = Collections.unmodifiableList(modified); |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
293 addedFiles = Collections.unmodifiableList(added); |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
294 deletedFiles = Collections.unmodifiableList(deleted); |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
295 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
296 } |