annotate test/org/tmatesoft/hg/test/TestCheckout.java @ 563:ca56a36c2eea

HgCheckoutCommand: clean parameter, discard changes in WD, test for clean checkout
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Thu, 28 Feb 2013 16:34:33 +0100
parents 2813a26b8999
children bd5926e24aa3
rev   line source
526
2f9ed6bcefa2 Initial support for Revert command with accompanying minor refactoring
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
1 /*
2f9ed6bcefa2 Initial support for Revert command with accompanying minor refactoring
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
2 * Copyright (c) 2013 TMate Software Ltd
2f9ed6bcefa2 Initial support for Revert command with accompanying minor refactoring
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
3 *
2f9ed6bcefa2 Initial support for Revert command with accompanying minor refactoring
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
4 * This program is free software; you can redistribute it and/or modify
2f9ed6bcefa2 Initial support for Revert command with accompanying minor refactoring
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
5 * it under the terms of the GNU General Public License as published by
2f9ed6bcefa2 Initial support for Revert command with accompanying minor refactoring
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
6 * the Free Software Foundation; version 2 of the License.
2f9ed6bcefa2 Initial support for Revert command with accompanying minor refactoring
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
7 *
2f9ed6bcefa2 Initial support for Revert command with accompanying minor refactoring
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
8 * This program is distributed in the hope that it will be useful,
2f9ed6bcefa2 Initial support for Revert command with accompanying minor refactoring
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
2f9ed6bcefa2 Initial support for Revert command with accompanying minor refactoring
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2f9ed6bcefa2 Initial support for Revert command with accompanying minor refactoring
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
11 * GNU General Public License for more details.
2f9ed6bcefa2 Initial support for Revert command with accompanying minor refactoring
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
12 *
2f9ed6bcefa2 Initial support for Revert command with accompanying minor refactoring
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
13 * For information on how to redistribute this software under
2f9ed6bcefa2 Initial support for Revert command with accompanying minor refactoring
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
14 * the terms of a license other than GNU General Public License
2f9ed6bcefa2 Initial support for Revert command with accompanying minor refactoring
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
15 * contact TMate Software at support@hg4j.com
2f9ed6bcefa2 Initial support for Revert command with accompanying minor refactoring
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
16 */
2f9ed6bcefa2 Initial support for Revert command with accompanying minor refactoring
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
17 package org.tmatesoft.hg.test;
2f9ed6bcefa2 Initial support for Revert command with accompanying minor refactoring
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
18
527
47b7bedf0569 Tests for present HgCheckoutCommand functionality. Update branch information on checkout. Use UTF8 encoding for the branch file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 526
diff changeset
19 import static org.junit.Assert.assertEquals;
563
ca56a36c2eea HgCheckoutCommand: clean parameter, discard changes in WD, test for clean checkout
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 536
diff changeset
20 import static org.junit.Assert.assertTrue;
ca56a36c2eea HgCheckoutCommand: clean parameter, discard changes in WD, test for clean checkout
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 536
diff changeset
21 import static org.tmatesoft.hg.repo.HgRepository.TIP;
536
2813a26b8999 Tests: refactor various utility methods to a single location
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 527
diff changeset
22 import static org.tmatesoft.hg.test.RepoUtils.cloneRepoToTempLocation;
527
47b7bedf0569 Tests for present HgCheckoutCommand functionality. Update branch information on checkout. Use UTF8 encoding for the branch file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 526
diff changeset
23
47b7bedf0569 Tests for present HgCheckoutCommand functionality. Update branch information on checkout. Use UTF8 encoding for the branch file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 526
diff changeset
24 import java.io.File;
47b7bedf0569 Tests for present HgCheckoutCommand functionality. Update branch information on checkout. Use UTF8 encoding for the branch file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 526
diff changeset
25 import java.io.FileFilter;
47b7bedf0569 Tests for present HgCheckoutCommand functionality. Update branch information on checkout. Use UTF8 encoding for the branch file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 526
diff changeset
26
47b7bedf0569 Tests for present HgCheckoutCommand functionality. Update branch information on checkout. Use UTF8 encoding for the branch file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 526
diff changeset
27 import org.junit.Rule;
526
2f9ed6bcefa2 Initial support for Revert command with accompanying minor refactoring
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
28 import org.junit.Test;
527
47b7bedf0569 Tests for present HgCheckoutCommand functionality. Update branch information on checkout. Use UTF8 encoding for the branch file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 526
diff changeset
29 import org.tmatesoft.hg.core.HgCheckoutCommand;
47b7bedf0569 Tests for present HgCheckoutCommand functionality. Update branch information on checkout. Use UTF8 encoding for the branch file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 526
diff changeset
30 import org.tmatesoft.hg.core.Nodeid;
47b7bedf0569 Tests for present HgCheckoutCommand functionality. Update branch information on checkout. Use UTF8 encoding for the branch file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 526
diff changeset
31 import org.tmatesoft.hg.repo.HgLookup;
47b7bedf0569 Tests for present HgCheckoutCommand functionality. Update branch information on checkout. Use UTF8 encoding for the branch file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 526
diff changeset
32 import org.tmatesoft.hg.repo.HgRepository;
47b7bedf0569 Tests for present HgCheckoutCommand functionality. Update branch information on checkout. Use UTF8 encoding for the branch file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 526
diff changeset
33 import org.tmatesoft.hg.util.Pair;
47b7bedf0569 Tests for present HgCheckoutCommand functionality. Update branch information on checkout. Use UTF8 encoding for the branch file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 526
diff changeset
34 import org.tmatesoft.hg.util.Path;
526
2f9ed6bcefa2 Initial support for Revert command with accompanying minor refactoring
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
35
2f9ed6bcefa2 Initial support for Revert command with accompanying minor refactoring
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
36 /**
2f9ed6bcefa2 Initial support for Revert command with accompanying minor refactoring
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
37 *
2f9ed6bcefa2 Initial support for Revert command with accompanying minor refactoring
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
38 * @author Artem Tikhomirov
2f9ed6bcefa2 Initial support for Revert command with accompanying minor refactoring
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
39 * @author TMate Software Ltd.
2f9ed6bcefa2 Initial support for Revert command with accompanying minor refactoring
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
40 */
2f9ed6bcefa2 Initial support for Revert command with accompanying minor refactoring
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
41 public class TestCheckout {
2f9ed6bcefa2 Initial support for Revert command with accompanying minor refactoring
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
42
527
47b7bedf0569 Tests for present HgCheckoutCommand functionality. Update branch information on checkout. Use UTF8 encoding for the branch file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 526
diff changeset
43 @Rule
47b7bedf0569 Tests for present HgCheckoutCommand functionality. Update branch information on checkout. Use UTF8 encoding for the branch file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 526
diff changeset
44 public ErrorCollectorExt errorCollector = new ErrorCollectorExt();
47b7bedf0569 Tests for present HgCheckoutCommand functionality. Update branch information on checkout. Use UTF8 encoding for the branch file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 526
diff changeset
45
47b7bedf0569 Tests for present HgCheckoutCommand functionality. Update branch information on checkout. Use UTF8 encoding for the branch file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 526
diff changeset
46 private HgRepository repo;
47b7bedf0569 Tests for present HgCheckoutCommand functionality. Update branch information on checkout. Use UTF8 encoding for the branch file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 526
diff changeset
47 private ExecHelper eh;
47b7bedf0569 Tests for present HgCheckoutCommand functionality. Update branch information on checkout. Use UTF8 encoding for the branch file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 526
diff changeset
48
526
2f9ed6bcefa2 Initial support for Revert command with accompanying minor refactoring
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
49
2f9ed6bcefa2 Initial support for Revert command with accompanying minor refactoring
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
50 @Test
527
47b7bedf0569 Tests for present HgCheckoutCommand functionality. Update branch information on checkout. Use UTF8 encoding for the branch file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 526
diff changeset
51 public void testCleanCheckoutInEmptyDir() throws Exception {
563
ca56a36c2eea HgCheckoutCommand: clean parameter, discard changes in WD, test for clean checkout
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 536
diff changeset
52 File testRepoLoc = cloneRepoToTempLocation("log-1", "test-checkout-clean", true);
527
47b7bedf0569 Tests for present HgCheckoutCommand functionality. Update branch information on checkout. Use UTF8 encoding for the branch file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 526
diff changeset
53 repo = new HgLookup().detect(testRepoLoc);
47b7bedf0569 Tests for present HgCheckoutCommand functionality. Update branch information on checkout. Use UTF8 encoding for the branch file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 526
diff changeset
54 // nothing but .hg dir
47b7bedf0569 Tests for present HgCheckoutCommand functionality. Update branch information on checkout. Use UTF8 encoding for the branch file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 526
diff changeset
55 assertEquals("[sanity]", 0, testRepoLoc.listFiles(new FilesOnlyFilter()).length);
47b7bedf0569 Tests for present HgCheckoutCommand functionality. Update branch information on checkout. Use UTF8 encoding for the branch file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 526
diff changeset
56
563
ca56a36c2eea HgCheckoutCommand: clean parameter, discard changes in WD, test for clean checkout
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 536
diff changeset
57 new HgCheckoutCommand(repo).clean(true).changeset(1).execute();
527
47b7bedf0569 Tests for present HgCheckoutCommand functionality. Update branch information on checkout. Use UTF8 encoding for the branch file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 526
diff changeset
58 errorCollector.assertEquals(2, testRepoLoc.listFiles(new FilesOnlyFilter()).length);
47b7bedf0569 Tests for present HgCheckoutCommand functionality. Update branch information on checkout. Use UTF8 encoding for the branch file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 526
diff changeset
59
47b7bedf0569 Tests for present HgCheckoutCommand functionality. Update branch information on checkout. Use UTF8 encoding for the branch file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 526
diff changeset
60 Pair<Nodeid, Nodeid> workingCopyParents = repo.getWorkingCopyParents();
47b7bedf0569 Tests for present HgCheckoutCommand functionality. Update branch information on checkout. Use UTF8 encoding for the branch file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 526
diff changeset
61 errorCollector.assertEquals("da3461cd828dae8eb5fd11189d40e9df1961f191", workingCopyParents.first().toString());
47b7bedf0569 Tests for present HgCheckoutCommand functionality. Update branch information on checkout. Use UTF8 encoding for the branch file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 526
diff changeset
62 errorCollector.assertEquals(Nodeid.NULL, workingCopyParents.second());
47b7bedf0569 Tests for present HgCheckoutCommand functionality. Update branch information on checkout. Use UTF8 encoding for the branch file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 526
diff changeset
63 errorCollector.assertEquals(HgRepository.DEFAULT_BRANCH_NAME, repo.getWorkingCopyBranchName());
47b7bedf0569 Tests for present HgCheckoutCommand functionality. Update branch information on checkout. Use UTF8 encoding for the branch file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 526
diff changeset
64
47b7bedf0569 Tests for present HgCheckoutCommand functionality. Update branch information on checkout. Use UTF8 encoding for the branch file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 526
diff changeset
65 StatusOutputParser statusOutputParser = new StatusOutputParser();
47b7bedf0569 Tests for present HgCheckoutCommand functionality. Update branch information on checkout. Use UTF8 encoding for the branch file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 526
diff changeset
66 eh = new ExecHelper(statusOutputParser, testRepoLoc);
47b7bedf0569 Tests for present HgCheckoutCommand functionality. Update branch information on checkout. Use UTF8 encoding for the branch file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 526
diff changeset
67 eh.run("hg", "status", "-A");
47b7bedf0569 Tests for present HgCheckoutCommand functionality. Update branch information on checkout. Use UTF8 encoding for the branch file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 526
diff changeset
68 errorCollector.assertEquals(2, statusOutputParser.getClean().size());
47b7bedf0569 Tests for present HgCheckoutCommand functionality. Update branch information on checkout. Use UTF8 encoding for the branch file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 526
diff changeset
69 errorCollector.assertTrue(statusOutputParser.getClean().contains(Path.create("a")));
47b7bedf0569 Tests for present HgCheckoutCommand functionality. Update branch information on checkout. Use UTF8 encoding for the branch file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 526
diff changeset
70 errorCollector.assertTrue(statusOutputParser.getClean().contains(Path.create("b")));
47b7bedf0569 Tests for present HgCheckoutCommand functionality. Update branch information on checkout. Use UTF8 encoding for the branch file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 526
diff changeset
71
563
ca56a36c2eea HgCheckoutCommand: clean parameter, discard changes in WD, test for clean checkout
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 536
diff changeset
72 new HgCheckoutCommand(repo).clean(true).changeset(3).execute();
527
47b7bedf0569 Tests for present HgCheckoutCommand functionality. Update branch information on checkout. Use UTF8 encoding for the branch file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 526
diff changeset
73 statusOutputParser.reset();
47b7bedf0569 Tests for present HgCheckoutCommand functionality. Update branch information on checkout. Use UTF8 encoding for the branch file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 526
diff changeset
74 eh.run("hg", "status", "-A");
47b7bedf0569 Tests for present HgCheckoutCommand functionality. Update branch information on checkout. Use UTF8 encoding for the branch file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 526
diff changeset
75 errorCollector.assertEquals(3, statusOutputParser.getClean().size());
47b7bedf0569 Tests for present HgCheckoutCommand functionality. Update branch information on checkout. Use UTF8 encoding for the branch file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 526
diff changeset
76 errorCollector.assertTrue(statusOutputParser.getClean().contains(Path.create("b")));
47b7bedf0569 Tests for present HgCheckoutCommand functionality. Update branch information on checkout. Use UTF8 encoding for the branch file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 526
diff changeset
77 errorCollector.assertTrue(statusOutputParser.getClean().contains(Path.create("d")));
47b7bedf0569 Tests for present HgCheckoutCommand functionality. Update branch information on checkout. Use UTF8 encoding for the branch file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 526
diff changeset
78 errorCollector.assertTrue(statusOutputParser.getClean().contains(Path.create("dir/b")));
526
2f9ed6bcefa2 Initial support for Revert command with accompanying minor refactoring
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
79 }
2f9ed6bcefa2 Initial support for Revert command with accompanying minor refactoring
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
80
563
ca56a36c2eea HgCheckoutCommand: clean parameter, discard changes in WD, test for clean checkout
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 536
diff changeset
81 /**
ca56a36c2eea HgCheckoutCommand: clean parameter, discard changes in WD, test for clean checkout
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 536
diff changeset
82 * Make sure WC is cleared prior to clean checkout
ca56a36c2eea HgCheckoutCommand: clean parameter, discard changes in WD, test for clean checkout
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 536
diff changeset
83 */
526
2f9ed6bcefa2 Initial support for Revert command with accompanying minor refactoring
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
84 @Test
563
ca56a36c2eea HgCheckoutCommand: clean parameter, discard changes in WD, test for clean checkout
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 536
diff changeset
85 public void testCleanCheckoutInDirtyDir() throws Exception {
ca56a36c2eea HgCheckoutCommand: clean parameter, discard changes in WD, test for clean checkout
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 536
diff changeset
86 File repoLoc = cloneRepoToTempLocation("log-1", "test-checkout-dirty", false);
ca56a36c2eea HgCheckoutCommand: clean parameter, discard changes in WD, test for clean checkout
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 536
diff changeset
87 File untrackedFile = new File(repoLoc, "aaa");
ca56a36c2eea HgCheckoutCommand: clean parameter, discard changes in WD, test for clean checkout
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 536
diff changeset
88 RepoUtils.createFile(untrackedFile, "shall survive hg co --clean");
ca56a36c2eea HgCheckoutCommand: clean parameter, discard changes in WD, test for clean checkout
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 536
diff changeset
89 File modifiedFile = new File(repoLoc, "b");
ca56a36c2eea HgCheckoutCommand: clean parameter, discard changes in WD, test for clean checkout
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 536
diff changeset
90 assertTrue("[sanity]", modifiedFile.canRead());
ca56a36c2eea HgCheckoutCommand: clean parameter, discard changes in WD, test for clean checkout
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 536
diff changeset
91 final long modifiedFileInitialLen = modifiedFile.length();
ca56a36c2eea HgCheckoutCommand: clean parameter, discard changes in WD, test for clean checkout
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 536
diff changeset
92 RepoUtils.modifyFileAppend(modifiedFile, "the change shall not survive");
ca56a36c2eea HgCheckoutCommand: clean parameter, discard changes in WD, test for clean checkout
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 536
diff changeset
93 assertTrue("[sanity]", modifiedFile.length() > modifiedFileInitialLen);
ca56a36c2eea HgCheckoutCommand: clean parameter, discard changes in WD, test for clean checkout
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 536
diff changeset
94 //
ca56a36c2eea HgCheckoutCommand: clean parameter, discard changes in WD, test for clean checkout
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 536
diff changeset
95 repo = new HgLookup().detect(repoLoc);
ca56a36c2eea HgCheckoutCommand: clean parameter, discard changes in WD, test for clean checkout
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 536
diff changeset
96 new HgCheckoutCommand(repo).clean(true).changeset(TIP).execute();
ca56a36c2eea HgCheckoutCommand: clean parameter, discard changes in WD, test for clean checkout
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 536
diff changeset
97 errorCollector.assertTrue(untrackedFile.canRead());
ca56a36c2eea HgCheckoutCommand: clean parameter, discard changes in WD, test for clean checkout
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 536
diff changeset
98 errorCollector.assertEquals(modifiedFileInitialLen, modifiedFile.length());
526
2f9ed6bcefa2 Initial support for Revert command with accompanying minor refactoring
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
99 }
2f9ed6bcefa2 Initial support for Revert command with accompanying minor refactoring
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
100
2f9ed6bcefa2 Initial support for Revert command with accompanying minor refactoring
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
101 @Test
527
47b7bedf0569 Tests for present HgCheckoutCommand functionality. Update branch information on checkout. Use UTF8 encoding for the branch file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 526
diff changeset
102 public void testBranchCheckout() throws Exception {
536
2813a26b8999 Tests: refactor various utility methods to a single location
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 527
diff changeset
103 File testRepoLoc = cloneRepoToTempLocation("log-branches", "test-checkoutBranch", true);
527
47b7bedf0569 Tests for present HgCheckoutCommand functionality. Update branch information on checkout. Use UTF8 encoding for the branch file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 526
diff changeset
104 repo = new HgLookup().detect(testRepoLoc);
47b7bedf0569 Tests for present HgCheckoutCommand functionality. Update branch information on checkout. Use UTF8 encoding for the branch file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 526
diff changeset
105
563
ca56a36c2eea HgCheckoutCommand: clean parameter, discard changes in WD, test for clean checkout
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 536
diff changeset
106 new HgCheckoutCommand(repo).clean(true).changeset(3 /*branch test*/).execute();
527
47b7bedf0569 Tests for present HgCheckoutCommand functionality. Update branch information on checkout. Use UTF8 encoding for the branch file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 526
diff changeset
107
47b7bedf0569 Tests for present HgCheckoutCommand functionality. Update branch information on checkout. Use UTF8 encoding for the branch file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 526
diff changeset
108 StatusOutputParser statusOutputParser = new StatusOutputParser();
47b7bedf0569 Tests for present HgCheckoutCommand functionality. Update branch information on checkout. Use UTF8 encoding for the branch file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 526
diff changeset
109 eh = new ExecHelper(statusOutputParser, testRepoLoc);
47b7bedf0569 Tests for present HgCheckoutCommand functionality. Update branch information on checkout. Use UTF8 encoding for the branch file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 526
diff changeset
110 eh.run("hg", "status", "-A");
47b7bedf0569 Tests for present HgCheckoutCommand functionality. Update branch information on checkout. Use UTF8 encoding for the branch file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 526
diff changeset
111 errorCollector.assertEquals(3, statusOutputParser.getClean().size());
47b7bedf0569 Tests for present HgCheckoutCommand functionality. Update branch information on checkout. Use UTF8 encoding for the branch file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 526
diff changeset
112 errorCollector.assertTrue(statusOutputParser.getClean().contains(Path.create("a")));
47b7bedf0569 Tests for present HgCheckoutCommand functionality. Update branch information on checkout. Use UTF8 encoding for the branch file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 526
diff changeset
113 errorCollector.assertTrue(statusOutputParser.getClean().contains(Path.create("b")));
47b7bedf0569 Tests for present HgCheckoutCommand functionality. Update branch information on checkout. Use UTF8 encoding for the branch file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 526
diff changeset
114 errorCollector.assertTrue(statusOutputParser.getClean().contains(Path.create("c")));
47b7bedf0569 Tests for present HgCheckoutCommand functionality. Update branch information on checkout. Use UTF8 encoding for the branch file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 526
diff changeset
115
47b7bedf0569 Tests for present HgCheckoutCommand functionality. Update branch information on checkout. Use UTF8 encoding for the branch file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 526
diff changeset
116 errorCollector.assertEquals("test", repo.getWorkingCopyBranchName());
47b7bedf0569 Tests for present HgCheckoutCommand functionality. Update branch information on checkout. Use UTF8 encoding for the branch file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 526
diff changeset
117 }
47b7bedf0569 Tests for present HgCheckoutCommand functionality. Update branch information on checkout. Use UTF8 encoding for the branch file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 526
diff changeset
118
47b7bedf0569 Tests for present HgCheckoutCommand functionality. Update branch information on checkout. Use UTF8 encoding for the branch file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 526
diff changeset
119 private static final class FilesOnlyFilter implements FileFilter {
47b7bedf0569 Tests for present HgCheckoutCommand functionality. Update branch information on checkout. Use UTF8 encoding for the branch file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 526
diff changeset
120 public boolean accept(File f) {
47b7bedf0569 Tests for present HgCheckoutCommand functionality. Update branch information on checkout. Use UTF8 encoding for the branch file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 526
diff changeset
121 return f.isFile();
47b7bedf0569 Tests for present HgCheckoutCommand functionality. Update branch information on checkout. Use UTF8 encoding for the branch file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 526
diff changeset
122 }
526
2f9ed6bcefa2 Initial support for Revert command with accompanying minor refactoring
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
123 }
2f9ed6bcefa2 Initial support for Revert command with accompanying minor refactoring
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
124 }