Mercurial > hg4j
comparison src/org/tmatesoft/hg/internal/RevlogStreamWriter.java @ 708:4ffc17c0b534
Merge: tests for resolver and complex scenario. Enable commit for merged revisions. Reuse file revisions if nothing changed
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Tue, 20 Aug 2013 18:41:34 +0200 |
parents | 545b1d4cc11d |
children |
comparison
equal
deleted
inserted
replaced
707:42b88709e41d | 708:4ffc17c0b534 |
---|---|
142 public Pair<Integer,Nodeid> addRevision(DataSource content, int linkRevision, int p1, int p2) throws HgIOException, HgRuntimeException { | 142 public Pair<Integer,Nodeid> addRevision(DataSource content, int linkRevision, int p1, int p2) throws HgIOException, HgRuntimeException { |
143 populateLastEntryIndex(); | 143 populateLastEntryIndex(); |
144 populateLastEntryContent(); | 144 populateLastEntryContent(); |
145 // | 145 // |
146 byte[] contentByteArray = toByteArray(content); | 146 byte[] contentByteArray = toByteArray(content); |
147 Patch patch = GeneratePatchInspector.delta(lastFullContent.second(), contentByteArray); | |
148 int patchSerializedLength = patch.serializedLength(); | |
149 | |
150 final boolean writeComplete = preferCompleteOverPatch(patchSerializedLength, contentByteArray.length); | |
151 DataSerializer.DataSource dataSource = writeComplete ? new ByteArrayDataSource(contentByteArray) : patch.new PatchDataSource(); | |
152 // | |
153 Nodeid p1Rev = revision(p1); | 147 Nodeid p1Rev = revision(p1); |
154 Nodeid p2Rev = revision(p2); | 148 Nodeid p2Rev = revision(p2); |
155 Nodeid newRev = Nodeid.fromBinary(dh.sha1(p1Rev, p2Rev, contentByteArray).asBinary(), 0); | 149 Nodeid newRev = Nodeid.fromBinary(dh.sha1(p1Rev, p2Rev, contentByteArray).asBinary(), 0); |
150 if (newRev.equals(p1Rev)) { // shall never happen, same content but different parents give new SHA. Doesn't hurt to check, though | |
151 assert p2Rev.isNull(); | |
152 return new Pair<Integer, Nodeid>(p1, p1Rev); | |
153 } | |
154 // | |
155 Patch patch = GeneratePatchInspector.delta(lastFullContent.second(), contentByteArray); | |
156 int patchSerializedLength = patch.serializedLength(); | |
157 final boolean writeComplete = preferCompleteOverPatch(patchSerializedLength, contentByteArray.length); | |
158 DataSerializer.DataSource dataSource = writeComplete ? new ByteArrayDataSource(contentByteArray) : patch.new PatchDataSource(); | |
159 // | |
156 doAdd(newRev, p1, p2, linkRevision, writeComplete ? lastEntryIndex+1 : lastEntryBase, contentByteArray.length, dataSource); | 160 doAdd(newRev, p1, p2, linkRevision, writeComplete ? lastEntryIndex+1 : lastEntryBase, contentByteArray.length, dataSource); |
157 lastFullContent = new Pair<Integer, byte[]>(lastEntryIndex, contentByteArray); | 161 lastFullContent = new Pair<Integer, byte[]>(lastEntryIndex, contentByteArray); |
158 return new Pair<Integer, Nodeid>(lastEntryIndex, lastEntryRevision); | 162 return new Pair<Integer, Nodeid>(lastEntryIndex, lastEntryRevision); |
159 } | 163 } |
160 | 164 |