Mercurial > jhg
comparison src/org/tmatesoft/hg/core/HgStatusCommand.java @ 683:98ff1fb49abe
Update commands to use changeset Nodeid and int in uniform way, clients of core.* classes shall not go back and forth from int to Nodeid
| author | Artem Tikhomirov <tikhomirov.artem@gmail.com> | 
|---|---|
| date | Wed, 24 Jul 2013 16:40:15 +0200 | 
| parents | 90df078d6418 | 
| children | 1499139a600a | 
   comparison
  equal
  deleted
  inserted
  replaced
| 682:f568330dd9c0 | 683:98ff1fb49abe | 
|---|---|
| 1 /* | 1 /* | 
| 2 * Copyright (c) 2011-2012 TMate Software Ltd | 2 * Copyright (c) 2011-2013 TMate Software Ltd | 
| 3 * | 3 * | 
| 4 * This program is free software; you can redistribute it and/or modify | 4 * This program is free software; you can redistribute it and/or modify | 
| 5 * it under the terms of the GNU General Public License as published by | 5 * it under the terms of the GNU General Public License as published by | 
| 6 * the Free Software Foundation; version 2 of the License. | 6 * the Free Software Foundation; version 2 of the License. | 
| 7 * | 7 * | 
| 23 import java.io.IOException; | 23 import java.io.IOException; | 
| 24 import java.util.ConcurrentModificationException; | 24 import java.util.ConcurrentModificationException; | 
| 25 | 25 | 
| 26 import org.tmatesoft.hg.internal.AdapterPlug; | 26 import org.tmatesoft.hg.internal.AdapterPlug; | 
| 27 import org.tmatesoft.hg.internal.ChangelogHelper; | 27 import org.tmatesoft.hg.internal.ChangelogHelper; | 
| 28 import org.tmatesoft.hg.internal.CsetParamKeeper; | |
| 28 import org.tmatesoft.hg.internal.Internals; | 29 import org.tmatesoft.hg.internal.Internals; | 
| 29 import org.tmatesoft.hg.repo.HgRepository; | 30 import org.tmatesoft.hg.repo.HgRepository; | 
| 30 import org.tmatesoft.hg.repo.HgRuntimeException; | 31 import org.tmatesoft.hg.repo.HgRuntimeException; | 
| 31 import org.tmatesoft.hg.repo.HgStatusCollector; | 32 import org.tmatesoft.hg.repo.HgStatusCollector; | 
| 32 import org.tmatesoft.hg.repo.HgStatusInspector; | 33 import org.tmatesoft.hg.repo.HgStatusInspector; | 
| 113 } | 114 } | 
| 114 if (changesetRevisionIndex == BAD_REVISION) { | 115 if (changesetRevisionIndex == BAD_REVISION) { | 
| 115 changesetRevisionIndex = TIP; | 116 changesetRevisionIndex = TIP; | 
| 116 } | 117 } | 
| 117 startRevision = changesetRevisionIndex; | 118 startRevision = changesetRevisionIndex; | 
| 118 return this; | 119 // TODO [2.0 API break] shall throw HgBadArgumentException, like other commands do | 
| 119 } | 120 return this; | 
| 120 | 121 } | 
| 122 | |
| 123 /** | |
| 124 * Select base revision for difference | |
| 125 * @param changeset changelog revision, left range boundary if used in conjunction with {@link #revision(int)} | |
| 126 * @return <code>this</code> for convenience | |
| 127 * @throws HgBadArgumentException if revision is not a valid changeset identifier | |
| 128 */ | |
| 129 public HgStatusCommand base(Nodeid changeset) throws HgBadArgumentException { | |
| 130 int ri = new CsetParamKeeper(repo).set(changeset).get(); | |
| 131 return base(ri); | |
| 132 } | |
| 133 | |
| 121 /** | 134 /** | 
| 122 * Revision without base == --change | 135 * Revision without base == --change | 
| 123 * Pass {@link HgRepository#WORKING_COPY} or {@link HgRepository#BAD_REVISION} to reset | 136 * Pass {@link HgRepository#WORKING_COPY} or {@link HgRepository#BAD_REVISION} to reset | 
| 124 * @param changesetRevisionIndex - non-negative changeset revision local index, or any of {@link HgRepository#BAD_REVISION}, {@link HgRepository#WORKING_COPY} or {@link HgRepository#TIP} | 137 * @param changesetRevisionIndex - non-negative changeset revision local index, or any of {@link HgRepository#BAD_REVISION}, {@link HgRepository#WORKING_COPY} or {@link HgRepository#TIP} | 
| 125 * @return <code>this</code> for convenience | 138 * @return <code>this</code> for convenience | 
| 131 } | 144 } | 
| 132 if (wrongRevisionIndex(changesetRevisionIndex)) { | 145 if (wrongRevisionIndex(changesetRevisionIndex)) { | 
| 133 throw new IllegalArgumentException(String.valueOf(changesetRevisionIndex)); | 146 throw new IllegalArgumentException(String.valueOf(changesetRevisionIndex)); | 
| 134 } | 147 } | 
| 135 endRevision = changesetRevisionIndex; | 148 endRevision = changesetRevisionIndex; | 
| 136 return this; | 149 // TODO [2.0 API break] shall throw HgBadArgumentException, like other commands do | 
| 137 } | 150 return this; | 
| 138 | 151 } | 
| 152 | |
| 153 /** | |
| 154 * Select changeset to show difference | |
| 155 * @see #revision(int) | |
| 156 * @param changeset changelog revision, right range boundary if <code>base</code> revision is set | |
| 157 * @return <code>this</code> for convenience | |
| 158 * @throws HgBadArgumentException if revision is not a valid changeset identifier | |
| 159 */ | |
| 160 public HgStatusCommand revision(Nodeid changeset) throws HgBadArgumentException { | |
| 161 int ri = new CsetParamKeeper(repo).set(changeset).get(); | |
| 162 return revision(ri); | |
| 163 } | |
| 164 | |
| 139 /** | 165 /** | 
| 140 * Shorthand for {@link #base(int) cmd.base(BAD_REVISION)}{@link #change(int) .revision(revision)} | 166 * Shorthand for {@link #base(int) cmd.base(BAD_REVISION)}{@link #change(int) .revision(revision)} | 
| 141 * | 167 * | 
| 142 * @param changesetRevisionIndex compare given revision against its parent | 168 * @param changesetIndex compare given revision against its parent | 
| 143 * @return <code>this</code> for convenience | 169 * @return <code>this</code> for convenience | 
| 144 */ | 170 */ | 
| 145 public HgStatusCommand change(int changesetRevisionIndex) { | 171 public HgStatusCommand change(int changesetIndex) { | 
| 146 base(BAD_REVISION); | 172 base(BAD_REVISION); | 
| 147 return revision(changesetRevisionIndex); | 173 return revision(changesetIndex); | 
| 148 } | 174 } | 
| 149 | 175 | 
| 176 /** | |
| 177 * Report changes in specified changeset | |
| 178 * @see #change(int) | |
| 179 * @param changeset changelog revision to get status of | |
| 180 * @return <code>this</code> for convenience | |
| 181 * @throws HgBadArgumentException if revision is not a valid changeset identifier | |
| 182 */ | |
| 183 public HgStatusCommand change(Nodeid changeset) throws HgBadArgumentException { | |
| 184 base(BAD_REVISION); | |
| 185 return revision(changeset); | |
| 186 } | |
| 187 | |
| 150 /** | 188 /** | 
| 151 * Limit status operation to certain sub-tree. | 189 * Limit status operation to certain sub-tree. | 
| 152 * | 190 * | 
| 153 * @param scopeMatcher - matcher to use, pass <code>null/<code> to reset | 191 * @param scopeMatcher - matcher to use, pass <code>null/<code> to reset | 
| 154 * @return <code>this</code> for convenience | 192 * @return <code>this</code> for convenience | 
