Mercurial > jhg
comparison src/org/tmatesoft/hg/internal/PatchGenerator.java @ 549:83afa680555d
Annotate merge revision (combined diff against two parents without looking further)
| author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
|---|---|
| date | Tue, 19 Feb 2013 21:17:39 +0100 |
| parents | 15b406c7cd9d |
| children |
comparison
equal
deleted
inserted
replaced
| 548:ab21ac7dd833 | 549:83afa680555d |
|---|---|
| 19 import java.util.ArrayList; | 19 import java.util.ArrayList; |
| 20 import java.util.HashMap; | 20 import java.util.HashMap; |
| 21 import java.util.Map; | 21 import java.util.Map; |
| 22 | 22 |
| 23 import org.tmatesoft.hg.repo.HgDataFile; | 23 import org.tmatesoft.hg.repo.HgDataFile; |
| 24 import org.tmatesoft.hg.repo.HgInvalidStateException; | |
| 24 import org.tmatesoft.hg.repo.HgLookup; | 25 import org.tmatesoft.hg.repo.HgLookup; |
| 25 import org.tmatesoft.hg.repo.HgRepository; | 26 import org.tmatesoft.hg.repo.HgRepository; |
| 26 | 27 |
| 27 /** | 28 /** |
| 28 * Mercurial cares about changes only up to the line level, e.g. a simple file version dump in manifest looks like (RevlogDump output): | 29 * Mercurial cares about changes only up to the line level, e.g. a simple file version dump in manifest looks like (RevlogDump output): |
| 53 public void init(T s1, T s2) { | 54 public void init(T s1, T s2) { |
| 54 seq1 = s1; | 55 seq1 = s1; |
| 55 seq2 = s2; | 56 seq2 = s2; |
| 56 prepare(s2); | 57 prepare(s2); |
| 57 } | 58 } |
| 59 | |
| 60 public void init(T s1) { | |
| 61 if (seq2 == null) { | |
| 62 throw new IllegalStateException("Use this #init() only when target sequence shall be matched against different origin"); | |
| 63 } | |
| 64 seq1 = s1; | |
| 65 } | |
| 58 | 66 |
| 59 | 67 |
| 60 private void prepare(T s2) { | 68 private void prepare(T s2) { |
| 61 chunk2UseIndex = new HashMap<Chunk, IntVector>(); | 69 chunk2UseIndex = new HashMap<Chunk, IntVector>(); |
| 62 for (int i = 0, len = s2.chunkCount(); i < len; i++) { | 70 for (int i = 0, len = s2.chunkCount(); i < len; i++) { |
| 198 assert changeStartS1 == matchStartSeq1; | 206 assert changeStartS1 == matchStartSeq1; |
| 199 if(changeStartS2 < matchStartSeq2) { | 207 if(changeStartS2 < matchStartSeq2) { |
| 200 added(changeStartS1, changeStartS2, matchStartSeq2); | 208 added(changeStartS1, changeStartS2, matchStartSeq2); |
| 201 } else { | 209 } else { |
| 202 assert changeStartS2 == matchStartSeq2; | 210 assert changeStartS2 == matchStartSeq2; |
| 203 System.out.printf("adjustent equal blocks %d, %d and %d,%d\n", changeStartS1, matchStartSeq1, changeStartS2, matchStartSeq2); | 211 if (matchStartSeq1 > 0 || matchStartSeq2 > 0) { |
| 212 // FIXME perhaps, exception is too much for the case | |
| 213 // once diff is covered with tests, replace with assert false : msg; | |
| 214 throw new HgInvalidStateException(String.format("adjustent equal blocks %d, %d and %d,%d", changeStartS1, matchStartSeq1, changeStartS2, matchStartSeq2)); | |
| 215 } | |
| 204 } | 216 } |
| 205 } | 217 } |
| 206 if (matchLength > 0) { | 218 if (matchLength > 0) { |
| 207 unchanged(matchStartSeq1, matchStartSeq2, matchLength); | 219 unchanged(matchStartSeq1, matchStartSeq2, matchLength); |
| 208 } | 220 } |
