Mercurial > jhg
diff 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 |
line wrap: on
line diff
--- a/cmdline/org/tmatesoft/hg/console/Manifest.java Thu Feb 17 05:06:07 2011 +0100 +++ b/cmdline/org/tmatesoft/hg/console/Manifest.java Thu Feb 17 22:16:25 2011 +0100 @@ -19,9 +19,8 @@ import static org.tmatesoft.hg.repo.HgRepository.TIP; import org.tmatesoft.hg.core.HgLogCommand.FileRevision; +import org.tmatesoft.hg.core.HgManifestCommand; import org.tmatesoft.hg.core.Nodeid; -import org.tmatesoft.hg.core.HgManifestCommand; -import org.tmatesoft.hg.repo.HgManifest; import org.tmatesoft.hg.repo.HgRepository; import org.tmatesoft.hg.util.Path; @@ -40,43 +39,29 @@ System.err.printf("Can't find repository in: %s\n", hgRepo.getLocation()); return; } - System.out.println(hgRepo.getLocation()); - hgRepo.getManifest().walk(0, TIP, new Dump()); - // - new HgManifestCommand(hgRepo).dirs(true).walk(new HgManifestCommand.Handler() { + final boolean debug = cmdLineOpts.getBoolean("--debug"); + final boolean verbose = cmdLineOpts.getBoolean("-v", "--verbose"); + HgManifestCommand.Handler h = new HgManifestCommand.Handler() { public void begin(Nodeid manifestRevision) { - System.out.println(">> " + manifestRevision); } public void dir(Path p) { - System.out.println(p); } public void file(FileRevision fileRevision) { - System.out.print(fileRevision.getRevision());; - System.out.print(" "); + if (debug) { + System.out.print(fileRevision.getRevision());; + } + if (debug || verbose) { + System.out.print(" 644"); // FIXME real flags! + System.out.print(" "); + } System.out.println(fileRevision.getPath()); } public void end(Nodeid manifestRevision) { - System.out.println(); } - }); - } - - public static final class Dump implements HgManifest.Inspector { - public boolean begin(int revision, Nodeid nid) { - System.out.printf("%d : %s\n", revision, nid); - return true; - } - - public boolean next(Nodeid nid, String fname, String flags) { - System.out.println(nid + "\t" + fname + "\t\t" + flags); - return true; - } - - public boolean end(int revision) { - System.out.println(); - return true; - } + }; + int rev = cmdLineOpts.getSingleInt(TIP, "-r", "--rev"); + new HgManifestCommand(hgRepo).dirs(false).revision(rev).execute(h); } }