comparison src/org/tmatesoft/hg/core/ChangesetTransformer.java @ 328:a674b8590362

Move file tree history to upper API level
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Wed, 05 Oct 2011 07:13:57 +0200
parents 41a778e3fd31
children ac8e1ce67730
comparison
equal deleted inserted replaced
327:3f09b8c19142 328:a674b8590362
35 * @author Artem Tikhomirov 35 * @author Artem Tikhomirov
36 * @author TMate Software Ltd. 36 * @author TMate Software Ltd.
37 */ 37 */
38 /*package-local*/ class ChangesetTransformer implements HgChangelog.Inspector { 38 /*package-local*/ class ChangesetTransformer implements HgChangelog.Inspector {
39 private final HgChangesetHandler handler; 39 private final HgChangesetHandler handler;
40 private final HgChangeset changeset;
41 private final ProgressSupport progressHelper; 40 private final ProgressSupport progressHelper;
42 private final CancelSupport cancelHelper; 41 private final CancelSupport cancelHelper;
42 private final Transformation t;
43 private Set<String> branches; 43 private Set<String> branches;
44 private HgCallbackTargetException failure; 44 private HgCallbackTargetException failure;
45 private CancelledException cancellation; 45 private CancelledException cancellation;
46 46
47 // repo and delegate can't be null, parent walker can 47 // repo and delegate can't be null, parent walker can
52 } 52 }
53 if (ps == null || cs == null) { 53 if (ps == null || cs == null) {
54 throw new IllegalArgumentException(); 54 throw new IllegalArgumentException();
55 } 55 }
56 HgStatusCollector statusCollector = new HgStatusCollector(hgRepo); 56 HgStatusCollector statusCollector = new HgStatusCollector(hgRepo);
57 // files listed in a changeset don't need their names to be rewritten (they are normalized already) 57 t = new Transformation(statusCollector, pw);
58 PathPool pp = new PathPool(new PathRewrite.Empty());
59 statusCollector.setPathPool(pp);
60 changeset = new HgChangeset(statusCollector, pp);
61 changeset.setParentHelper(pw);
62 handler = delegate; 58 handler = delegate;
63 cancelHelper = cs; 59 cancelHelper = cs;
64 progressHelper = ps; 60 progressHelper = ps;
65 } 61 }
66 62
70 } 66 }
71 if (branches != null && !branches.contains(cset.branch())) { 67 if (branches != null && !branches.contains(cset.branch())) {
72 return; 68 return;
73 } 69 }
74 70
75 changeset.init(revisionNumber, nodeid, cset); 71 HgChangeset changeset = t.handle(revisionNumber, nodeid, cset);
76 try { 72 try {
77 handler.next(changeset); 73 handler.next(changeset);
78 progressHelper.worked(1); 74 progressHelper.worked(1);
79 cancelHelper.checkCancelled(); 75 cancelHelper.checkCancelled();
80 } catch (RuntimeException ex) { 76 } catch (RuntimeException ex) {
98 } 94 }
99 95
100 public void limitBranches(Set<String> branches) { 96 public void limitBranches(Set<String> branches) {
101 this.branches = branches; 97 this.branches = branches;
102 } 98 }
99
100 // part relevant to RawChangeset->HgChangeset transformation
101 static class Transformation {
102 private final HgChangeset changeset;
103
104 public Transformation(HgStatusCollector statusCollector, HgChangelog.ParentWalker pw) {
105 // files listed in a changeset don't need their names to be rewritten (they are normalized already)
106 PathPool pp = new PathPool(new PathRewrite.Empty());
107 statusCollector.setPathPool(pp);
108 changeset = new HgChangeset(statusCollector, pp);
109 changeset.setParentHelper(pw);
110 }
111
112 HgChangeset handle(int revisionNumber, Nodeid nodeid, RawChangeset cset) {
113 changeset.init(revisionNumber, nodeid, cset);
114 return changeset;
115 }
116 }
103 } 117 }