comparison src/com/tmate/hgkit/console/Log.java @ 60:613c936d74e4

Log operation to output mode detailed (added, removed) files
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Tue, 18 Jan 2011 00:30:41 +0100
parents f1db8610da62
children e21df6259f83
comparison
equal deleted inserted replaced
59:b771e94a4f7c 60:613c936d74e4
14 import com.tmate.hgkit.ll.Changeset; 14 import com.tmate.hgkit.ll.Changeset;
15 import com.tmate.hgkit.ll.HgDataFile; 15 import com.tmate.hgkit.ll.HgDataFile;
16 import com.tmate.hgkit.ll.HgRepository; 16 import com.tmate.hgkit.ll.HgRepository;
17 import com.tmate.hgkit.ll.Nodeid; 17 import com.tmate.hgkit.ll.Nodeid;
18 import com.tmate.hgkit.ll.Revlog; 18 import com.tmate.hgkit.ll.Revlog;
19 import com.tmate.hgkit.ll.StatusCollector;
19 20
20 /** 21 /**
21 * @author artem 22 * @author artem
22 */ 23 */
23 public class Log { 24 public class Log {
31 return; 32 return;
32 } 33 }
33 System.out.println(hgRepo.getLocation()); 34 System.out.println(hgRepo.getLocation());
34 final Dump dump = new Dump(hgRepo); 35 final Dump dump = new Dump(hgRepo);
35 dump.complete = true; //cmdLineOpts; 36 dump.complete = true; //cmdLineOpts;
37 dump.verbose = false; //cmdLineOpts;
36 dump.reverseOrder = true; 38 dump.reverseOrder = true;
37 dump.branches = cmdLineOpts.branches; 39 dump.branches = cmdLineOpts.branches;
38 if (cmdLineOpts.users != null) { 40 if (cmdLineOpts.users != null) {
39 dump.users = new LinkedHashSet<String>(); 41 dump.users = new LinkedHashSet<String>();
40 for (String u : cmdLineOpts.users) { 42 for (String u : cmdLineOpts.users) {
94 96
95 // Differences with standard hg log output 97 // Differences with standard hg log output
96 // - complete == true (--debug) files are not broke down to modified,+ and - 98 // - complete == true (--debug) files are not broke down to modified,+ and -
97 private static final class Dump implements Changeset.Inspector { 99 private static final class Dump implements Changeset.Inspector {
98 // params 100 // params
99 boolean complete = false; 101 boolean complete = false; // roughly --debug
100 boolean reverseOrder = false; 102 boolean reverseOrder = false;
101 Set<String> branches; 103 Set<String> branches;
102 Set<String> users; // shall be lowercased 104 Set<String> users; // shall be lowercased
105 boolean verbose = true; // roughly -v
103 // own 106 // own
104 private LinkedList<String> l = new LinkedList<String>(); 107 private LinkedList<String> l = new LinkedList<String>();
105 private final HgRepository repo; 108 private final HgRepository repo;
106 private Revlog.ParentWalker changelogWalker; 109 private Revlog.ParentWalker changelogWalker;
107 private final int tip ; 110 private final int tip ;
111 private StatusCollector statusHelper;
108 112
109 public Dump(HgRepository hgRepo) { 113 public Dump(HgRepository hgRepo) {
110 repo = hgRepo; 114 repo = hgRepo;
111 tip = hgRepo.getChangelog().getRevisionCount() - 1; 115 tip = hgRepo.getChangelog().getRevisionCount() - 1;
112 } 116 }
174 int p2x = p2 == Nodeid.NULL ? -1 : repo.getChangelog().getLocalRevisionNumber(p2); 178 int p2x = p2 == Nodeid.NULL ? -1 : repo.getChangelog().getLocalRevisionNumber(p2);
175 int mx = repo.getManifest().getLocalRevisionNumber(cset.manifest()); 179 int mx = repo.getManifest().getLocalRevisionNumber(cset.manifest());
176 f.format("parent: %d:%s\nparent: %d:%s\nmanifest: %d:%s\n", p1x, p1, p2x, p2, mx, cset.manifest()); 180 f.format("parent: %d:%s\nparent: %d:%s\nmanifest: %d:%s\n", p1x, p1, p2x, p2, mx, cset.manifest());
177 } 181 }
178 f.format("user: %s\ndate: %s\n", cset.user(), cset.dateString()); 182 f.format("user: %s\ndate: %s\n", cset.user(), cset.dateString());
179 if (complete) { 183 if (!complete && verbose) {
180 final List<String> files = cset.files(); 184 final List<String> files = cset.files();
181 sb.append("files: "); 185 sb.append("files: ");
182 for (String s : files) { 186 for (String s : files) {
183 sb.append(' '); 187 sb.append(' ');
184 sb.append(s); 188 sb.append(s);
185 } 189 }
190 sb.append('\n');
191 }
192 if (complete) {
193 if (statusHelper == null) {
194 statusHelper = new StatusCollector(repo);
195 }
196 StatusCollector.Record r = new StatusCollector.Record();
197 statusHelper.change(revNumber, r);
198 if (!r.getModified().isEmpty()) {
199 sb.append("files: ");
200 for (String s : r.getModified()) {
201 sb.append(' ');
202 sb.append(s);
203 }
204 sb.append('\n');
205 }
206 if (!r.getAdded().isEmpty()) {
207 sb.append("files+: ");
208 for (String s : r.getAdded()) {
209 sb.append(' ');
210 sb.append(s);
211 }
212 sb.append('\n');
213 }
214 if (!r.getRemoved().isEmpty()) {
215 sb.append("files-: ");
216 for (String s : r.getRemoved()) {
217 sb.append(' ');
218 sb.append(s);
219 }
220 sb.append('\n');
221 }
186 if (cset.extras() != null) { 222 if (cset.extras() != null) {
187 sb.append("\nextra: "); 223 sb.append("extra: ");
188 for (Map.Entry<String, String> e : cset.extras().entrySet()) { 224 for (Map.Entry<String, String> e : cset.extras().entrySet()) {
189 sb.append(' '); 225 sb.append(' ');
190 sb.append(e.getKey()); 226 sb.append(e.getKey());
191 sb.append('='); 227 sb.append('=');
192 sb.append(e.getValue()); 228 sb.append(e.getValue());
193 } 229 }
194 } 230 sb.append('\n');
195 f.format("\ndescription:\n%s\n\n", cset.comment()); 231 }
232 }
233 if (complete || verbose) {
234 f.format("description:\n%s\n\n", cset.comment());
196 } else { 235 } else {
197 f.format("summary: %s\n\n", cset.comment()); 236 f.format("summary: %s\n\n", cset.comment());
198 } 237 }
199 return sb.toString(); 238 return sb.toString();
200 } 239 }