tikhomirov@13: /*
tikhomirov@72:  * Copyright (c) 2010-2011 TMate Software Ltd
tikhomirov@72:  *  
tikhomirov@72:  * This program is free software; you can redistribute it and/or modify
tikhomirov@72:  * it under the terms of the GNU General Public License as published by
tikhomirov@72:  * the Free Software Foundation; version 2 of the License.
tikhomirov@72:  *
tikhomirov@72:  * This program is distributed in the hope that it will be useful,
tikhomirov@72:  * but WITHOUT ANY WARRANTY; without even the implied warranty of
tikhomirov@72:  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
tikhomirov@72:  * GNU General Public License for more details.
tikhomirov@72:  *
tikhomirov@72:  * For information on how to redistribute this software under
tikhomirov@72:  * the terms of a license other than GNU General Public License
tikhomirov@102:  * contact TMate Software at support@hg4j.com
tikhomirov@13:  */
tikhomirov@72: package org.tmatesoft.hg.console;
tikhomirov@13: 
tikhomirov@74: import static org.tmatesoft.hg.repo.HgRepository.TIP;
tikhomirov@19: 
tikhomirov@249: import org.tmatesoft.hg.core.HgFileRevision;
tikhomirov@143: import org.tmatesoft.hg.core.HgManifestCommand;
tikhomirov@74: import org.tmatesoft.hg.core.Nodeid;
tikhomirov@74: import org.tmatesoft.hg.repo.HgRepository;
tikhomirov@133: import org.tmatesoft.hg.util.Path;
tikhomirov@64: 
tikhomirov@13: 
tikhomirov@13: /**
tikhomirov@13:  *
tikhomirov@72:  * @author Artem Tikhomirov
tikhomirov@72:  * @author TMate Software Ltd.
tikhomirov@13:  */
tikhomirov@13: public class Manifest {
tikhomirov@13: 
tikhomirov@13: 	public static void main(String[] args) throws Exception {
tikhomirov@74: 		Options cmdLineOpts = Options.parse(args);
tikhomirov@74: 		HgRepository hgRepo = cmdLineOpts.findRepository();
tikhomirov@13: 		if (hgRepo.isInvalid()) {
tikhomirov@13: 			System.err.printf("Can't find repository in: %s\n", hgRepo.getLocation());
tikhomirov@13: 			return;
tikhomirov@13: 		}
tikhomirov@143: 		final boolean debug = cmdLineOpts.getBoolean("--debug");
tikhomirov@143: 		final boolean verbose = cmdLineOpts.getBoolean("-v", "--verbose");
tikhomirov@143: 		HgManifestCommand.Handler h = new HgManifestCommand.Handler() {
tikhomirov@64: 			
tikhomirov@64: 			public void begin(Nodeid manifestRevision) {
tikhomirov@64: 			}
tikhomirov@64: 			public void dir(Path p) {
tikhomirov@64: 			}
tikhomirov@249: 			public void file(HgFileRevision fileRevision) {
tikhomirov@143: 				if (debug) {
tikhomirov@143: 					System.out.print(fileRevision.getRevision());;
tikhomirov@143: 				}
tikhomirov@143: 				if (debug || verbose) {
tikhomirov@143: 					System.out.print(" 644"); // FIXME real flags!
tikhomirov@143: 					System.out.print("   ");
tikhomirov@143: 				}
tikhomirov@64: 				System.out.println(fileRevision.getPath());
tikhomirov@64: 			}
tikhomirov@64: 			
tikhomirov@64: 			public void end(Nodeid manifestRevision) {
tikhomirov@64: 			}
tikhomirov@143: 		};
tikhomirov@143: 		int rev = cmdLineOpts.getSingleInt(TIP, "-r", "--rev");
tikhomirov@143: 		new HgManifestCommand(hgRepo).dirs(false).revision(rev).execute(h); 
tikhomirov@22: 	}
tikhomirov@13: }