annotate src/com/tmate/hgkit/console/Manifest.java @ 42:92c3d0920d58

Real integrity check, with exception. DigestHelper refactored to accomodate new needs
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Fri, 14 Jan 2011 04:29:03 +0100
parents 603806cd2dc6
children 19e9e220bf68
rev   line source
13
df8c67f3006a Basic manifest parsing to analyze what's in there
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
1 /*
19
40532cdc92fc Inspector (visitor) for manifest
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 13
diff changeset
2 * Copyright (c) 2010, 2011 Artem Tikhomirov
13
df8c67f3006a Basic manifest parsing to analyze what's in there
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
3 */
df8c67f3006a Basic manifest parsing to analyze what's in there
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
4 package com.tmate.hgkit.console;
df8c67f3006a Basic manifest parsing to analyze what's in there
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
5
19
40532cdc92fc Inspector (visitor) for manifest
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 13
diff changeset
6 import static com.tmate.hgkit.ll.HgRepository.TIP;
40532cdc92fc Inspector (visitor) for manifest
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 13
diff changeset
7
13
df8c67f3006a Basic manifest parsing to analyze what's in there
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
8 import com.tmate.hgkit.fs.RepositoryLookup;
19
40532cdc92fc Inspector (visitor) for manifest
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 13
diff changeset
9 import com.tmate.hgkit.ll.HgManifest;
13
df8c67f3006a Basic manifest parsing to analyze what's in there
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
10 import com.tmate.hgkit.ll.HgRepository;
19
40532cdc92fc Inspector (visitor) for manifest
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 13
diff changeset
11 import com.tmate.hgkit.ll.Nodeid;
13
df8c67f3006a Basic manifest parsing to analyze what's in there
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
12
df8c67f3006a Basic manifest parsing to analyze what's in there
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
13 /**
df8c67f3006a Basic manifest parsing to analyze what's in there
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
14 *
df8c67f3006a Basic manifest parsing to analyze what's in there
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
15 * @author artem
df8c67f3006a Basic manifest parsing to analyze what's in there
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
16 */
df8c67f3006a Basic manifest parsing to analyze what's in there
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
17 public class Manifest {
df8c67f3006a Basic manifest parsing to analyze what's in there
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
18
df8c67f3006a Basic manifest parsing to analyze what's in there
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
19 public static void main(String[] args) throws Exception {
df8c67f3006a Basic manifest parsing to analyze what's in there
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
20 RepositoryLookup repoLookup = new RepositoryLookup();
df8c67f3006a Basic manifest parsing to analyze what's in there
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
21 RepositoryLookup.Options cmdLineOpts = RepositoryLookup.Options.parse(args);
df8c67f3006a Basic manifest parsing to analyze what's in there
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
22 HgRepository hgRepo = repoLookup.detect(cmdLineOpts);
df8c67f3006a Basic manifest parsing to analyze what's in there
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
23 if (hgRepo.isInvalid()) {
df8c67f3006a Basic manifest parsing to analyze what's in there
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
24 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
25 return;
df8c67f3006a Basic manifest parsing to analyze what's in there
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
26 }
df8c67f3006a Basic manifest parsing to analyze what's in there
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
27 System.out.println(hgRepo.getLocation());
22
603806cd2dc6 Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 19
diff changeset
28 HgManifest.Inspector insp = new Dump();
19
40532cdc92fc Inspector (visitor) for manifest
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 13
diff changeset
29 hgRepo.getManifest().walk(0, TIP, insp);
13
df8c67f3006a Basic manifest parsing to analyze what's in there
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
30 }
22
603806cd2dc6 Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 19
diff changeset
31
603806cd2dc6 Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 19
diff changeset
32 public static final class Dump implements HgManifest.Inspector {
603806cd2dc6 Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 19
diff changeset
33 public boolean begin(int revision, Nodeid nid) {
603806cd2dc6 Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 19
diff changeset
34 System.out.printf("%d : %s\n", revision, nid);
603806cd2dc6 Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 19
diff changeset
35 return true;
603806cd2dc6 Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 19
diff changeset
36 }
603806cd2dc6 Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 19
diff changeset
37
603806cd2dc6 Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 19
diff changeset
38 public boolean next(Nodeid nid, String fname, String flags) {
603806cd2dc6 Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 19
diff changeset
39 System.out.println(nid + "\t" + fname + "\t\t" + flags);
603806cd2dc6 Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 19
diff changeset
40 return true;
603806cd2dc6 Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 19
diff changeset
41 }
603806cd2dc6 Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 19
diff changeset
42
603806cd2dc6 Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 19
diff changeset
43 public boolean end(int revision) {
603806cd2dc6 Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 19
diff changeset
44 System.out.println();
603806cd2dc6 Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 19
diff changeset
45 return true;
603806cd2dc6 Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 19
diff changeset
46 }
603806cd2dc6 Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 19
diff changeset
47 }
13
df8c67f3006a Basic manifest parsing to analyze what's in there
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
48 }