Mercurial > jhg
comparison src/org/tmatesoft/hg/repo/HgDataFile.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/HgDataFile.java@576d6e8a09f6 |
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 static org.tmatesoft.hg.repo.HgRepository.TIP; | |
20 | |
21 import org.tmatesoft.hg.core.Nodeid; | |
22 import org.tmatesoft.hg.core.Path; | |
23 | |
24 | |
25 | |
26 /** | |
27 * ? name:HgFileNode? | |
28 * | |
29 * @author Artem Tikhomirov | |
30 * @author TMate Software Ltd. | |
31 */ | |
32 public class HgDataFile extends Revlog { | |
33 | |
34 // absolute from repo root? | |
35 // slashes, unix-style? | |
36 // repo location agnostic, just to give info to user, not to access real storage | |
37 private final Path path; | |
38 | |
39 /*package-local*/HgDataFile(HgRepository hgRepo, Path path, RevlogStream content) { | |
40 super(hgRepo, content); | |
41 this.path = path; | |
42 } | |
43 | |
44 public boolean exists() { | |
45 return content != null; // XXX need better impl | |
46 } | |
47 | |
48 public Path getPath() { | |
49 return path; // hgRepo.backresolve(this) -> name? | |
50 } | |
51 | |
52 public int length(Nodeid nodeid) { | |
53 return content.dataLength(getLocalRevisionNumber(nodeid)); | |
54 } | |
55 | |
56 public byte[] content() { | |
57 return content(TIP); | |
58 } | |
59 | |
60 public void history(Changeset.Inspector inspector) { | |
61 history(0, content.revisionCount() - 1, inspector); | |
62 } | |
63 | |
64 public void history(int start, int end, Changeset.Inspector inspector) { | |
65 if (!exists()) { | |
66 throw new IllegalStateException("Can't get history of invalid repository file node"); | |
67 } | |
68 final int[] commitRevisions = new int[end - start + 1]; | |
69 Revlog.Inspector insp = new Revlog.Inspector() { | |
70 int count = 0; | |
71 | |
72 public void next(int revisionNumber, int actualLen, int baseRevision, int linkRevision, int parent1Revision, int parent2Revision, byte[] nodeid, byte[] data) { | |
73 commitRevisions[count++] = linkRevision; | |
74 } | |
75 }; | |
76 content.iterate(start, end, false, insp); | |
77 getRepo().getChangelog().range(inspector, commitRevisions); | |
78 } | |
79 } |