tikhomirov@2: /** tikhomirov@2: * Copyright (c) 2010 Artem Tikhomirov tikhomirov@2: */ tikhomirov@2: package com.tmate.hgkit.ll; tikhomirov@2: tikhomirov@2: /** tikhomirov@2: * Extends Revlog/uses RevlogStream? tikhomirov@2: * ? name:HgFileNode? tikhomirov@2: * @author artem tikhomirov@2: */ tikhomirov@2: public class HgDataFile extends Revlog { tikhomirov@2: tikhomirov@3: private final RevlogStream content; // XXX move up to Revlog? tikhomirov@3: tikhomirov@3: // absolute from repo root? tikhomirov@3: // slashes, unix-style? tikhomirov@3: // repo location agnostic, just to give info to user, not to access real storage tikhomirov@2: private final String path; tikhomirov@2: tikhomirov@3: /*package-local*/HgDataFile(HgRepository hgRepo, String path, RevlogStream content) { tikhomirov@2: super(hgRepo); tikhomirov@3: this.path = path; tikhomirov@3: this.content = content; tikhomirov@3: } tikhomirov@3: tikhomirov@3: public boolean exists() { tikhomirov@3: return content != null; // XXX need better impl tikhomirov@2: } tikhomirov@2: tikhomirov@2: public String getPath() { tikhomirov@2: return path; // hgRepo.backresolve(this) -> name? tikhomirov@2: } tikhomirov@2: tikhomirov@2: private static final int TIP = -2; tikhomirov@2: tikhomirov@2: public byte[] content() { tikhomirov@2: return content(TIP); tikhomirov@2: } tikhomirov@2: tikhomirov@2: public byte[] content(int revision) { tikhomirov@2: throw HgRepository.notImplemented(); tikhomirov@2: } tikhomirov@3: tikhomirov@3: public void history(Changeset.Inspector inspector) { tikhomirov@3: if (!exists()) { tikhomirov@3: throw new IllegalStateException("Can't get history of invalid repository file node"); tikhomirov@3: } tikhomirov@3: final int[] commitRevisions = new int[content.revisionCount()]; tikhomirov@3: Revlog.Inspector insp = new Revlog.Inspector() { tikhomirov@3: int count = 0; tikhomirov@3: tikhomirov@3: public void next(int revisionNumber, int actualLen, int baseRevision, int linkRevision, int parent1Revision, int parent2Revision, byte[] nodeid, byte[] data) { tikhomirov@3: commitRevisions[count++] = linkRevision; tikhomirov@3: } tikhomirov@3: }; tikhomirov@3: content.iterate(0, -1, false, insp); tikhomirov@3: getRepo().getChangelog().range(inspector, commitRevisions); tikhomirov@3: } tikhomirov@3: tikhomirov@3: public void history(int start, int end, Changeset.Inspector i) { tikhomirov@3: throw HgRepository.notImplemented(); tikhomirov@3: } tikhomirov@2: }