Mercurial > hg4j
comparison test/org/tmatesoft/hg/test/TestBlame.java @ 573:e49f9d9513fa
Partial blame when start/end revisions are in the middle of a single filename history
| author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
|---|---|
| date | Fri, 12 Apr 2013 19:50:21 +0200 |
| parents | 36853bb80a35 |
| children | 707b5c7c6fa4 |
comparison
equal
deleted
inserted
replaced
| 572:becd2a1310a2 | 573:e49f9d9513fa |
|---|---|
| 16 */ | 16 */ |
| 17 package org.tmatesoft.hg.test; | 17 package org.tmatesoft.hg.test; |
| 18 | 18 |
| 19 import static org.junit.Assert.assertEquals; | 19 import static org.junit.Assert.assertEquals; |
| 20 import static org.junit.Assert.assertTrue; | 20 import static org.junit.Assert.assertTrue; |
| 21 import static org.tmatesoft.hg.core.HgIterateDirection.NewToOld; | |
| 22 import static org.tmatesoft.hg.core.HgIterateDirection.OldToNew; | |
| 21 import static org.tmatesoft.hg.repo.HgRepository.NO_REVISION; | 23 import static org.tmatesoft.hg.repo.HgRepository.NO_REVISION; |
| 22 import static org.tmatesoft.hg.repo.HgRepository.TIP; | 24 import static org.tmatesoft.hg.repo.HgRepository.TIP; |
| 23 | 25 |
| 24 import java.io.ByteArrayOutputStream; | 26 import java.io.ByteArrayOutputStream; |
| 25 import java.io.File; | 27 import java.io.File; |
| 28 import java.io.IOException; | |
| 29 import java.io.OutputStream; | |
| 26 import java.io.PrintStream; | 30 import java.io.PrintStream; |
| 27 import java.util.ArrayList; | 31 import java.util.ArrayList; |
| 28 import java.util.Arrays; | 32 import java.util.Arrays; |
| 29 import java.util.LinkedHashSet; | 33 import java.util.LinkedHashSet; |
| 30 import java.util.LinkedList; | 34 import java.util.LinkedList; |
| 184 } | 188 } |
| 185 } | 189 } |
| 186 errorCollector.assertTrue(String.format("Annotate API reported excessive diff: %s ", apiResult.toString()), apiResult.isEmpty()); | 190 errorCollector.assertTrue(String.format("Annotate API reported excessive diff: %s ", apiResult.toString()), apiResult.isEmpty()); |
| 187 } | 191 } |
| 188 | 192 |
| 193 | |
| 194 @Test | |
| 195 public void testPartialHistoryFollow() throws Exception { | |
| 196 HgRepository repo = Configuration.get().find("test-annotate2"); | |
| 197 HgDataFile df = repo.getFileNode("file1b.txt"); | |
| 198 // rev3: file1 -> file1a, rev7: file1a -> file1b, tip: rev10 | |
| 199 HgBlameFacility bf = new HgBlameFacility(df); | |
| 200 DiffOutInspector insp = new DiffOutInspector(new PrintStream(new OutputStream() { | |
| 201 @Override | |
| 202 public void write(int b) throws IOException { | |
| 203 // NULL OutputStream | |
| 204 } | |
| 205 })); | |
| 206 // rev6 changes rev4, rev4 changes rev3. Plus, anything changed | |
| 207 // earlier than rev2 shall be reported as new from change3 | |
| 208 int[] change_2_8_new2old = new int[] {4, 6, 3, 4, -1, 3}; | |
| 209 int[] change_2_8_old2new = new int[] {-1, 3, 3, 4, 4, 6 }; | |
| 210 bf.annotate(2, 8, insp, NewToOld); | |
| 211 Assert.assertArrayEquals(change_2_8_new2old, insp.getReportedRevisionPairs()); | |
| 212 insp.reset(); | |
| 213 bf.annotate(2, 8, insp, OldToNew); | |
| 214 Assert.assertArrayEquals(change_2_8_old2new, insp.getReportedRevisionPairs()); | |
| 215 // same as 2 to 8, with addition of rev9 changes rev7 (rev6 to rev7 didn't change content, only name) | |
| 216 int[] change_3_9_new2old = new int[] {7, 9, 4, 6, 3, 4, -1, 3 }; | |
| 217 int[] change_3_9_old2new = new int[] {-1, 3, 3, 4, 4, 6, 7, 9 }; | |
| 218 insp.reset(); | |
| 219 bf.annotate(3, 9, insp, NewToOld); | |
| 220 Assert.assertArrayEquals(change_3_9_new2old, insp.getReportedRevisionPairs()); | |
| 221 insp.reset(); | |
| 222 bf.annotate(3, 9, insp, OldToNew); | |
| 223 Assert.assertArrayEquals(change_3_9_old2new, insp.getReportedRevisionPairs()); | |
| 224 } | |
| 225 | |
| 189 @Test | 226 @Test |
| 190 public void testAnnotateCmdFollowNoFollow() throws Exception { | 227 public void testAnnotateCmdFollowNoFollow() throws Exception { |
| 191 HgRepoFacade hgRepoFacade = new HgRepoFacade(); | 228 HgRepoFacade hgRepoFacade = new HgRepoFacade(); |
| 192 HgRepository repo = Configuration.get().find("test-annotate2"); | 229 HgRepository repo = Configuration.get().find("test-annotate2"); |
| 193 hgRepoFacade.init(repo); | 230 hgRepoFacade.init(repo); |
| 367 x[i++] = v; | 404 x[i++] = v; |
| 368 } | 405 } |
| 369 return x; | 406 return x; |
| 370 } | 407 } |
| 371 | 408 |
| 409 int[] getReportedRevisionPairs() { | |
| 410 return reportedRevisionPairs.toArray(); | |
| 411 } | |
| 412 | |
| 413 void reset() { | |
| 414 reportedRevisionPairs.clear(); | |
| 415 } | |
| 416 | |
| 372 public void same(EqualBlock block) { | 417 public void same(EqualBlock block) { |
| 373 // nothing | 418 // nothing |
| 374 } | 419 } |
| 375 | 420 |
| 376 public void deleted(DeleteBlock block) { | 421 public void deleted(DeleteBlock block) { |
