Mercurial > jhg
comparison src/org/tmatesoft/hg/core/HgLogCommand.java @ 193:37f3d4a596e4
Use common low to hi-level changeset api transformer
| author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
|---|---|
| date | Fri, 15 Apr 2011 03:28:12 +0200 |
| parents | d5268ca7715b |
| children | c9b305df0b89 |
comparison
equal
deleted
inserted
replaced
| 192:e5407b5a586a | 193:37f3d4a596e4 |
|---|---|
| 29 | 29 |
| 30 import org.tmatesoft.hg.repo.HgChangelog.RawChangeset; | 30 import org.tmatesoft.hg.repo.HgChangelog.RawChangeset; |
| 31 import org.tmatesoft.hg.repo.HgChangelog; | 31 import org.tmatesoft.hg.repo.HgChangelog; |
| 32 import org.tmatesoft.hg.repo.HgDataFile; | 32 import org.tmatesoft.hg.repo.HgDataFile; |
| 33 import org.tmatesoft.hg.repo.HgRepository; | 33 import org.tmatesoft.hg.repo.HgRepository; |
| 34 import org.tmatesoft.hg.repo.HgStatusCollector; | |
| 35 import org.tmatesoft.hg.util.ByteChannel; | 34 import org.tmatesoft.hg.util.ByteChannel; |
| 36 import org.tmatesoft.hg.util.CancelledException; | 35 import org.tmatesoft.hg.util.CancelledException; |
| 37 import org.tmatesoft.hg.util.Path; | 36 import org.tmatesoft.hg.util.Path; |
| 38 import org.tmatesoft.hg.util.PathPool; | |
| 39 import org.tmatesoft.hg.util.PathRewrite; | |
| 40 | 37 |
| 41 | 38 |
| 42 /** | 39 /** |
| 43 * Access to changelog, 'hg log' command counterpart. | 40 * Access to changelog, 'hg log' command counterpart. |
| 44 * | 41 * |
| 56 private final HgRepository repo; | 53 private final HgRepository repo; |
| 57 private Set<String> users; | 54 private Set<String> users; |
| 58 private Set<String> branches; | 55 private Set<String> branches; |
| 59 private int limit = 0, count = 0; | 56 private int limit = 0, count = 0; |
| 60 private int startRev = 0, endRev = TIP; | 57 private int startRev = 0, endRev = TIP; |
| 61 private Handler delegate; | |
| 62 private Calendar date; | 58 private Calendar date; |
| 63 private Path file; | 59 private Path file; |
| 64 private boolean followHistory; // makes sense only when file != null | 60 private boolean followHistory; // makes sense only when file != null |
| 65 private HgChangeset changeset; | 61 private ChangesetTransformer csetTransform; |
| 66 | 62 |
| 67 public HgLogCommand(HgRepository hgRepo) { | 63 public HgLogCommand(HgRepository hgRepo) { |
| 68 repo = hgRepo; | 64 repo = hgRepo; |
| 69 } | 65 } |
| 70 | 66 |
| 181 */ | 177 */ |
| 182 public void execute(Handler handler) throws HgException { | 178 public void execute(Handler handler) throws HgException { |
| 183 if (handler == null) { | 179 if (handler == null) { |
| 184 throw new IllegalArgumentException(); | 180 throw new IllegalArgumentException(); |
| 185 } | 181 } |
| 186 if (delegate != null) { | 182 if (csetTransform != null) { |
| 187 throw new ConcurrentModificationException(); | 183 throw new ConcurrentModificationException(); |
| 188 } | 184 } |
| 189 try { | 185 try { |
| 190 delegate = handler; | |
| 191 count = 0; | 186 count = 0; |
| 192 HgStatusCollector statusCollector = new HgStatusCollector(repo); | 187 // ChangesetTransfrom creates a blank PathPool, and #file(String, boolean) above |
| 193 // files listed in a changeset don't need their names to be rewritten (they are normalized already) | 188 // may utilize it as well. CommandContext? How about StatusCollector there as well? |
| 194 PathPool pp = new PathPool(new PathRewrite.Empty()); | 189 csetTransform = new ChangesetTransformer(repo, handler); |
| 195 // #file(String, boolean) above may utilize PathPool as well. CommandContext? | |
| 196 statusCollector.setPathPool(pp); | |
| 197 changeset = new HgChangeset(statusCollector, pp); | |
| 198 if (file == null) { | 190 if (file == null) { |
| 199 repo.getChangelog().range(startRev, endRev, this); | 191 repo.getChangelog().range(startRev, endRev, this); |
| 200 } else { | 192 } else { |
| 201 HgDataFile fileNode = repo.getFileNode(file); | 193 HgDataFile fileNode = repo.getFileNode(file); |
| 202 fileNode.history(startRev, endRev, this); | 194 fileNode.history(startRev, endRev, this); |
| 218 } | 210 } |
| 219 } while (followHistory && fileNode.isCopy()); | 211 } while (followHistory && fileNode.isCopy()); |
| 220 } | 212 } |
| 221 } | 213 } |
| 222 } finally { | 214 } finally { |
| 223 delegate = null; | 215 csetTransform = null; |
| 224 changeset = null; | |
| 225 } | 216 } |
| 226 } | 217 } |
| 227 | 218 |
| 228 // | 219 // |
| 229 | 220 |
| 249 } | 240 } |
| 250 if (date != null) { | 241 if (date != null) { |
| 251 // FIXME | 242 // FIXME |
| 252 } | 243 } |
| 253 count++; | 244 count++; |
| 254 changeset.init(revisionNumber, nodeid, cset); | 245 csetTransform.next(revisionNumber, nodeid, cset); |
| 255 delegate.next(changeset); | |
| 256 } | 246 } |
| 257 | 247 |
| 258 public interface Handler { | 248 public interface Handler { |
| 259 /** | 249 /** |
| 260 * @param changeset not necessarily a distinct instance each time, {@link HgChangeset#clone() clone()} if need a copy. | 250 * @param changeset not necessarily a distinct instance each time, {@link HgChangeset#clone() clone()} if need a copy. |
