annotate cmdline/org/tmatesoft/hg/console/Manifest.java @ 387:cdea37239b01

Issue 23: HgInvalidRevisionException for svn imported repository (changeset 0 references nullid manifest). Tests
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Mon, 13 Feb 2012 15:11:27 +0100
parents 45dc79e545f5
children ee8264d80747
rev   line source
13
df8c67f3006a Basic manifest parsing to analyze what's in there
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
1 /*
72
9a03a80a0f2f Command-line frontend moved to separate source root with new package statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 64
diff changeset
2 * Copyright (c) 2010-2011 TMate Software Ltd
9a03a80a0f2f Command-line frontend moved to separate source root with new package statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 64
diff changeset
3 *
9a03a80a0f2f Command-line frontend moved to separate source root with new package statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 64
diff changeset
4 * This program is free software; you can redistribute it and/or modify
9a03a80a0f2f Command-line frontend moved to separate source root with new package statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 64
diff changeset
5 * it under the terms of the GNU General Public License as published by
9a03a80a0f2f Command-line frontend moved to separate source root with new package statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 64
diff changeset
6 * the Free Software Foundation; version 2 of the License.
9a03a80a0f2f Command-line frontend moved to separate source root with new package statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 64
diff changeset
7 *
9a03a80a0f2f Command-line frontend moved to separate source root with new package statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 64
diff changeset
8 * This program is distributed in the hope that it will be useful,
9a03a80a0f2f Command-line frontend moved to separate source root with new package statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 64
diff changeset
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9a03a80a0f2f Command-line frontend moved to separate source root with new package statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 64
diff changeset
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9a03a80a0f2f Command-line frontend moved to separate source root with new package statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 64
diff changeset
11 * GNU General Public License for more details.
9a03a80a0f2f Command-line frontend moved to separate source root with new package statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 64
diff changeset
12 *
9a03a80a0f2f Command-line frontend moved to separate source root with new package statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 64
diff changeset
13 * For information on how to redistribute this software under
9a03a80a0f2f Command-line frontend moved to separate source root with new package statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 64
diff changeset
14 * the terms of a license other than GNU General Public License
102
a3a2e5deb320 Updated contact address to support@hg4j.com
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 74
diff changeset
15 * contact TMate Software at support@hg4j.com
13
df8c67f3006a Basic manifest parsing to analyze what's in there
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
16 */
72
9a03a80a0f2f Command-line frontend moved to separate source root with new package statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 64
diff changeset
17 package org.tmatesoft.hg.console;
13
df8c67f3006a Basic manifest parsing to analyze what's in there
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
18
299
45dc79e545f5 Recognize flag options (options with no arguments) in command line sample apps
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 249
diff changeset
19 import static org.tmatesoft.hg.console.Options.asSet;
74
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 72
diff changeset
20 import static org.tmatesoft.hg.repo.HgRepository.TIP;
19
40532cdc92fc Inspector (visitor) for manifest
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 13
diff changeset
21
249
4c3b9f679412 Deprecated HgLogCommand.FileRevision gone, top-level HgFileRevision is bright and shiny replacement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 143
diff changeset
22 import org.tmatesoft.hg.core.HgFileRevision;
143
b9700740553a Command line tools parse and respect most of command-line arguments
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
23 import org.tmatesoft.hg.core.HgManifestCommand;
74
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 72
diff changeset
24 import org.tmatesoft.hg.core.Nodeid;
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 72
diff changeset
25 import org.tmatesoft.hg.repo.HgRepository;
133
4a948ec83980 core.Path to util.Path as it's not Hg repo dependant
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 131
diff changeset
26 import org.tmatesoft.hg.util.Path;
64
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 22
diff changeset
27
13
df8c67f3006a Basic manifest parsing to analyze what's in there
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
28
df8c67f3006a Basic manifest parsing to analyze what's in there
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
29 /**
df8c67f3006a Basic manifest parsing to analyze what's in there
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
30 *
72
9a03a80a0f2f Command-line frontend moved to separate source root with new package statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 64
diff changeset
31 * @author Artem Tikhomirov
9a03a80a0f2f Command-line frontend moved to separate source root with new package statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 64
diff changeset
32 * @author TMate Software Ltd.
13
df8c67f3006a Basic manifest parsing to analyze what's in there
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
33 */
df8c67f3006a Basic manifest parsing to analyze what's in there
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
34 public class Manifest {
df8c67f3006a Basic manifest parsing to analyze what's in there
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
35
df8c67f3006a Basic manifest parsing to analyze what's in there
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
36 public static void main(String[] args) throws Exception {
299
45dc79e545f5 Recognize flag options (options with no arguments) in command line sample apps
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 249
diff changeset
37 Options cmdLineOpts = Options.parse(args, asSet("--debug", "-v", "--verbose"));
74
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 72
diff changeset
38 HgRepository hgRepo = cmdLineOpts.findRepository();
13
df8c67f3006a Basic manifest parsing to analyze what's in there
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
39 if (hgRepo.isInvalid()) {
df8c67f3006a Basic manifest parsing to analyze what's in there
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
40 System.err.printf("Can't find repository in: %s\n", hgRepo.getLocation());
df8c67f3006a Basic manifest parsing to analyze what's in there
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
41 return;
df8c67f3006a Basic manifest parsing to analyze what's in there
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
42 }
143
b9700740553a Command line tools parse and respect most of command-line arguments
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
43 final boolean debug = cmdLineOpts.getBoolean("--debug");
b9700740553a Command line tools parse and respect most of command-line arguments
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
44 final boolean verbose = cmdLineOpts.getBoolean("-v", "--verbose");
b9700740553a Command line tools parse and respect most of command-line arguments
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
45 HgManifestCommand.Handler h = new HgManifestCommand.Handler() {
64
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 22
diff changeset
46
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 22
diff changeset
47 public void begin(Nodeid manifestRevision) {
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 22
diff changeset
48 }
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 22
diff changeset
49 public void dir(Path p) {
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 22
diff changeset
50 }
249
4c3b9f679412 Deprecated HgLogCommand.FileRevision gone, top-level HgFileRevision is bright and shiny replacement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 143
diff changeset
51 public void file(HgFileRevision fileRevision) {
143
b9700740553a Command line tools parse and respect most of command-line arguments
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
52 if (debug) {
b9700740553a Command line tools parse and respect most of command-line arguments
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
53 System.out.print(fileRevision.getRevision());;
b9700740553a Command line tools parse and respect most of command-line arguments
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
54 }
b9700740553a Command line tools parse and respect most of command-line arguments
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
55 if (debug || verbose) {
b9700740553a Command line tools parse and respect most of command-line arguments
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
56 System.out.print(" 644"); // FIXME real flags!
b9700740553a Command line tools parse and respect most of command-line arguments
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
57 System.out.print(" ");
b9700740553a Command line tools parse and respect most of command-line arguments
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
58 }
64
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 22
diff changeset
59 System.out.println(fileRevision.getPath());
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 22
diff changeset
60 }
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 22
diff changeset
61
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 22
diff changeset
62 public void end(Nodeid manifestRevision) {
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 22
diff changeset
63 }
143
b9700740553a Command line tools parse and respect most of command-line arguments
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
64 };
b9700740553a Command line tools parse and respect most of command-line arguments
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
65 int rev = cmdLineOpts.getSingleInt(TIP, "-r", "--rev");
b9700740553a Command line tools parse and respect most of command-line arguments
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
66 new HgManifestCommand(hgRepo).dirs(false).revision(rev).execute(h);
22
603806cd2dc6 Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 19
diff changeset
67 }
13
df8c67f3006a Basic manifest parsing to analyze what's in there
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
68 }