comparison cmdline/org/tmatesoft/hg/console/Log.java @ 142:37a34044e6bd

More reasonable use of path normalizer and path.source
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Thu, 17 Feb 2011 05:06:07 +0100
parents 4a948ec83980
children b9700740553a
comparison
equal deleted inserted replaced
141:8248aae33f7d 142:37a34044e6bd
22 22
23 import org.tmatesoft.hg.core.HgChangeset; 23 import org.tmatesoft.hg.core.HgChangeset;
24 import org.tmatesoft.hg.core.HgLogCommand; 24 import org.tmatesoft.hg.core.HgLogCommand;
25 import org.tmatesoft.hg.core.HgLogCommand.FileRevision; 25 import org.tmatesoft.hg.core.HgLogCommand.FileRevision;
26 import org.tmatesoft.hg.core.Nodeid; 26 import org.tmatesoft.hg.core.Nodeid;
27 import org.tmatesoft.hg.repo.HgChangelog;
28 import org.tmatesoft.hg.repo.HgDataFile; 27 import org.tmatesoft.hg.repo.HgDataFile;
29 import org.tmatesoft.hg.repo.HgRepository; 28 import org.tmatesoft.hg.repo.HgRepository;
30 import org.tmatesoft.hg.util.Path; 29 import org.tmatesoft.hg.util.Path;
31 30
32 31
80 dump.complete(); 79 dump.complete();
81 } else { 80 } else {
82 for (String fname : cmdLineOpts.files) { 81 for (String fname : cmdLineOpts.files) {
83 HgDataFile f1 = hgRepo.getFileNode(fname); 82 HgDataFile f1 = hgRepo.getFileNode(fname);
84 System.out.println("History of the file: " + f1.getPath()); 83 System.out.println("History of the file: " + f1.getPath());
85 String normalizesName = hgRepo.getPathHelper().rewrite(fname);
86 if (cmdLineOpts.limit == -1) { 84 if (cmdLineOpts.limit == -1) {
87 cmd.file(Path.create(normalizesName), true).execute(dump); 85 cmd.file(f1.getPath(), true).execute(dump);
88 } else { 86 } else {
89 int[] r = new int[] { 0, f1.getRevisionCount() }; 87 int[] r = new int[] { 0, f1.getRevisionCount() };
90 if (fixRange(r, dump.reverseOrder, cmdLineOpts.limit) == 0) { 88 if (fixRange(r, dump.reverseOrder, cmdLineOpts.limit) == 0) {
91 System.out.println("No changes"); 89 System.out.println("No changes");
92 continue; 90 continue;
93 } 91 }
94 cmd.range(r[0], r[1]).file(Path.create(normalizesName), true).execute(dump); 92 cmd.range(r[0], r[1]).file(f1.getPath(), true).execute(dump);
95 } 93 }
96 dump.complete(); 94 dump.complete();
97 } 95 }
98 } 96 }
99 // 97 //
121 boolean reverseOrder = false; 119 boolean reverseOrder = false;
122 boolean verbose = true; // roughly -v 120 boolean verbose = true; // roughly -v
123 // own 121 // own
124 private LinkedList<String> l = new LinkedList<String>(); 122 private LinkedList<String> l = new LinkedList<String>();
125 private final HgRepository repo; 123 private final HgRepository repo;
126 private HgChangelog.ParentWalker changelogWalker; 124 // private HgChangelog.ParentWalker changelogWalker;
127 private final int tip ; 125 private final int tip ;
128 126
129 public Dump(HgRepository hgRepo) { 127 public Dump(HgRepository hgRepo) {
130 repo = hgRepo; 128 repo = hgRepo;
131 tip = hgRepo.getChangelog().getRevisionCount() - 1; 129 tip = hgRepo.getChangelog().getLastRevision();
132 } 130 }
133 131
134 public void copy(FileRevision from, FileRevision to) { 132 public void copy(FileRevision from, FileRevision to) {
135 System.out.printf("Got notified that %s(%s) was originally known as %s(%s)\n", to.getPath(), to.getRevision(), from.getPath(), from.getRevision()); 133 System.out.printf("Got notified that %s(%s) was originally known as %s(%s)\n", to.getPath(), to.getRevision(), from.getPath(), from.getRevision());
136 } 134 }
153 } 151 }
154 for (String s : l) { 152 for (String s : l) {
155 System.out.print(s); 153 System.out.print(s);
156 } 154 }
157 l.clear(); 155 l.clear();
158 changelogWalker = null; 156 // changelogWalker = null;
159 } 157 }
160 158
161 private String print(HgChangeset cset) { 159 private String print(HgChangeset cset) {
162 StringBuilder sb = new StringBuilder(); 160 StringBuilder sb = new StringBuilder();
163 Formatter f = new Formatter(sb); 161 Formatter f = new Formatter(sb);