comparison src/org/tmatesoft/hg/core/ChangesetTransformer.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 e5407b5a586a
children c9b305df0b89
comparison
equal deleted inserted replaced
192:e5407b5a586a 193:37f3d4a596e4
14 * the terms of a license other than GNU General Public License 14 * the terms of a license other than GNU General Public License
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 java.util.Set;
20
19 import org.tmatesoft.hg.repo.HgChangelog; 21 import org.tmatesoft.hg.repo.HgChangelog;
20 import org.tmatesoft.hg.repo.HgRepository; 22 import org.tmatesoft.hg.repo.HgRepository;
21 import org.tmatesoft.hg.repo.HgStatusCollector; 23 import org.tmatesoft.hg.repo.HgStatusCollector;
22 import org.tmatesoft.hg.repo.HgChangelog.RawChangeset; 24 import org.tmatesoft.hg.repo.HgChangelog.RawChangeset;
23 import org.tmatesoft.hg.util.PathPool; 25 import org.tmatesoft.hg.util.PathPool;
30 * @author TMate Software Ltd. 32 * @author TMate Software Ltd.
31 */ 33 */
32 /*package-local*/ class ChangesetTransformer implements HgChangelog.Inspector { 34 /*package-local*/ class ChangesetTransformer implements HgChangelog.Inspector {
33 private final HgLogCommand.Handler handler; 35 private final HgLogCommand.Handler handler;
34 private final HgChangeset changeset; 36 private final HgChangeset changeset;
37 private Set<String> branches;
35 38
36 public ChangesetTransformer(HgRepository hgRepo, HgLogCommand.Handler delegate) { 39 public ChangesetTransformer(HgRepository hgRepo, HgLogCommand.Handler delegate) {
37 if (hgRepo == null || delegate == null) { 40 if (hgRepo == null || delegate == null) {
38 throw new IllegalArgumentException(); 41 throw new IllegalArgumentException();
39 } 42 }
40 HgStatusCollector statusCollector = new HgStatusCollector(hgRepo); 43 HgStatusCollector statusCollector = new HgStatusCollector(hgRepo);
44 // files listed in a changeset don't need their names to be rewritten (they are normalized already)
41 PathPool pp = new PathPool(new PathRewrite.Empty()); 45 PathPool pp = new PathPool(new PathRewrite.Empty());
42 statusCollector.setPathPool(pp); 46 statusCollector.setPathPool(pp);
43 changeset = new HgChangeset(statusCollector, pp); 47 changeset = new HgChangeset(statusCollector, pp);
44 handler = delegate; 48 handler = delegate;
45 } 49 }
46 50
47 public void next(int revisionNumber, Nodeid nodeid, RawChangeset cset) { 51 public void next(int revisionNumber, Nodeid nodeid, RawChangeset cset) {
52 if (branches != null && !branches.contains(cset.branch())) {
53 return;
54 }
55
48 changeset.init(revisionNumber, nodeid, cset); 56 changeset.init(revisionNumber, nodeid, cset);
49 handler.next(changeset); 57 handler.next(changeset);
50 } 58 }
59
60 public void limitBranches(Set<String> branches) {
61 this.branches = branches;
62 }
51 } 63 }