Mercurial > hg4j
annotate src/org/tmatesoft/hg/core/HgChangeset.java @ 427:31a89587eb04
FIXMEs: consistent names, throws for commands and their handlers. Use of checked exceptions in hi-level api
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Thu, 29 Mar 2012 17:14:35 +0200 |
parents | 6437d261048a |
children | 1fc0da631200 |
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 |
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
|
24 import org.tmatesoft.hg.repo.HgChangelog; |
427
31a89587eb04
FIXMEs: consistent names, throws for commands and their handlers. Use of checked exceptions in hi-level api
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
424
diff
changeset
|
25 import org.tmatesoft.hg.repo.HgChangelog.RawChangeset; |
423
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
415
diff
changeset
|
26 import org.tmatesoft.hg.repo.HgInvalidStateException; |
74
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
65
diff
changeset
|
27 import org.tmatesoft.hg.repo.HgRepository; |
423
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
415
diff
changeset
|
28 import org.tmatesoft.hg.repo.HgRuntimeException; |
94
af1f3b78b918
*StatusCollector renamed to Hg*StatusCollector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
93
diff
changeset
|
29 import org.tmatesoft.hg.repo.HgStatusCollector; |
423
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
415
diff
changeset
|
30 import org.tmatesoft.hg.util.CancelledException; |
133
4a948ec83980
core.Path to util.Path as it's not Hg repo dependant
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
131
diff
changeset
|
31 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
|
32 |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
33 |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
34 /** |
131
aa1629f36482
Renamed .core classes to start with Hg prefix
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
129
diff
changeset
|
35 * 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
|
36 * |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
37 * 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
|
38 * |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
39 * @author Artem Tikhomirov |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
40 * @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
|
41 */ |
129
645829962785
core.Cset renamed to HgChangeset; repo.Changeset moved into HgChangelog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
125
diff
changeset
|
42 public class HgChangeset implements Cloneable { |
94
af1f3b78b918
*StatusCollector renamed to Hg*StatusCollector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
93
diff
changeset
|
43 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
|
44 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
|
45 |
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
|
46 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
|
47 |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
48 // |
154
ba2bf656f00f
Changeset => RawChangeset
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
148
diff
changeset
|
49 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
|
50 private Nodeid nodeid; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
51 |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
52 // |
231
1792b37650f2
Introduced access to conflict resolution information (merge state)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
211
diff
changeset
|
53 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
|
54 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
|
55 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
|
56 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
|
57 |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
58 // 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
|
59 // 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
|
60 /*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
|
61 statusHelper = statusCollector; |
142
37a34044e6bd
More reasonable use of path normalizer and path.source
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
62 pathHelper = pathFactory; |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
63 } |
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
|
64 |
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
|
65 /*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
|
66 revNumber = localRevNumber; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
67 nodeid = nid; |
196
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
195
diff
changeset
|
68 changeset = rawChangeset.clone(); |
65
e21df6259f83
Log commandline sample updated to use LogCommand
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
64
diff
changeset
|
69 modifiedFiles = addedFiles = null; |
e21df6259f83
Log commandline sample updated to use LogCommand
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
64
diff
changeset
|
70 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
|
71 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
|
72 // 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
|
73 } |
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
|
74 |
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 /*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
|
76 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
|
77 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
|
78 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
|
79 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
|
80 } |
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
|
81 } |
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
|
82 } |
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
|
83 |
403
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 * 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
|
86 * {@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
|
87 * |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
88 * @return index of the changeset revision |
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 public int getRevisionIndex() { |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
91 return revNumber; |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
92 } |
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 /** |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
95 * Unique identity of this changeset revision |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
96 * @return revision identifier, never <code>null</code> |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
97 */ |
65
e21df6259f83
Log commandline sample updated to use LogCommand
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
64
diff
changeset
|
98 public Nodeid getNodeid() { |
e21df6259f83
Log commandline sample updated to use LogCommand
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
64
diff
changeset
|
99 return nodeid; |
e21df6259f83
Log commandline sample updated to use LogCommand
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
64
diff
changeset
|
100 } |
403
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
101 |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
102 /** |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
103 * 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
|
104 * @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
|
105 */ |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
106 public String getUser() { |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
107 return changeset.user(); |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
108 } |
403
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
109 |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
110 /** |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
111 * Commit description |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
112 * @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
|
113 */ |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
114 public String getComment() { |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
115 return changeset.comment(); |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
116 } |
403
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
117 |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
118 /** |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
119 * 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
|
120 * @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
|
121 */ |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
122 public String getBranch() { |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
123 return changeset.branch(); |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
124 } |
211
644ee58c9f16
Compound HgDate object to provide flexible access to change date/time information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
125 |
644ee58c9f16
Compound HgDate object to provide flexible access to change date/time information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
126 /** |
644ee58c9f16
Compound HgDate object to provide flexible access to change date/time information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
127 * @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
|
128 */ |
644ee58c9f16
Compound HgDate object to provide flexible access to change date/time information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
129 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
|
130 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
|
131 } |
403
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
132 |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
133 /** |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
134 * 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
|
135 * 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
|
136 * |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
137 * @return revision identifier, never <code>null</code> |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
138 */ |
65
e21df6259f83
Log commandline sample updated to use LogCommand
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
64
diff
changeset
|
139 public Nodeid getManifestRevision() { |
e21df6259f83
Log commandline sample updated to use LogCommand
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
64
diff
changeset
|
140 return changeset.manifest(); |
e21df6259f83
Log commandline sample updated to use LogCommand
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
64
diff
changeset
|
141 } |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
142 |
403
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
143 /** |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
144 * 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
|
145 * {@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
|
146 * 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
|
147 * |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
148 * 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
|
149 * |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
150 * @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
|
151 */ |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
152 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
|
153 // 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
|
154 // 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
|
155 // #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
|
156 // 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
|
157 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
|
158 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
|
159 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
|
160 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
161 return rv; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
162 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
163 |
403
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
164 /** |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
165 * 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
|
166 * |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
167 * @return revisions of files modified in this commit |
423
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
415
diff
changeset
|
168 * @throws HgRuntimeException subclass thereof to indicate issues with the library. <em>Runtime exception</em> |
403
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
169 */ |
423
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
415
diff
changeset
|
170 public List<HgFileRevision> getModifiedFiles() throws HgRuntimeException { |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
171 if (modifiedFiles == null) { |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
172 initFileChanges(); |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
173 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
174 return modifiedFiles; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
175 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
176 |
403
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
177 /** |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
178 * Figures out files added in this commit |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
179 * |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
180 * @return revisions of files added in this commit |
423
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
415
diff
changeset
|
181 * @throws HgRuntimeException subclass thereof to indicate issues with the library. <em>Runtime exception</em> |
403
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
182 */ |
423
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
415
diff
changeset
|
183 public List<HgFileRevision> getAddedFiles() throws HgRuntimeException { |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
184 if (addedFiles == null) { |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
185 initFileChanges(); |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
186 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
187 return addedFiles; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
188 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
189 |
403
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
190 /** |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
191 * 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
|
192 * |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
193 * @return revisions of files deleted in this commit |
423
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
415
diff
changeset
|
194 * @throws HgRuntimeException subclass thereof to indicate issues with the library. <em>Runtime exception</em> |
403
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
195 */ |
423
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
415
diff
changeset
|
196 public List<Path> getRemovedFiles() throws HgRuntimeException { |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
197 if (deletedFiles == null) { |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
198 initFileChanges(); |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
199 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
200 return deletedFiles; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
201 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
202 |
427
31a89587eb04
FIXMEs: consistent names, throws for commands and their handlers. Use of checked exceptions in hi-level api
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
424
diff
changeset
|
203 public boolean isMerge() throws HgRuntimeException { |
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
|
204 // 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
|
205 return !(getFirstParentRevision().isNull() || getSecondParentRevision().isNull()); |
125
26ad21b250e4
Explicit op to tell merge revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
124
diff
changeset
|
206 } |
124
cea84c5995e6
Changeset to access parent nodeids
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
207 |
274
9fb50c04f03c
Use Nodeid.isNull check instead of NULL.equals
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
231
diff
changeset
|
208 /** |
9fb50c04f03c
Use Nodeid.isNull check instead of NULL.equals
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
231
diff
changeset
|
209 * @return never <code>null</code> |
423
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
415
diff
changeset
|
210 * @throws HgRuntimeException subclass thereof to indicate issues with the library. <em>Runtime exception</em> |
274
9fb50c04f03c
Use Nodeid.isNull check instead of NULL.equals
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
231
diff
changeset
|
211 */ |
423
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
415
diff
changeset
|
212 public Nodeid getFirstParentRevision() throws HgRuntimeException { |
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
|
213 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
|
214 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
|
215 } |
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
|
216 // 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
|
217 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
|
218 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
|
219 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
|
220 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
|
221 } |
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 Nodeid.fromBinary(parent1, 0); |
124
cea84c5995e6
Changeset to access parent nodeids
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
223 } |
cea84c5995e6
Changeset to access parent nodeids
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
224 |
274
9fb50c04f03c
Use Nodeid.isNull check instead of NULL.equals
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
231
diff
changeset
|
225 /** |
9fb50c04f03c
Use Nodeid.isNull check instead of NULL.equals
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
231
diff
changeset
|
226 * @return never <code>null</code> |
423
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
415
diff
changeset
|
227 * @throws HgRuntimeException subclass thereof to indicate issues with the library. <em>Runtime exception</em> |
274
9fb50c04f03c
Use Nodeid.isNull check instead of NULL.equals
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
231
diff
changeset
|
228 */ |
423
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
415
diff
changeset
|
229 public Nodeid getSecondParentRevision() throws HgRuntimeException { |
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
|
230 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
|
231 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
|
232 } |
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
|
233 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
|
234 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
|
235 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
|
236 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
|
237 } |
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 return Nodeid.fromBinary(parent2, 0); |
124
cea84c5995e6
Changeset to access parent nodeids
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
239 } |
cea84c5995e6
Changeset to access parent nodeids
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
240 |
403
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
241 /** |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
242 * Create a copy of this changeset |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
380
diff
changeset
|
243 */ |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
244 @Override |
129
645829962785
core.Cset renamed to HgChangeset; repo.Changeset moved into HgChangelog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
125
diff
changeset
|
245 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
|
246 try { |
129
645829962785
core.Cset renamed to HgChangeset; repo.Changeset moved into HgChangelog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
125
diff
changeset
|
247 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
|
248 // 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
|
249 return copy; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
250 } catch (CloneNotSupportedException ex) { |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
251 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
|
252 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
253 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
254 |
423
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
415
diff
changeset
|
255 private /*synchronized*/ void initFileChanges() throws HgRuntimeException { |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
256 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
|
257 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
|
258 ArrayList<HgFileRevision> added = new ArrayList<HgFileRevision>(); |
94
af1f3b78b918
*StatusCollector renamed to Hg*StatusCollector
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
93
diff
changeset
|
259 HgStatusCollector.Record r = new HgStatusCollector.Record(); |
423
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
415
diff
changeset
|
260 try { |
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
415
diff
changeset
|
261 statusHelper.change(revNumber, r); |
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
415
diff
changeset
|
262 } catch (CancelledException ex) { |
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
415
diff
changeset
|
263 // Record can't cancel |
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
415
diff
changeset
|
264 throw new HgInvalidStateException("Internal error"); |
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
415
diff
changeset
|
265 } |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
266 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
|
267 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
|
268 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
|
269 if (nid == null) { |
423
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
415
diff
changeset
|
270 throw new HgInvalidStateException(String.format("For the file %s recorded as modified in changeset %d couldn't find revision after change", s, revNumber)); |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
271 } |
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
|
272 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
|
273 } |
316
ee6b467c1a5f
Supply HGFileRevision with copy information when possible, calculate it otherwise
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
274
diff
changeset
|
274 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
|
275 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
|
276 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
|
277 if (nid == null) { |
423
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
415
diff
changeset
|
278 throw new HgInvalidStateException(String.format("For the file %s recorded as added in changeset %d couldn't find revision after change", s, revNumber)); |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
279 } |
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
|
280 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
|
281 } |
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
|
282 for (Path s : r.getRemoved()) { |
124
cea84c5995e6
Changeset to access parent nodeids
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
283 // 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
|
284 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
|
285 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
286 modified.trimToSize(); |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
287 added.trimToSize(); |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
288 deleted.trimToSize(); |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
289 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
|
290 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
|
291 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
|
292 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
293 } |