Mercurial > hg4j
annotate src/com/tmate/hgkit/console/Manifest.java @ 21:e929cecae4e1
Refactor to move revlog content to base class
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Wed, 05 Jan 2011 04:10:28 +0100 |
parents | 40532cdc92fc |
children | 603806cd2dc6 |
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()); |
19
40532cdc92fc
Inspector (visitor) for manifest
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
13
diff
changeset
|
28 HgManifest.Inspector insp = new HgManifest.Inspector() { |
40532cdc92fc
Inspector (visitor) for manifest
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
13
diff
changeset
|
29 public boolean begin(int revision, Nodeid nid) { |
40532cdc92fc
Inspector (visitor) for manifest
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
13
diff
changeset
|
30 System.out.printf("%d : %s\n", revision, nid); |
40532cdc92fc
Inspector (visitor) for manifest
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
13
diff
changeset
|
31 return true; |
40532cdc92fc
Inspector (visitor) for manifest
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
13
diff
changeset
|
32 } |
40532cdc92fc
Inspector (visitor) for manifest
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
13
diff
changeset
|
33 |
40532cdc92fc
Inspector (visitor) for manifest
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
13
diff
changeset
|
34 public boolean next(Nodeid nid, String fname, String flags) { |
40532cdc92fc
Inspector (visitor) for manifest
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
13
diff
changeset
|
35 System.out.println(nid + "\t" + fname + "\t\t" + flags); |
40532cdc92fc
Inspector (visitor) for manifest
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
13
diff
changeset
|
36 return true; |
40532cdc92fc
Inspector (visitor) for manifest
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
13
diff
changeset
|
37 } |
40532cdc92fc
Inspector (visitor) for manifest
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
13
diff
changeset
|
38 |
40532cdc92fc
Inspector (visitor) for manifest
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
13
diff
changeset
|
39 public boolean end(int revision) { |
40532cdc92fc
Inspector (visitor) for manifest
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
13
diff
changeset
|
40 System.out.println(); |
40532cdc92fc
Inspector (visitor) for manifest
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
13
diff
changeset
|
41 return true; |
40532cdc92fc
Inspector (visitor) for manifest
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
13
diff
changeset
|
42 } |
40532cdc92fc
Inspector (visitor) for manifest
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
13
diff
changeset
|
43 }; |
40532cdc92fc
Inspector (visitor) for manifest
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
13
diff
changeset
|
44 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
|
45 } |
df8c67f3006a
Basic manifest parsing to analyze what's in there
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
46 } |