Mercurial > hg4j
comparison test/org/tmatesoft/hg/test/TestByteChannel.java @ 121:b1d6208fb517
Conditionally apply filters to file content
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Fri, 04 Feb 2011 03:37:09 +0100 |
parents | 5d13dcaaff39 |
children | 7567f4a42fe5 |
comparison
equal
deleted
inserted
replaced
120:b19f0ac5ee62 | 121:b1d6208fb517 |
---|---|
31 public class TestByteChannel { | 31 public class TestByteChannel { |
32 | 32 |
33 public static void main(String[] args) throws Exception { | 33 public static void main(String[] args) throws Exception { |
34 RepositoryFacade rf = new RepositoryFacade(); | 34 RepositoryFacade rf = new RepositoryFacade(); |
35 rf.init(); | 35 rf.init(); |
36 HgDataFile file = rf.getRepository().getFileNode("TODO"); | 36 HgDataFile file = rf.getRepository().getFileNode("src/org/tmatesoft/hg/internal/KeywordFilter.java"); |
37 for (int i = file.getRevisionCount() - 1; i >= 0; i--) { | 37 for (int i = file.getRevisionCount() - 1; i >= 0; i--) { |
38 System.out.print("Content for revision:" + i); | 38 System.out.print("Content for revision:" + i); |
39 compareContent(file, i); | 39 compareContent(file, i); |
40 System.out.println(" OK"); | 40 System.out.println(" OK"); |
41 } | 41 } |
43 } | 43 } |
44 | 44 |
45 private static void compareContent(HgDataFile file, int rev) throws Exception { | 45 private static void compareContent(HgDataFile file, int rev) throws Exception { |
46 byte[] oldAccess = file.content(rev); | 46 byte[] oldAccess = file.content(rev); |
47 ByteArrayChannel ch = new ByteArrayChannel(); | 47 ByteArrayChannel ch = new ByteArrayChannel(); |
48 file.content(rev, ch); | 48 file.content(rev, ch, false); |
49 byte[] newAccess = ch.toArray(); | 49 byte[] newAccess = ch.toArray(); |
50 Assert.assertArrayEquals(oldAccess, newAccess); | 50 Assert.assertArrayEquals(oldAccess, newAccess); |
51 // don't trust anyone (even JUnit) | 51 // don't trust anyone (even JUnit) |
52 if (!Arrays.equals(oldAccess, newAccess)) { | 52 if (!Arrays.equals(oldAccess, newAccess)) { |
53 throw new RuntimeException("Failed:" + rev); | 53 throw new RuntimeException("Failed:" + rev); |