comparison src/com/tmate/hgkit/ll/HgManifest.java @ 13:df8c67f3006a

Basic manifest parsing to analyze what's in there
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Sun, 26 Dec 2010 03:21:17 +0100
parents 08db726a0fb7
children 254078595653
comparison
equal deleted inserted replaced
12:181fccc176ef 13:df8c67f3006a
1 /** 1 /*
2 * Copyright (c) 2010 Artem Tikhomirov 2 * Copyright (c) 2010 Artem Tikhomirov
3 */ 3 */
4 package com.tmate.hgkit.ll; 4 package com.tmate.hgkit.ll;
5 5
6 /** 6 /**
7 * 7 *
8 * @author artem 8 * @author artem
9 */ 9 */
10 public class HgManifest extends Revlog { 10 public class HgManifest extends Revlog {
11 11
12 /*package-local*/ HgManifest(HgRepository hgRepo) { 12 private final RevlogStream content;
13
14 /*package-local*/ HgManifest(HgRepository hgRepo, RevlogStream content) {
13 super(hgRepo); 15 super(hgRepo);
16 this.content = content;
17 }
18
19 public void dump() {
20 Revlog.Inspector insp = new Revlog.Inspector() {
21 public void next(int revisionNumber, int actualLen, int baseRevision, int linkRevision, int parent1Revision, int parent2Revision, byte[] nodeid, byte[] data) {
22 System.out.println(revisionNumber);
23 int i;
24 String fname = null;
25 String flags = null;
26 Nodeid nid = null;
27 for (i = 0; i < actualLen; i++) {
28 int x = i;
29 for( ; data[i] != '\n' && i < actualLen; i++) {
30 if (fname == null && data[i] == 0) {
31 fname = new String(data, x, i - x);
32 x = i+1;
33 }
34 }
35 if (i < actualLen) {
36 assert data[i] == '\n';
37 int nodeidLen = i - x < 40 ? i-x : 40;
38 nid = Nodeid.fromAscii(data, x, nodeidLen);
39 if (nodeidLen + x < i) {
40 // 'x' and 'l' for executable bits and symlinks?
41 // hg --debug manifest shows 644 for each regular file in my repo
42 flags = new String(data, x + nodeidLen, i-x-nodeidLen);
43 }
44 System.out.println(nid + "\t" + fname + "\t\t" + flags);
45 }
46 nid = null;
47 fname = flags = null;
48 }
49 System.out.println();
50 }
51 };
52 content.iterate(0, -1, true, insp);
14 } 53 }
15 } 54 }