Mercurial > jhg
comparison cmdline/org/tmatesoft/hg/console/Manifest.java @ 143:b9700740553a
Command line tools parse and respect most of command-line arguments
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Thu, 17 Feb 2011 22:16:25 +0100 |
parents | 4a948ec83980 |
children | 4c3b9f679412 |
comparison
equal
deleted
inserted
replaced
142:37a34044e6bd | 143:b9700740553a |
---|---|
17 package org.tmatesoft.hg.console; | 17 package org.tmatesoft.hg.console; |
18 | 18 |
19 import static org.tmatesoft.hg.repo.HgRepository.TIP; | 19 import static org.tmatesoft.hg.repo.HgRepository.TIP; |
20 | 20 |
21 import org.tmatesoft.hg.core.HgLogCommand.FileRevision; | 21 import org.tmatesoft.hg.core.HgLogCommand.FileRevision; |
22 import org.tmatesoft.hg.core.HgManifestCommand; | |
22 import org.tmatesoft.hg.core.Nodeid; | 23 import org.tmatesoft.hg.core.Nodeid; |
23 import org.tmatesoft.hg.core.HgManifestCommand; | |
24 import org.tmatesoft.hg.repo.HgManifest; | |
25 import org.tmatesoft.hg.repo.HgRepository; | 24 import org.tmatesoft.hg.repo.HgRepository; |
26 import org.tmatesoft.hg.util.Path; | 25 import org.tmatesoft.hg.util.Path; |
27 | 26 |
28 | 27 |
29 /** | 28 /** |
38 HgRepository hgRepo = cmdLineOpts.findRepository(); | 37 HgRepository hgRepo = cmdLineOpts.findRepository(); |
39 if (hgRepo.isInvalid()) { | 38 if (hgRepo.isInvalid()) { |
40 System.err.printf("Can't find repository in: %s\n", hgRepo.getLocation()); | 39 System.err.printf("Can't find repository in: %s\n", hgRepo.getLocation()); |
41 return; | 40 return; |
42 } | 41 } |
43 System.out.println(hgRepo.getLocation()); | 42 final boolean debug = cmdLineOpts.getBoolean("--debug"); |
44 hgRepo.getManifest().walk(0, TIP, new Dump()); | 43 final boolean verbose = cmdLineOpts.getBoolean("-v", "--verbose"); |
45 // | 44 HgManifestCommand.Handler h = new HgManifestCommand.Handler() { |
46 new HgManifestCommand(hgRepo).dirs(true).walk(new HgManifestCommand.Handler() { | |
47 | 45 |
48 public void begin(Nodeid manifestRevision) { | 46 public void begin(Nodeid manifestRevision) { |
49 System.out.println(">> " + manifestRevision); | |
50 } | 47 } |
51 public void dir(Path p) { | 48 public void dir(Path p) { |
52 System.out.println(p); | |
53 } | 49 } |
54 public void file(FileRevision fileRevision) { | 50 public void file(FileRevision fileRevision) { |
55 System.out.print(fileRevision.getRevision());; | 51 if (debug) { |
56 System.out.print(" "); | 52 System.out.print(fileRevision.getRevision());; |
53 } | |
54 if (debug || verbose) { | |
55 System.out.print(" 644"); // FIXME real flags! | |
56 System.out.print(" "); | |
57 } | |
57 System.out.println(fileRevision.getPath()); | 58 System.out.println(fileRevision.getPath()); |
58 } | 59 } |
59 | 60 |
60 public void end(Nodeid manifestRevision) { | 61 public void end(Nodeid manifestRevision) { |
61 System.out.println(); | |
62 } | 62 } |
63 }); | 63 }; |
64 } | 64 int rev = cmdLineOpts.getSingleInt(TIP, "-r", "--rev"); |
65 | 65 new HgManifestCommand(hgRepo).dirs(false).revision(rev).execute(h); |
66 public static final class Dump implements HgManifest.Inspector { | |
67 public boolean begin(int revision, Nodeid nid) { | |
68 System.out.printf("%d : %s\n", revision, nid); | |
69 return true; | |
70 } | |
71 | |
72 public boolean next(Nodeid nid, String fname, String flags) { | |
73 System.out.println(nid + "\t" + fname + "\t\t" + flags); | |
74 return true; | |
75 } | |
76 | |
77 public boolean end(int revision) { | |
78 System.out.println(); | |
79 return true; | |
80 } | |
81 } | 66 } |
82 } | 67 } |