comparison src/com/tmate/hgkit/ll/RevlogIndexStreamAccess.java @ 0:dbd663faec1f

Basic changelog parsing
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Fri, 17 Dec 2010 19:05:59 +0100
parents
children d6d2a630f4a6
comparison
equal deleted inserted replaced
-1:000000000000 0:dbd663faec1f
1 /**
2 * Copyright (c) 2010 Artem Tikhomirov
3 */
4 package com.tmate.hgkit.ll;
5
6 import java.io.DataInput;
7 import java.io.IOException;
8
9 /**
10 * @author artem
11 *
12 */
13 public class RevlogIndexStreamAccess {
14
15 private final RevlogStream stream;
16
17 // takes RevlogStream. RevlogStream delegates calls for data to this accessor, which in turn refers back to RevlogStream to get
18 // correct [Input|Data]Stream according to revlog version (Revlogv0 or RevlogNG)
19
20 public RevlogIndexStreamAccess(RevlogStream stream) {
21 this.stream = stream;
22 // TODO Auto-generated constructor stub
23 }
24
25
26 void readRevlogV0Record() throws IOException {
27 DataInput di = stream.getIndexStream();
28 int offset = di.readInt();
29 int compressedLen = di.readInt();
30 int baseRevision = di.readInt();
31 int linkRevision = di.readInt();
32 // int r = (((buf[0] & 0xff) << 24) | ((buf[1] & 0xff) << 16) | ((buf[2] & 0xff) << 8) | (buf[3] & 0xff));
33 byte[] buf = new byte[20];
34 di.readFully(buf, 0, 20);
35 Object nodeidOwn = buf.clone();
36 // XXX nodeid as an Object with hash/equals?
37 di.readFully(buf, 0, 20);
38 Object nodeidParent1 = buf.clone();
39 di.readFully(buf, 0, 20);
40 Object nodeidParent2 = buf.clone();
41 }
42
43 // another subclass?
44 void readRevlogNGRecord() throws IOException {
45 DataInput di = stream.getIndexStream();
46 long l = di.readLong();
47 long offset = l >>> 16;
48 int flags = (int) (l & 0X0FFFF);
49 int compressedLen = di.readInt();
50 int actualLen = di.readInt();
51 int baseRevision = di.readInt();
52 int linkRevision = di.readInt();
53 int parent1Revision = di.readInt();
54 int parent2Revision = di.readInt();
55 byte[] buf = new byte[32];
56 di.readFully(buf, 0, 20+12);
57 Object nodeid = buf/*[0..20]*/;
58
59 }
60 }