comparison src/org/tmatesoft/hg/repo/HgManifest.java @ 74:6f1b88693d48

Complete refactoring to org.tmatesoft
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Mon, 24 Jan 2011 03:14:45 +0100
parents src/com/tmate/hgkit/ll/HgManifest.java@b2251b7a9823
children c677e1593919
comparison
equal deleted inserted replaced
73:0d279bcc4442 74:6f1b88693d48
1 /*
2 * Copyright (c) 2010-2011 TMate Software Ltd
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 2 of the License.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * For information on how to redistribute this software under
14 * the terms of a license other than GNU General Public License
15 * contact TMate Software at support@svnkit.com
16 */
17 package org.tmatesoft.hg.repo;
18
19 import org.tmatesoft.hg.core.Nodeid;
20
21
22 /**
23 *
24 * @author Artem Tikhomirov
25 * @author TMate Software Ltd.
26 */
27 public class HgManifest extends Revlog {
28
29 /*package-local*/ HgManifest(HgRepository hgRepo, RevlogStream content) {
30 super(hgRepo, content);
31 }
32
33 public void walk(int start, int end, final Inspector inspector) {
34 Revlog.Inspector insp = new Revlog.Inspector() {
35
36 private boolean gtg = true; // good to go
37
38 public void next(int revisionNumber, int actualLen, int baseRevision, int linkRevision, int parent1Revision, int parent2Revision, byte[] nodeid, byte[] data) {
39 if (!gtg) {
40 return;
41 }
42 gtg = gtg && inspector.begin(revisionNumber, new Nodeid(nodeid, true));
43 int i;
44 String fname = null;
45 String flags = null;
46 Nodeid nid = null;
47 for (i = 0; gtg && i < actualLen; i++) {
48 int x = i;
49 for( ; data[i] != '\n' && i < actualLen; i++) {
50 if (fname == null && data[i] == 0) {
51 fname = new String(data, x, i - x);
52 x = i+1;
53 }
54 }
55 if (i < actualLen) {
56 assert data[i] == '\n';
57 int nodeidLen = i - x < 40 ? i-x : 40;
58 nid = Nodeid.fromAscii(data, x, nodeidLen);
59 if (nodeidLen + x < i) {
60 // 'x' and 'l' for executable bits and symlinks?
61 // hg --debug manifest shows 644 for each regular file in my repo
62 flags = new String(data, x + nodeidLen, i-x-nodeidLen);
63 }
64 gtg = gtg && inspector.next(nid, fname, flags);
65 }
66 nid = null;
67 fname = flags = null;
68 }
69 gtg = gtg && inspector.end(revisionNumber);
70 }
71 };
72 content.iterate(start, end, true, insp);
73 }
74
75 public interface Inspector {
76 boolean begin(int revision, Nodeid nid);
77 boolean next(Nodeid nid, String fname, String flags);
78 boolean end(int revision);
79 }
80 }