Mercurial > jhg
comparison src/org/tmatesoft/hg/core/HgStatusCommand.java @ 148:1a7a9a20e1f9
Exceptions, javadoc. Initial cancel and progress support
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Wed, 23 Feb 2011 22:36:28 +0100 |
parents | b9700740553a |
children | 6b55f10ef54b |
comparison
equal
deleted
inserted
replaced
147:a05145db4d0c | 148:1a7a9a20e1f9 |
---|---|
15 * contact TMate Software at support@hg4j.com | 15 * contact TMate Software at support@hg4j.com |
16 */ | 16 */ |
17 package org.tmatesoft.hg.core; | 17 package org.tmatesoft.hg.core; |
18 | 18 |
19 import static org.tmatesoft.hg.core.HgStatus.Kind.*; | 19 import static org.tmatesoft.hg.core.HgStatus.Kind.*; |
20 import static org.tmatesoft.hg.repo.HgInternals.wrongLocalRevision; | |
20 import static org.tmatesoft.hg.repo.HgRepository.*; | 21 import static org.tmatesoft.hg.repo.HgRepository.*; |
21 | 22 |
22 import java.util.ConcurrentModificationException; | 23 import java.util.ConcurrentModificationException; |
23 | 24 |
24 import org.tmatesoft.hg.internal.ChangelogHelper; | 25 import org.tmatesoft.hg.internal.ChangelogHelper; |
91 mediator.needIgnored = include; | 92 mediator.needIgnored = include; |
92 return this; | 93 return this; |
93 } | 94 } |
94 | 95 |
95 /** | 96 /** |
96 * if set, either base:revision or base:workingdir | 97 * If set, either base:revision or base:workingdir |
97 * to unset, pass {@link HgRepository#TIP} or {@link HgRepository#BAD_REVISION} | 98 * to unset, pass {@link HgRepository#TIP} or {@link HgRepository#BAD_REVISION} |
98 * @param revision | 99 * @param revision - local revision number to base status from |
99 * @return | 100 * @return <code>this</code> for convenience |
100 */ | 101 * @throws IllegalArgumentException when revision is negative or {@link HgRepository#WORKING_COPY} |
101 | 102 */ |
102 public HgStatusCommand base(int revision) { | 103 public HgStatusCommand base(int revision) { |
103 if (revision == WORKING_COPY) { | 104 if (revision == WORKING_COPY || wrongLocalRevision(revision)) { |
104 throw new IllegalArgumentException(); | 105 throw new IllegalArgumentException(String.valueOf(revision)); |
105 } | 106 } |
106 if (revision == BAD_REVISION) { | 107 if (revision == BAD_REVISION) { |
107 revision = TIP; | 108 revision = TIP; |
108 } | 109 } |
109 startRevision = revision; | 110 startRevision = revision; |
111 } | 112 } |
112 | 113 |
113 /** | 114 /** |
114 * Revision without base == --change | 115 * Revision without base == --change |
115 * Pass {@link HgRepository#WORKING_COPY} or {@link HgRepository#BAD_REVISION} to reset | 116 * Pass {@link HgRepository#WORKING_COPY} or {@link HgRepository#BAD_REVISION} to reset |
116 * @param revision | 117 * @param revision - non-negative local revision number, or any of {@link HgRepository#BAD_REVISION}, {@link HgRepository#WORKING_COPY} or {@link HgRepository#TIP} |
117 * @return | 118 * @return <code>this</code> for convenience |
119 * @throws IllegalArgumentException if local revision number doesn't specify legitimate revision. | |
118 */ | 120 */ |
119 public HgStatusCommand revision(int revision) { | 121 public HgStatusCommand revision(int revision) { |
120 if (revision == BAD_REVISION) { | 122 if (revision == BAD_REVISION) { |
121 revision = WORKING_COPY; | 123 revision = WORKING_COPY; |
122 } | 124 } |
123 if (revision != TIP && revision != WORKING_COPY && revision < 0) { | 125 if (wrongLocalRevision(revision)) { |
124 throw new IllegalArgumentException(String.valueOf(revision)); | 126 throw new IllegalArgumentException(String.valueOf(revision)); |
125 } | 127 } |
126 endRevision = revision; | 128 endRevision = revision; |
127 return this; | 129 return this; |
128 } | 130 } |
129 | 131 |
130 /** | 132 /** |
131 * Shorthand for {@link #base(int) cmd.base(BAD_REVISION)}{@link #change(int) .revision(revision)} | 133 * Shorthand for {@link #base(int) cmd.base(BAD_REVISION)}{@link #change(int) .revision(revision)} |
132 * | 134 * |
133 * @param revision compare given revision against its parent | 135 * @param revision compare given revision against its parent |
134 * @return | 136 * @return <code>this</code> for convenience |
135 */ | 137 */ |
136 public HgStatusCommand change(int revision) { | 138 public HgStatusCommand change(int revision) { |
137 base(BAD_REVISION); | 139 base(BAD_REVISION); |
138 return revision(revision); | 140 return revision(revision); |
139 } | 141 } |
140 | 142 |
141 // pass null to reset | 143 /** |
144 * Limit status operation to certain sub-tree. | |
145 * | |
146 * @param pathMatcher - matcher to use, pass <code>null/<code> to reset | |
147 * @return <code>this</code> for convenience | |
148 */ | |
142 public HgStatusCommand match(Path.Matcher pathMatcher) { | 149 public HgStatusCommand match(Path.Matcher pathMatcher) { |
143 mediator.matcher = pathMatcher; | 150 mediator.matcher = pathMatcher; |
144 return this; | 151 return this; |
145 } | 152 } |
146 | 153 |