Mercurial > jhg
annotate src/com/tmate/hgkit/console/Manifest.java @ 71:ce6d23673f2d
Tests to run from build.xml
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Sun, 23 Jan 2011 03:34:24 +0100 |
parents | 19e9e220bf68 |
children |
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 |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
22
diff
changeset
|
8 import org.tmatesoft.hg.core.Path; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
22
diff
changeset
|
9 import org.tmatesoft.hg.core.RepositoryTreeWalker; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
22
diff
changeset
|
10 import org.tmatesoft.hg.core.LogCommand.FileRevision; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
22
diff
changeset
|
11 |
13
df8c67f3006a
Basic manifest parsing to analyze what's in there
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
12 import com.tmate.hgkit.fs.RepositoryLookup; |
19
40532cdc92fc
Inspector (visitor) for manifest
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
13
diff
changeset
|
13 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
|
14 import com.tmate.hgkit.ll.HgRepository; |
19
40532cdc92fc
Inspector (visitor) for manifest
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
13
diff
changeset
|
15 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
|
16 |
df8c67f3006a
Basic manifest parsing to analyze what's in there
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
17 /** |
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 * @author artem |
df8c67f3006a
Basic manifest parsing to analyze what's in there
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
20 */ |
df8c67f3006a
Basic manifest parsing to analyze what's in there
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
21 public class Manifest { |
df8c67f3006a
Basic manifest parsing to analyze what's in there
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
22 |
df8c67f3006a
Basic manifest parsing to analyze what's in there
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
23 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
|
24 RepositoryLookup repoLookup = new RepositoryLookup(); |
df8c67f3006a
Basic manifest parsing to analyze what's in there
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
25 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
|
26 HgRepository hgRepo = repoLookup.detect(cmdLineOpts); |
df8c67f3006a
Basic manifest parsing to analyze what's in there
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
27 if (hgRepo.isInvalid()) { |
df8c67f3006a
Basic manifest parsing to analyze what's in there
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
28 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
|
29 return; |
df8c67f3006a
Basic manifest parsing to analyze what's in there
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
30 } |
df8c67f3006a
Basic manifest parsing to analyze what's in there
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
31 System.out.println(hgRepo.getLocation()); |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
22
diff
changeset
|
32 hgRepo.getManifest().walk(0, TIP, new Dump()); |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
22
diff
changeset
|
33 // |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
22
diff
changeset
|
34 new RepositoryTreeWalker(hgRepo).dirs(true).walk(new RepositoryTreeWalker.Handler() { |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
22
diff
changeset
|
35 |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
22
diff
changeset
|
36 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
|
37 System.out.println(">> " + manifestRevision); |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
22
diff
changeset
|
38 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
22
diff
changeset
|
39 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
|
40 System.out.println(p); |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
22
diff
changeset
|
41 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
22
diff
changeset
|
42 public void file(FileRevision fileRevision) { |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
22
diff
changeset
|
43 System.out.print(fileRevision.getRevision());; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
22
diff
changeset
|
44 System.out.print(" "); |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
22
diff
changeset
|
45 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
|
46 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
22
diff
changeset
|
47 |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
22
diff
changeset
|
48 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
|
49 System.out.println(); |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
22
diff
changeset
|
50 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
22
diff
changeset
|
51 }); |
13
df8c67f3006a
Basic manifest parsing to analyze what's in there
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
52 } |
22
603806cd2dc6
Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
19
diff
changeset
|
53 |
603806cd2dc6
Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
19
diff
changeset
|
54 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
|
55 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
|
56 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
|
57 return true; |
603806cd2dc6
Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
19
diff
changeset
|
58 } |
603806cd2dc6
Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
19
diff
changeset
|
59 |
603806cd2dc6
Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
19
diff
changeset
|
60 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
|
61 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
|
62 return true; |
603806cd2dc6
Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
19
diff
changeset
|
63 } |
603806cd2dc6
Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
19
diff
changeset
|
64 |
603806cd2dc6
Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
19
diff
changeset
|
65 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
|
66 System.out.println(); |
603806cd2dc6
Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
19
diff
changeset
|
67 return true; |
603806cd2dc6
Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
19
diff
changeset
|
68 } |
603806cd2dc6
Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
19
diff
changeset
|
69 } |
13
df8c67f3006a
Basic manifest parsing to analyze what's in there
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
70 } |