comparison src/org/tmatesoft/hg/core/HgFileRevision.java @ 415:ee8264d80747

Explicit constant for regular file flags, access to flags for a given file revision
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Thu, 22 Mar 2012 18:54:11 +0100
parents 0ae53c32ecef
children 9c9c442b5f2e
comparison
equal deleted inserted replaced
414:bb278ccf9866 415:ee8264d80747
15 * contact TMate Software at support@hg4j.com 15 * contact TMate Software at support@hg4j.com
16 */ 16 */
17 package org.tmatesoft.hg.core; 17 package org.tmatesoft.hg.core;
18 18
19 import org.tmatesoft.hg.repo.HgDataFile; 19 import org.tmatesoft.hg.repo.HgDataFile;
20 import org.tmatesoft.hg.repo.HgManifest;
21 import org.tmatesoft.hg.repo.HgManifest.Flags;
20 import org.tmatesoft.hg.repo.HgRepository; 22 import org.tmatesoft.hg.repo.HgRepository;
21 import org.tmatesoft.hg.util.ByteChannel; 23 import org.tmatesoft.hg.util.ByteChannel;
22 import org.tmatesoft.hg.util.CancelledException; 24 import org.tmatesoft.hg.util.CancelledException;
23 import org.tmatesoft.hg.util.Pair; 25 import org.tmatesoft.hg.util.Pair;
24 import org.tmatesoft.hg.util.Path; 26 import org.tmatesoft.hg.util.Path;
34 private final Nodeid revision; 36 private final Nodeid revision;
35 private final Path path; 37 private final Path path;
36 private Path origin; 38 private Path origin;
37 private Boolean isCopy = null; // null means not yet known 39 private Boolean isCopy = null; // null means not yet known
38 private Pair<Nodeid, Nodeid> parents; 40 private Pair<Nodeid, Nodeid> parents;
41 private Flags flags; // null unless set/extracted
39 42
40 public HgFileRevision(HgRepository hgRepo, Nodeid rev, Path p) { 43 /**
44 * FIXME has to be public?
45 *
46 * @param hgRepo repository
47 * @param rev file revision
48 * @param manifestEntryFlags file flags at this revision (optional, may be null)
49 * @param p path of the file at the given revision
50 */
51 public HgFileRevision(HgRepository hgRepo, Nodeid rev, HgManifest.Flags manifestEntryFlags, Path p) {
41 if (hgRepo == null || rev == null || p == null) { 52 if (hgRepo == null || rev == null || p == null) {
42 // since it's package local, it is our code to blame for non validated arguments 53 // since it's package local, it is our code to blame for non validated arguments
43 throw new IllegalArgumentException(); 54 throw new IllegalArgumentException();
44 } 55 }
45 repo = hgRepo; 56 repo = hgRepo;
46 revision = rev; 57 revision = rev;
58 flags = manifestEntryFlags;
47 path = p; 59 path = p;
48 } 60 }
49 61
50 // this cons shall be used when we know whether p was a copy. Perhaps, shall pass Map<Path,Path> instead to stress orig argument is not optional 62 // this cons shall be used when we know whether p was a copy. Perhaps, shall pass Map<Path,Path> instead to stress orig argument is not optional
51 HgFileRevision(HgRepository hgRepo, Nodeid rev, Path p, Path orig) { 63 HgFileRevision(HgRepository hgRepo, Nodeid rev, HgManifest.Flags flags, Path p, Path orig) {
52 this(hgRepo, rev, p); 64 this(hgRepo, rev, flags, p);
53 isCopy = Boolean.valueOf(orig == null); 65 isCopy = Boolean.valueOf(orig == null);
54 origin = orig; 66 origin = orig;
55 } 67 }
56 68
57 public Path getPath() { 69 public Path getPath() {
58 return path; 70 return path;
59 } 71 }
60 72
61 public Nodeid getRevision() { 73 public Nodeid getRevision() {
62 return revision; 74 return revision;
75 }
76
77 /**
78 * Executable or symbolic link, or <code>null</code> if regular file
79 * @throws HgInvalidRevisionException if supplied nodeid doesn't identify any revision from this revlog
80 * @throws HgInvalidControlFileException if access to revlog index/data entry failed
81 */
82 public HgManifest.Flags getFileFlags() throws HgInvalidControlFileException, HgInvalidRevisionException {
83 if (flags == null) {
84 HgDataFile df = repo.getFileNode(path);
85 int revIdx = df.getRevisionIndex(revision);
86 flags = df.getFlags(revIdx);
87 }
88 return flags;
63 } 89 }
64 90
65 public boolean wasCopied() throws HgException { 91 public boolean wasCopied() throws HgException {
66 if (isCopy == null) { 92 if (isCopy == null) {
67 checkCopy(); 93 checkCopy();