annotate test/org/tmatesoft/hg/test/TestFileRenameUtils.java @ 713:661e77dc88ba tip

Mac support: respect Mac alternatives of command-line arguments for common unix tools
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Sun, 03 Aug 2014 18:09:00 +0200
parents 72fc7774b87e
children
rev   line source
691
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
1 /*
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
2 * Copyright (c) 2013 TMate Software Ltd
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
3 *
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
4 * This program is free software; you can redistribute it and/or modify
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
5 * it under the terms of the GNU General Public License as published by
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
6 * the Free Software Foundation; version 2 of the License.
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
7 *
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
8 * This program is distributed in the hope that it will be useful,
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
11 * GNU General Public License for more details.
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
12 *
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
13 * For information on how to redistribute this software under
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
14 * the terms of a license other than GNU General Public License
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
15 * contact TMate Software at support@hg4j.com
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
16 */
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
17 package org.tmatesoft.hg.test;
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
18
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
19 import static org.tmatesoft.hg.core.HgIterateDirection.NewToOld;
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
20 import static org.tmatesoft.hg.core.HgIterateDirection.OldToNew;
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
21
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
22 import org.junit.Assert;
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
23 import org.junit.Rule;
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
24 import org.junit.Test;
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
25 import org.tmatesoft.hg.core.HgChangesetFileSneaker;
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
26 import org.tmatesoft.hg.core.HgException;
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
27 import org.tmatesoft.hg.core.HgIterateDirection;
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
28 import org.tmatesoft.hg.internal.FileRenameHistory;
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
29 import org.tmatesoft.hg.internal.FileRenameHistory.Chunk;
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
30 import org.tmatesoft.hg.repo.HgDataFile;
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
31 import org.tmatesoft.hg.repo.HgRepository;
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
32
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
33 /**
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
34 * TODO add tests for {@link HgChangesetFileSneaker}
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
35 * @author Artem Tikhomirov
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
36 * @author TMate Software Ltd.
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
37 */
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
38 public class TestFileRenameUtils {
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
39
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
40
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
41 @Rule
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
42 public ErrorCollectorExt errorCollector = new ErrorCollectorExt();
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
43
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
44 @Test
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
45 public void testFileRenameHistory() throws HgException {
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
46 HgRepository repo = Configuration.get().find("log-renames");
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
47 // history of files from their TIP perspective
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
48 // series of (fname, fileRefStart, fileRevEnd, csetStart, csetEnd), new to old
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
49 Object[] historyA = new Object[] {"a", 2, 2, 5, 5, "c", 0, 1, 2, 4, "b", 0, 1, 0, 1};
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
50 Object[] historyB = new Object[] {"b", 2, 3, 3, 4, "a", 0, 1, 0, 2 };
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
51 Object[] historyC = new Object[] {"c", 0, 1, 2, 4, "b", 0, 1, 0, 1 };
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
52 Object[] historyD = new Object[] {"d", 1, 1, 5, 5, "b", 2, 3, 3, 4, "a", 0, 1, 0, 2};
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
53
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
54 FileRenameHistory frh = new FileRenameHistory(0, 5);
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
55 for (Object[] history : new Object[][] {historyA, historyB, historyC, historyD}) {
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
56 String fname = history[0].toString();
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
57 HgDataFile df = repo.getFileNode(fname);
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
58 Assert.assertFalse(frh.isOutOfRange(df, df.getLastRevision()));
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
59 frh.build(df, df.getLastRevision());
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
60 int recordIndex = 0;
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
61 errorCollector.assertEquals(history.length / 5, frh.chunks());
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
62 for (Chunk c : frh.iterate(HgIterateDirection.NewToOld)) {
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
63 compareChunk(fname, c, history, recordIndex++);
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
64 }
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
65 errorCollector.assertEquals("Shall compare full history", history.length, recordIndex * 5);
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
66 }
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
67 //
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
68 HgDataFile df = repo.getFileNode("d");
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
69 Assert.assertFalse(frh.isOutOfRange(df, 0));
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
70 frh.build(df, 0);
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
71 errorCollector.assertEquals(1, frh.chunks());
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
72 Chunk c = frh.iterate(NewToOld).iterator().next();
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
73 compareChunk("abandoned d(0)", c, new Object[] { "d", 0, 0, 4, 4 }, 0);
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
74 //
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
75 df = repo.getFileNode("a");
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
76 Assert.assertFalse(frh.isOutOfRange(df, 0));
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
77 frh.build(df, 0);
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
78 errorCollector.assertEquals(1, frh.chunks());
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
79 c = frh.iterate(NewToOld).iterator().next();
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
80 compareChunk("a(0) and boundary checks", c, new Object[] { "a", 0, 0, 0, 0 }, 0);
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
81 //
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
82 repo = Configuration.get().find("test-annotate"); // need a long file history
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
83 df = repo.getFileNode("file1");
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
84 Assert.assertTrue("[sanity]", repo.getChangelog().getLastRevision() >=9);
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
85 Assert.assertTrue("[sanity]", df.exists() && df.getLastRevision() >= 9);
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
86 frh = new FileRenameHistory(0, 9);
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
87 frh.build(df, 9);
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
88 errorCollector.assertEquals(1, frh.chunks());
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
89 c = frh.iterate(NewToOld).iterator().next();
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
90 compareChunk("regular file, no renames", c, new Object[] { "file1", 0, 9, 0, 9 }, 0);
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
91 // restricted range
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
92 frh = new FileRenameHistory(3, 6);
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
93 Assert.assertFalse(frh.isOutOfRange(df, 9));
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
94 frh.build(df, 9); // start from out of range revision
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
95 errorCollector.assertEquals(1, frh.chunks());
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
96 c = frh.iterate(OldToNew).iterator().next();
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
97 compareChunk("regular file, no renames, in range 3..6", c, new Object[] { "file1", 3, 6, 3, 6 }, 0);
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
98 }
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
99
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
100 private void compareChunk(String msg, Chunk chunk, Object[] expected, int recordOffset) {
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
101 int off = recordOffset * 5;
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
102 errorCollector.assertEquals(msg, expected[off], chunk.file().getPath().toString());
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
103 errorCollector.assertEquals(msg, expected[off+1], chunk.firstFileRev());
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
104 errorCollector.assertEquals(msg, expected[off+2], chunk.lastFileRev());
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
105 errorCollector.assertEquals(msg, expected[off+3], chunk.firstCset());
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
106 errorCollector.assertEquals(msg, expected[off+4], chunk.lastCset());
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
107 }
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
108
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
109 }