Mercurial > jhg
comparison src/org/tmatesoft/hg/repo/HgDataFile.java @ 88:61eedab3eb3e
Status between two revisions to recognize copy/rename
| author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
|---|---|
| date | Wed, 26 Jan 2011 05:46:47 +0100 |
| parents | 5f9635c01681 |
| children | a3a2e5deb320 |
comparison
equal
deleted
inserted
replaced
| 87:25f2e5d1cd8b | 88:61eedab3eb3e |
|---|---|
| 55 public Path getPath() { | 55 public Path getPath() { |
| 56 return path; // hgRepo.backresolve(this) -> name? | 56 return path; // hgRepo.backresolve(this) -> name? |
| 57 } | 57 } |
| 58 | 58 |
| 59 public int length(Nodeid nodeid) { | 59 public int length(Nodeid nodeid) { |
| 60 return content.dataLength(getLocalRevisionNumber(nodeid)); | 60 return content.dataLength(getLocalRevision(nodeid)); |
| 61 } | 61 } |
| 62 | 62 |
| 63 public byte[] content() { | 63 public byte[] content() { |
| 64 return content(TIP); | 64 return content(TIP); |
| 65 } | 65 } |
| 145 } | 145 } |
| 146 }; | 146 }; |
| 147 content.iterate(start, end, false, insp); | 147 content.iterate(start, end, false, insp); |
| 148 getRepo().getChangelog().range(inspector, commitRevisions); | 148 getRepo().getChangelog().range(inspector, commitRevisions); |
| 149 } | 149 } |
| 150 | |
| 151 // for a given local revision of the file, find out local revision in the changelog | |
| 152 public int getChangesetLocalRevision(int revision) { | |
| 153 return content.linkRevision(revision); | |
| 154 } | |
| 155 | |
| 156 public Nodeid getChangesetRevision(Nodeid nid) { | |
| 157 int changelogRevision = getChangesetLocalRevision(getLocalRevision(nid)); | |
| 158 return getRepo().getChangelog().getRevision(changelogRevision); | |
| 159 } | |
| 150 | 160 |
| 151 public boolean isCopy() { | 161 public boolean isCopy() { |
| 152 if (metadata == null) { | 162 if (metadata == null) { |
| 153 content(0); // FIXME expensive way to find out metadata, distinct RevlogStream.Iterator would be better. | 163 content(0); // FIXME expensive way to find out metadata, distinct RevlogStream.Iterator would be better. |
| 154 } | 164 } |
| 169 if (isCopy()) { | 179 if (isCopy()) { |
| 170 return Nodeid.fromAscii(metadata.find(0, "copyrev")); // XXX reuse/cache Nodeid | 180 return Nodeid.fromAscii(metadata.find(0, "copyrev")); // XXX reuse/cache Nodeid |
| 171 } | 181 } |
| 172 throw new UnsupportedOperationException(); | 182 throw new UnsupportedOperationException(); |
| 173 } | 183 } |
| 174 | 184 |
| 175 public static final class MetadataEntry { | 185 @Override |
| 186 public String toString() { | |
| 187 StringBuilder sb = new StringBuilder(getClass().getSimpleName()); | |
| 188 sb.append('('); | |
| 189 sb.append(getPath()); | |
| 190 sb.append(')'); | |
| 191 return sb.toString(); | |
| 192 } | |
| 193 | |
| 194 private static final class MetadataEntry { | |
| 176 private final String entry; | 195 private final String entry; |
| 177 private final int valueStart; | 196 private final int valueStart; |
| 178 /*package-local*/MetadataEntry(String key, String value) { | 197 /*package-local*/MetadataEntry(String key, String value) { |
| 179 entry = key + value; | 198 entry = key + value; |
| 180 valueStart = key.length(); | 199 valueStart = key.length(); |
