comparison hg4j/src/main/java/org/tmatesoft/hg/core/ChangesetTransformer.java @ 213:6ec4af642ba8 gradle

Project uses Gradle for build - actual changes
author Alexander Kitaev <kitaev@gmail.com>
date Tue, 10 May 2011 10:52:53 +0200
parents
children
comparison
equal deleted inserted replaced
212:edb2e2829352 213:6ec4af642ba8
1 /*
2 * Copyright (c) 2011 TMate Software Ltd
3 *
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
6 * the Free Software Foundation; version 2 of the License.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * For information on how to redistribute this software under
14 * the terms of a license other than GNU General Public License
15 * contact TMate Software at support@hg4j.com
16 */
17 package org.tmatesoft.hg.core;
18
19 import java.util.Set;
20
21 import org.tmatesoft.hg.repo.HgChangelog;
22 import org.tmatesoft.hg.repo.HgChangelog.RawChangeset;
23 import org.tmatesoft.hg.repo.HgRepository;
24 import org.tmatesoft.hg.repo.HgStatusCollector;
25 import org.tmatesoft.hg.util.PathPool;
26 import org.tmatesoft.hg.util.PathRewrite;
27
28 /**
29 * Bridges {@link HgChangelog.RawChangeset} with high-level {@link HgChangeset} API
30 *
31 * @author Artem Tikhomirov
32 * @author TMate Software Ltd.
33 */
34 /*package-local*/ class ChangesetTransformer implements HgChangelog.Inspector {
35 private final HgChangesetHandler handler;
36 private final HgChangeset changeset;
37 private Set<String> branches;
38
39 // repo and delegate can't be null, parent walker can
40 public ChangesetTransformer(HgRepository hgRepo, HgChangesetHandler delegate, HgChangelog.ParentWalker pw) {
41 if (hgRepo == null || delegate == null) {
42 throw new IllegalArgumentException();
43 }
44 HgStatusCollector statusCollector = new HgStatusCollector(hgRepo);
45 // files listed in a changeset don't need their names to be rewritten (they are normalized already)
46 PathPool pp = new PathPool(new PathRewrite.Empty());
47 statusCollector.setPathPool(pp);
48 changeset = new HgChangeset(statusCollector, pp);
49 changeset.setParentHelper(pw);
50 handler = delegate;
51 }
52
53 public void next(int revisionNumber, Nodeid nodeid, RawChangeset cset) {
54 if (branches != null && !branches.contains(cset.branch())) {
55 return;
56 }
57
58 changeset.init(revisionNumber, nodeid, cset);
59 handler.next(changeset);
60 }
61
62 public void limitBranches(Set<String> branches) {
63 this.branches = branches;
64 }
65 }