Mercurial > jhg
annotate test/org/tmatesoft/hg/test/TestCommit.java @ 613:f41dd9a3b8af v1.1m4
Remove few Experimental annotations as the API they've marked graduates
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Fri, 10 May 2013 17:31:27 +0200 |
parents | dca70c0b1f74 |
children | 65c01508f002 |
rev | line source |
---|---|
534
243202f1bda5
Commit: refactor revision creation code from clone command to work separately, fit into existing library structure
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
1 /* |
243202f1bda5
Commit: refactor revision creation code from clone command to work separately, fit into existing library structure
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
2 * Copyright (c) 2013 TMate Software Ltd |
243202f1bda5
Commit: refactor revision creation code from clone command to work separately, fit into existing library structure
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
3 * |
243202f1bda5
Commit: refactor revision creation code from clone command to work separately, fit into existing library structure
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
4 * This program is free software; you can redistribute it and/or modify |
243202f1bda5
Commit: refactor revision creation code from clone command to work separately, fit into existing library structure
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
5 * it under the terms of the GNU General Public License as published by |
243202f1bda5
Commit: refactor revision creation code from clone command to work separately, fit into existing library structure
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
6 * the Free Software Foundation; version 2 of the License. |
243202f1bda5
Commit: refactor revision creation code from clone command to work separately, fit into existing library structure
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
7 * |
243202f1bda5
Commit: refactor revision creation code from clone command to work separately, fit into existing library structure
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
8 * This program is distributed in the hope that it will be useful, |
243202f1bda5
Commit: refactor revision creation code from clone command to work separately, fit into existing library structure
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
243202f1bda5
Commit: refactor revision creation code from clone command to work separately, fit into existing library structure
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
243202f1bda5
Commit: refactor revision creation code from clone command to work separately, fit into existing library structure
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
11 * GNU General Public License for more details. |
243202f1bda5
Commit: refactor revision creation code from clone command to work separately, fit into existing library structure
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
12 * |
243202f1bda5
Commit: refactor revision creation code from clone command to work separately, fit into existing library structure
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
13 * For information on how to redistribute this software under |
243202f1bda5
Commit: refactor revision creation code from clone command to work separately, fit into existing library structure
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
14 * the terms of a license other than GNU General Public License |
243202f1bda5
Commit: refactor revision creation code from clone command to work separately, fit into existing library structure
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
15 * contact TMate Software at support@hg4j.com |
243202f1bda5
Commit: refactor revision creation code from clone command to work separately, fit into existing library structure
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
16 */ |
243202f1bda5
Commit: refactor revision creation code from clone command to work separately, fit into existing library structure
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
17 package org.tmatesoft.hg.test; |
243202f1bda5
Commit: refactor revision creation code from clone command to work separately, fit into existing library structure
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
18 |
559
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
19 import static org.junit.Assert.*; |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
20 import static org.tmatesoft.hg.repo.HgRepository.*; |
539
9edfd5a223b8
Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
538
diff
changeset
|
21 |
538
dd4f6311af52
Commit: first working version
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
534
diff
changeset
|
22 import java.io.File; |
559
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
23 import java.io.IOException; |
538
dd4f6311af52
Commit: first working version
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
534
diff
changeset
|
24 import java.nio.ByteBuffer; |
559
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
25 import java.util.List; |
538
dd4f6311af52
Commit: first working version
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
534
diff
changeset
|
26 |
588
41218d84842a
Update dirstate after commit
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
586
diff
changeset
|
27 import org.junit.Rule; |
534
243202f1bda5
Commit: refactor revision creation code from clone command to work separately, fit into existing library structure
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
28 import org.junit.Test; |
559
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
29 import org.tmatesoft.hg.core.HgAddRemoveCommand; |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
30 import org.tmatesoft.hg.core.HgCatCommand; |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
31 import org.tmatesoft.hg.core.HgChangeset; |
586
73c20c648c1f
HgCommitCommand initial support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
565
diff
changeset
|
32 import org.tmatesoft.hg.core.HgCommitCommand; |
559
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
33 import org.tmatesoft.hg.core.HgLogCommand; |
586
73c20c648c1f
HgCommitCommand initial support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
565
diff
changeset
|
34 import org.tmatesoft.hg.core.HgStatus.Kind; |
73c20c648c1f
HgCommitCommand initial support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
565
diff
changeset
|
35 import org.tmatesoft.hg.core.HgStatusCommand; |
559
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
36 import org.tmatesoft.hg.core.Nodeid; |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
37 import org.tmatesoft.hg.internal.ByteArrayChannel; |
591
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
588
diff
changeset
|
38 import org.tmatesoft.hg.internal.CommitFacility; |
586
73c20c648c1f
HgCommitCommand initial support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
565
diff
changeset
|
39 import org.tmatesoft.hg.internal.FileContentSupplier; |
591
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
588
diff
changeset
|
40 import org.tmatesoft.hg.internal.Internals; |
559
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
41 import org.tmatesoft.hg.repo.HgDataFile; |
538
dd4f6311af52
Commit: first working version
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
534
diff
changeset
|
42 import org.tmatesoft.hg.repo.HgLookup; |
dd4f6311af52
Commit: first working version
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
534
diff
changeset
|
43 import org.tmatesoft.hg.repo.HgRepository; |
586
73c20c648c1f
HgCommitCommand initial support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
565
diff
changeset
|
44 import org.tmatesoft.hg.util.Outcome; |
559
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
45 import org.tmatesoft.hg.util.Path; |
534
243202f1bda5
Commit: refactor revision creation code from clone command to work separately, fit into existing library structure
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
46 |
243202f1bda5
Commit: refactor revision creation code from clone command to work separately, fit into existing library structure
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
47 /** |
559
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
48 * Handy for debug to see patch content: |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
49 * ...RevlogDump /tmp/test-commit2non-empty/.hg/ store/data/file1.i dumpData |
534
243202f1bda5
Commit: refactor revision creation code from clone command to work separately, fit into existing library structure
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
50 * |
243202f1bda5
Commit: refactor revision creation code from clone command to work separately, fit into existing library structure
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
51 * @author Artem Tikhomirov |
243202f1bda5
Commit: refactor revision creation code from clone command to work separately, fit into existing library structure
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
52 * @author TMate Software Ltd. |
243202f1bda5
Commit: refactor revision creation code from clone command to work separately, fit into existing library structure
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
53 */ |
243202f1bda5
Commit: refactor revision creation code from clone command to work separately, fit into existing library structure
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
54 public class TestCommit { |
243202f1bda5
Commit: refactor revision creation code from clone command to work separately, fit into existing library structure
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
55 |
588
41218d84842a
Update dirstate after commit
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
586
diff
changeset
|
56 @Rule |
41218d84842a
Update dirstate after commit
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
586
diff
changeset
|
57 public ErrorCollectorExt errorCollector = new ErrorCollectorExt(); |
41218d84842a
Update dirstate after commit
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
586
diff
changeset
|
58 |
534
243202f1bda5
Commit: refactor revision creation code from clone command to work separately, fit into existing library structure
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
59 @Test |
538
dd4f6311af52
Commit: first working version
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
534
diff
changeset
|
60 public void testCommitToNonEmpty() throws Exception { |
dd4f6311af52
Commit: first working version
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
534
diff
changeset
|
61 File repoLoc = RepoUtils.initEmptyTempRepo("test-commit2non-empty"); |
559
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
62 RepoUtils.createFile(new File(repoLoc, "file1"), "hello\n"); |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
63 new ExecHelper(new OutputParser.Stub(), repoLoc).run("hg", "commit", "--addremove", "-m", "FIRST"); |
538
dd4f6311af52
Commit: first working version
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
534
diff
changeset
|
64 // |
dd4f6311af52
Commit: first working version
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
534
diff
changeset
|
65 HgRepository hgRepo = new HgLookup().detect(repoLoc); |
591
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
588
diff
changeset
|
66 CommitFacility cf = new CommitFacility(Internals.getInstance(hgRepo), 0); |
559
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
67 // FIXME test diff for processing changed newlines (ie \r\n -> \n or vice verse) - if a whole line or |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
68 // just changed endings are in the patch! |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
69 HgDataFile df = hgRepo.getFileNode("file1"); |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
70 cf.add(df, new ByteArraySupplier("hello\nworld".getBytes())); |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
71 Nodeid secondRev = cf.commit("SECOND"); |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
72 // |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
73 List<HgChangeset> commits = new HgLogCommand(hgRepo).execute(); |
588
41218d84842a
Update dirstate after commit
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
586
diff
changeset
|
74 errorCollector.assertEquals(2, commits.size()); |
559
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
75 HgChangeset c1 = commits.get(0); |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
76 HgChangeset c2 = commits.get(1); |
588
41218d84842a
Update dirstate after commit
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
586
diff
changeset
|
77 errorCollector.assertEquals("FIRST", c1.getComment()); |
41218d84842a
Update dirstate after commit
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
586
diff
changeset
|
78 errorCollector.assertEquals("SECOND", c2.getComment()); |
41218d84842a
Update dirstate after commit
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
586
diff
changeset
|
79 errorCollector.assertEquals(df.getPath(), c2.getAffectedFiles().get(0)); |
41218d84842a
Update dirstate after commit
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
586
diff
changeset
|
80 errorCollector.assertEquals(c1.getNodeid(), c2.getFirstParentRevision()); |
41218d84842a
Update dirstate after commit
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
586
diff
changeset
|
81 errorCollector.assertEquals(Nodeid.NULL, c2.getSecondParentRevision()); |
41218d84842a
Update dirstate after commit
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
586
diff
changeset
|
82 errorCollector.assertEquals(secondRev, c2.getNodeid()); |
539
9edfd5a223b8
Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
538
diff
changeset
|
83 } |
9edfd5a223b8
Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
538
diff
changeset
|
84 |
9edfd5a223b8
Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
538
diff
changeset
|
85 @Test |
9edfd5a223b8
Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
538
diff
changeset
|
86 public void testCommitToEmpty() throws Exception { |
9edfd5a223b8
Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
538
diff
changeset
|
87 File repoLoc = RepoUtils.initEmptyTempRepo("test-commit2empty"); |
559
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
88 String fname = "file1"; |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
89 RepoUtils.createFile(new File(repoLoc, fname), null); |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
90 new ExecHelper(new OutputParser.Stub(), repoLoc).run("hg", "add", fname); |
539
9edfd5a223b8
Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
538
diff
changeset
|
91 // |
9edfd5a223b8
Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
538
diff
changeset
|
92 HgRepository hgRepo = new HgLookup().detect(repoLoc); |
559
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
93 assertEquals("[sanity]", 0, new HgLogCommand(hgRepo).execute().size()); |
591
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
588
diff
changeset
|
94 CommitFacility cf = new CommitFacility(Internals.getInstance(hgRepo), NO_REVISION); |
559
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
95 HgDataFile df = hgRepo.getFileNode(fname); |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
96 final byte[] initialContent = "hello\nworld".getBytes(); |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
97 cf.add(df, new ByteArraySupplier(initialContent)); |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
98 String comment = "commit 1"; |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
99 Nodeid c1Rev = cf.commit(comment); |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
100 List<HgChangeset> commits = new HgLogCommand(hgRepo).execute(); |
588
41218d84842a
Update dirstate after commit
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
586
diff
changeset
|
101 errorCollector.assertEquals(1, commits.size()); |
559
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
102 HgChangeset c1 = commits.get(0); |
588
41218d84842a
Update dirstate after commit
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
586
diff
changeset
|
103 errorCollector.assertEquals(1, c1.getAffectedFiles().size()); |
41218d84842a
Update dirstate after commit
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
586
diff
changeset
|
104 errorCollector.assertEquals(df.getPath(), c1.getAffectedFiles().get(0)); |
41218d84842a
Update dirstate after commit
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
586
diff
changeset
|
105 errorCollector.assertEquals(0, c1.getRevisionIndex()); |
41218d84842a
Update dirstate after commit
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
586
diff
changeset
|
106 errorCollector.assertEquals(Nodeid.NULL, c1.getFirstParentRevision()); |
41218d84842a
Update dirstate after commit
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
586
diff
changeset
|
107 errorCollector.assertEquals(Nodeid.NULL, c1.getSecondParentRevision()); |
41218d84842a
Update dirstate after commit
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
586
diff
changeset
|
108 errorCollector.assertEquals(HgRepository.DEFAULT_BRANCH_NAME, c1.getBranch()); |
41218d84842a
Update dirstate after commit
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
586
diff
changeset
|
109 errorCollector.assertEquals(comment, c1.getComment()); |
41218d84842a
Update dirstate after commit
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
586
diff
changeset
|
110 errorCollector.assertEquals(c1Rev, c1.getNodeid()); |
559
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
111 ByteArrayChannel bac = new ByteArrayChannel(); |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
112 new HgCatCommand(hgRepo).file(df.getPath()).execute(bac); |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
113 assertArrayEquals(initialContent, bac.toArray()); |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
114 } |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
115 |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
116 @Test |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
117 public void testCommitIntoBranch() throws Exception { |
613
f41dd9a3b8af
Remove few Experimental annotations as the API they've marked graduates
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
612
diff
changeset
|
118 File repoLoc = RepoUtils.cloneRepoToTempLocation("log-1", "test-commit2branch", false); |
559
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
119 HgRepository hgRepo = new HgLookup().detect(repoLoc); |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
120 HgDataFile dfD = hgRepo.getFileNode("d"); |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
121 assertTrue("[sanity]", dfD.exists()); |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
122 File fileD = new File(repoLoc, "d"); |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
123 assertTrue("[sanity]", fileD.canRead()); |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
124 final int parentCsetRevIndex = hgRepo.getChangelog().getLastRevision(); |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
125 HgChangeset parentCset = new HgLogCommand(hgRepo).range(parentCsetRevIndex, parentCsetRevIndex).execute().get(0); |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
126 assertEquals("[sanity]", DEFAULT_BRANCH_NAME, parentCset.getBranch()); |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
127 // |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
128 RepoUtils.modifyFileAppend(fileD, "A CHANGE\n"); |
591
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
588
diff
changeset
|
129 CommitFacility cf = new CommitFacility(Internals.getInstance(hgRepo), parentCsetRevIndex); |
559
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
130 FileContentSupplier contentProvider = new FileContentSupplier(fileD); |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
131 cf.add(dfD, contentProvider); |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
132 cf.branch("branch1"); |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
133 Nodeid commitRev1 = cf.commit("FIRST"); |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
134 contentProvider.done(); |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
135 // |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
136 List<HgChangeset> commits = new HgLogCommand(hgRepo).range(parentCsetRevIndex+1, TIP).execute(); |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
137 assertEquals(1, commits.size()); |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
138 HgChangeset c1 = commits.get(0); |
588
41218d84842a
Update dirstate after commit
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
586
diff
changeset
|
139 errorCollector.assertEquals(c1.getNodeid(), commitRev1); |
41218d84842a
Update dirstate after commit
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
586
diff
changeset
|
140 errorCollector.assertEquals("branch1", c1.getBranch()); |
41218d84842a
Update dirstate after commit
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
586
diff
changeset
|
141 errorCollector.assertEquals("FIRST", c1.getComment()); |
559
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
142 // |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
143 assertHgVerifyOk(repoLoc); |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
144 } |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
145 |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
146 /** |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
147 * use own add and remove commands and then commit |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
148 */ |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
149 @Test |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
150 public void testCommitWithAddRemove() throws Exception { |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
151 File repoLoc = RepoUtils.cloneRepoToTempLocation("log-1", "test-add-remove-commit", false); |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
152 HgRepository hgRepo = new HgLookup().detect(repoLoc); |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
153 assertTrue("[sanity]", hgRepo.getFileNode("d").exists()); |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
154 assertTrue("[sanity]", new File(repoLoc, "d").canRead()); |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
155 RepoUtils.createFile(new File(repoLoc, "xx"), "xyz"); |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
156 new HgAddRemoveCommand(hgRepo).add(Path.create("xx")).remove(Path.create("d")).execute(); |
591
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
588
diff
changeset
|
157 CommitFacility cf = new CommitFacility(Internals.getInstance(hgRepo), hgRepo.getChangelog().getLastRevision()); |
559
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
158 FileContentSupplier contentProvider = new FileContentSupplier(new File(repoLoc, "xx")); |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
159 cf.add(hgRepo.getFileNode("xx"), contentProvider); |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
160 cf.forget(hgRepo.getFileNode("d")); |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
161 Nodeid commitRev = cf.commit("Commit with add/remove cmd"); |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
162 contentProvider.done(); |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
163 // |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
164 List<HgChangeset> commits = new HgLogCommand(hgRepo).changeset(commitRev).execute(); |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
165 HgChangeset cmt = commits.get(0); |
588
41218d84842a
Update dirstate after commit
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
586
diff
changeset
|
166 errorCollector.assertEquals(1, cmt.getAddedFiles().size()); |
41218d84842a
Update dirstate after commit
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
586
diff
changeset
|
167 errorCollector.assertEquals("xx", cmt.getAddedFiles().get(0).getPath().toString()); |
41218d84842a
Update dirstate after commit
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
586
diff
changeset
|
168 errorCollector.assertEquals(1, cmt.getRemovedFiles().size()); |
41218d84842a
Update dirstate after commit
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
586
diff
changeset
|
169 errorCollector.assertEquals("d", cmt.getRemovedFiles().get(0).toString()); |
559
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
170 ByteArrayChannel sink = new ByteArrayChannel(); |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
171 new HgCatCommand(hgRepo).file(Path.create("xx")).changeset(commitRev).execute(sink); |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
172 assertArrayEquals("xyz".getBytes(), sink.toArray()); |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
173 // |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
174 assertHgVerifyOk(repoLoc); |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
175 } |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
176 /** |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
177 * perform few commits one by one, into different branches |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
178 */ |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
179 @Test |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
180 public void testSequentialCommits() throws Exception { |
613
f41dd9a3b8af
Remove few Experimental annotations as the API they've marked graduates
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
612
diff
changeset
|
181 File repoLoc = RepoUtils.cloneRepoToTempLocation("log-1", "test-sequential-commits", false); |
559
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
182 HgRepository hgRepo = new HgLookup().detect(repoLoc); |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
183 HgDataFile dfD = hgRepo.getFileNode("d"); |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
184 assertTrue("[sanity]", dfD.exists()); |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
185 File fileD = new File(repoLoc, "d"); |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
186 assertTrue("[sanity]", fileD.canRead()); |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
187 // |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
188 RepoUtils.modifyFileAppend(fileD, " 1 \n"); |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
189 final int parentCsetRevIndex = hgRepo.getChangelog().getLastRevision(); |
591
e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
588
diff
changeset
|
190 CommitFacility cf = new CommitFacility(Internals.getInstance(hgRepo), parentCsetRevIndex); |
559
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
191 FileContentSupplier contentProvider = new FileContentSupplier(fileD); |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
192 cf.add(dfD, contentProvider); |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
193 cf.branch("branch1"); |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
194 Nodeid commitRev1 = cf.commit("FIRST"); |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
195 contentProvider.done(); |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
196 // |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
197 RepoUtils.modifyFileAppend(fileD, " 2 \n"); |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
198 cf.add(dfD, contentProvider = new FileContentSupplier(fileD)); |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
199 cf.branch("branch2"); |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
200 Nodeid commitRev2 = cf.commit("SECOND"); |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
201 contentProvider.done(); |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
202 // |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
203 RepoUtils.modifyFileAppend(fileD, " 2 \n"); |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
204 cf.add(dfD, contentProvider = new FileContentSupplier(fileD)); |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
205 cf.branch(DEFAULT_BRANCH_NAME); |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
206 Nodeid commitRev3 = cf.commit("THIRD"); |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
207 contentProvider.done(); |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
208 // |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
209 List<HgChangeset> commits = new HgLogCommand(hgRepo).range(parentCsetRevIndex+1, TIP).execute(); |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
210 assertEquals(3, commits.size()); |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
211 HgChangeset c1 = commits.get(0); |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
212 HgChangeset c2 = commits.get(1); |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
213 HgChangeset c3 = commits.get(2); |
588
41218d84842a
Update dirstate after commit
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
586
diff
changeset
|
214 errorCollector.assertEquals(c1.getNodeid(), commitRev1); |
41218d84842a
Update dirstate after commit
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
586
diff
changeset
|
215 errorCollector.assertEquals(c2.getNodeid(), commitRev2); |
41218d84842a
Update dirstate after commit
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
586
diff
changeset
|
216 errorCollector.assertEquals(c3.getNodeid(), commitRev3); |
41218d84842a
Update dirstate after commit
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
586
diff
changeset
|
217 errorCollector.assertEquals("branch1", c1.getBranch()); |
41218d84842a
Update dirstate after commit
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
586
diff
changeset
|
218 errorCollector.assertEquals("branch2", c2.getBranch()); |
41218d84842a
Update dirstate after commit
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
586
diff
changeset
|
219 errorCollector.assertEquals(DEFAULT_BRANCH_NAME, c3.getBranch()); |
41218d84842a
Update dirstate after commit
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
586
diff
changeset
|
220 errorCollector.assertEquals("FIRST", c1.getComment()); |
41218d84842a
Update dirstate after commit
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
586
diff
changeset
|
221 errorCollector.assertEquals("SECOND", c2.getComment()); |
41218d84842a
Update dirstate after commit
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
586
diff
changeset
|
222 errorCollector.assertEquals("THIRD", c3.getComment()); |
559
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
223 assertHgVerifyOk(repoLoc); |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
224 } |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
225 |
586
73c20c648c1f
HgCommitCommand initial support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
565
diff
changeset
|
226 @Test |
73c20c648c1f
HgCommitCommand initial support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
565
diff
changeset
|
227 public void testCommandBasics() throws Exception { |
73c20c648c1f
HgCommitCommand initial support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
565
diff
changeset
|
228 File repoLoc = RepoUtils.cloneRepoToTempLocation("log-1", "test-commit-cmd", false); |
73c20c648c1f
HgCommitCommand initial support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
565
diff
changeset
|
229 HgRepository hgRepo = new HgLookup().detect(repoLoc); |
73c20c648c1f
HgCommitCommand initial support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
565
diff
changeset
|
230 HgDataFile dfB = hgRepo.getFileNode("b"); |
73c20c648c1f
HgCommitCommand initial support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
565
diff
changeset
|
231 assertTrue("[sanity]", dfB.exists()); |
73c20c648c1f
HgCommitCommand initial support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
565
diff
changeset
|
232 File fileB = new File(repoLoc, "b"); |
73c20c648c1f
HgCommitCommand initial support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
565
diff
changeset
|
233 assertTrue("[sanity]", fileB.canRead()); |
73c20c648c1f
HgCommitCommand initial support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
565
diff
changeset
|
234 RepoUtils.modifyFileAppend(fileB, " 1 \n"); |
73c20c648c1f
HgCommitCommand initial support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
565
diff
changeset
|
235 |
73c20c648c1f
HgCommitCommand initial support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
565
diff
changeset
|
236 HgCommitCommand cmd = new HgCommitCommand(hgRepo); |
73c20c648c1f
HgCommitCommand initial support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
565
diff
changeset
|
237 assertFalse(cmd.isMergeCommit()); |
73c20c648c1f
HgCommitCommand initial support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
565
diff
changeset
|
238 Outcome r = cmd.message("FIRST").execute(); |
588
41218d84842a
Update dirstate after commit
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
586
diff
changeset
|
239 errorCollector.assertTrue(r.isOk()); |
586
73c20c648c1f
HgCommitCommand initial support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
565
diff
changeset
|
240 Nodeid c1 = cmd.getCommittedRevision(); |
73c20c648c1f
HgCommitCommand initial support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
565
diff
changeset
|
241 |
588
41218d84842a
Update dirstate after commit
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
586
diff
changeset
|
242 // check that modified files are no longer reported as such |
586
73c20c648c1f
HgCommitCommand initial support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
565
diff
changeset
|
243 TestStatus.StatusCollector status = new TestStatus.StatusCollector(); |
588
41218d84842a
Update dirstate after commit
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
586
diff
changeset
|
244 new HgStatusCommand(hgRepo).all().execute(status); |
41218d84842a
Update dirstate after commit
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
586
diff
changeset
|
245 errorCollector.assertTrue(status.getErrors().isEmpty()); |
41218d84842a
Update dirstate after commit
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
586
diff
changeset
|
246 errorCollector.assertTrue(status.get(Kind.Modified).isEmpty()); |
41218d84842a
Update dirstate after commit
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
586
diff
changeset
|
247 errorCollector.assertEquals(1, status.get(dfB.getPath()).size()); |
41218d84842a
Update dirstate after commit
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
586
diff
changeset
|
248 errorCollector.assertTrue(status.get(dfB.getPath()).contains(Kind.Clean)); |
586
73c20c648c1f
HgCommitCommand initial support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
565
diff
changeset
|
249 |
73c20c648c1f
HgCommitCommand initial support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
565
diff
changeset
|
250 HgDataFile dfD = hgRepo.getFileNode("d"); |
73c20c648c1f
HgCommitCommand initial support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
565
diff
changeset
|
251 assertTrue("[sanity]", dfD.exists()); |
73c20c648c1f
HgCommitCommand initial support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
565
diff
changeset
|
252 File fileD = new File(repoLoc, "d"); |
73c20c648c1f
HgCommitCommand initial support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
565
diff
changeset
|
253 assertTrue("[sanity]", fileD.canRead()); |
73c20c648c1f
HgCommitCommand initial support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
565
diff
changeset
|
254 // |
73c20c648c1f
HgCommitCommand initial support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
565
diff
changeset
|
255 RepoUtils.modifyFileAppend(fileD, " 1 \n"); |
73c20c648c1f
HgCommitCommand initial support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
565
diff
changeset
|
256 cmd = new HgCommitCommand(hgRepo); |
73c20c648c1f
HgCommitCommand initial support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
565
diff
changeset
|
257 assertFalse(cmd.isMergeCommit()); |
73c20c648c1f
HgCommitCommand initial support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
565
diff
changeset
|
258 r = cmd.message("SECOND").execute(); |
588
41218d84842a
Update dirstate after commit
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
586
diff
changeset
|
259 errorCollector.assertTrue(r.isOk()); |
586
73c20c648c1f
HgCommitCommand initial support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
565
diff
changeset
|
260 Nodeid c2 = cmd.getCommittedRevision(); |
73c20c648c1f
HgCommitCommand initial support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
565
diff
changeset
|
261 // |
73c20c648c1f
HgCommitCommand initial support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
565
diff
changeset
|
262 int lastRev = hgRepo.getChangelog().getLastRevision(); |
73c20c648c1f
HgCommitCommand initial support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
565
diff
changeset
|
263 List<HgChangeset> csets = new HgLogCommand(hgRepo).range(lastRev-1, lastRev).execute(); |
588
41218d84842a
Update dirstate after commit
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
586
diff
changeset
|
264 errorCollector.assertEquals(csets.get(0).getNodeid(), c1); |
41218d84842a
Update dirstate after commit
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
586
diff
changeset
|
265 errorCollector.assertEquals(csets.get(1).getNodeid(), c2); |
41218d84842a
Update dirstate after commit
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
586
diff
changeset
|
266 errorCollector.assertEquals(csets.get(0).getComment(), "FIRST"); |
41218d84842a
Update dirstate after commit
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
586
diff
changeset
|
267 errorCollector.assertEquals(csets.get(1).getComment(), "SECOND"); |
586
73c20c648c1f
HgCommitCommand initial support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
565
diff
changeset
|
268 assertHgVerifyOk(repoLoc); |
73c20c648c1f
HgCommitCommand initial support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
565
diff
changeset
|
269 } |
73c20c648c1f
HgCommitCommand initial support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
565
diff
changeset
|
270 |
605
c56edf42be64
Commit: update active bookmark with new revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
591
diff
changeset
|
271 @Test |
c56edf42be64
Commit: update active bookmark with new revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
591
diff
changeset
|
272 public void testUpdateActiveBookmark() throws Exception { |
612
dca70c0b1f74
Test tags, branches and hgingore information get refreshed on external (and/or internal) change
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
607
diff
changeset
|
273 File repoLoc = RepoUtils.cloneRepoToTempLocation("log-1", "test-commit-bookmark-update", false); |
605
c56edf42be64
Commit: update active bookmark with new revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
591
diff
changeset
|
274 ExecHelper eh = new ExecHelper(new OutputParser.Stub(), repoLoc); |
c56edf42be64
Commit: update active bookmark with new revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
591
diff
changeset
|
275 String activeBookmark = "bm1"; |
c56edf42be64
Commit: update active bookmark with new revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
591
diff
changeset
|
276 eh.run("hg", "bookmarks", activeBookmark); |
c56edf42be64
Commit: update active bookmark with new revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
591
diff
changeset
|
277 |
c56edf42be64
Commit: update active bookmark with new revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
591
diff
changeset
|
278 HgRepository hgRepo = new HgLookup().detect(repoLoc); |
c56edf42be64
Commit: update active bookmark with new revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
591
diff
changeset
|
279 assertEquals("[sanity]", activeBookmark, hgRepo.getBookmarks().getActiveBookmarkName()); |
c56edf42be64
Commit: update active bookmark with new revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
591
diff
changeset
|
280 Nodeid activeBookmarkRevision = hgRepo.getBookmarks().getRevision(activeBookmark); |
c56edf42be64
Commit: update active bookmark with new revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
591
diff
changeset
|
281 assertEquals("[sanity]", activeBookmarkRevision, hgRepo.getWorkingCopyParents().first()); |
c56edf42be64
Commit: update active bookmark with new revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
591
diff
changeset
|
282 |
c56edf42be64
Commit: update active bookmark with new revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
591
diff
changeset
|
283 HgDataFile dfD = hgRepo.getFileNode("d"); |
c56edf42be64
Commit: update active bookmark with new revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
591
diff
changeset
|
284 File fileD = new File(repoLoc, "d"); |
c56edf42be64
Commit: update active bookmark with new revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
591
diff
changeset
|
285 assertTrue("[sanity]", dfD.exists()); |
c56edf42be64
Commit: update active bookmark with new revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
591
diff
changeset
|
286 assertTrue("[sanity]", fileD.canRead()); |
c56edf42be64
Commit: update active bookmark with new revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
591
diff
changeset
|
287 |
c56edf42be64
Commit: update active bookmark with new revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
591
diff
changeset
|
288 RepoUtils.modifyFileAppend(fileD, " 1 \n"); |
c56edf42be64
Commit: update active bookmark with new revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
591
diff
changeset
|
289 HgCommitCommand cmd = new HgCommitCommand(hgRepo).message("FIRST"); |
c56edf42be64
Commit: update active bookmark with new revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
591
diff
changeset
|
290 Outcome r = cmd.execute(); |
c56edf42be64
Commit: update active bookmark with new revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
591
diff
changeset
|
291 errorCollector.assertTrue(r.isOk()); |
c56edf42be64
Commit: update active bookmark with new revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
591
diff
changeset
|
292 Nodeid c = cmd.getCommittedRevision(); |
c56edf42be64
Commit: update active bookmark with new revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
591
diff
changeset
|
293 |
c56edf42be64
Commit: update active bookmark with new revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
591
diff
changeset
|
294 errorCollector.assertEquals(activeBookmark, hgRepo.getBookmarks().getActiveBookmarkName()); |
c56edf42be64
Commit: update active bookmark with new revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
591
diff
changeset
|
295 errorCollector.assertEquals(c, hgRepo.getBookmarks().getRevision(activeBookmark)); |
c56edf42be64
Commit: update active bookmark with new revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
591
diff
changeset
|
296 // reload repo, and repeat the check |
c56edf42be64
Commit: update active bookmark with new revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
591
diff
changeset
|
297 hgRepo = new HgLookup().detect(repoLoc); |
c56edf42be64
Commit: update active bookmark with new revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
591
diff
changeset
|
298 errorCollector.assertEquals(activeBookmark, hgRepo.getBookmarks().getActiveBookmarkName()); |
c56edf42be64
Commit: update active bookmark with new revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
591
diff
changeset
|
299 errorCollector.assertEquals(c, hgRepo.getBookmarks().getRevision(activeBookmark)); |
c56edf42be64
Commit: update active bookmark with new revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
591
diff
changeset
|
300 } |
612
dca70c0b1f74
Test tags, branches and hgingore information get refreshed on external (and/or internal) change
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
607
diff
changeset
|
301 |
dca70c0b1f74
Test tags, branches and hgingore information get refreshed on external (and/or internal) change
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
607
diff
changeset
|
302 @Test |
dca70c0b1f74
Test tags, branches and hgingore information get refreshed on external (and/or internal) change
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
607
diff
changeset
|
303 public void testRefreshTagsAndBranches() throws Exception { |
dca70c0b1f74
Test tags, branches and hgingore information get refreshed on external (and/or internal) change
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
607
diff
changeset
|
304 File repoLoc = RepoUtils.cloneRepoToTempLocation("log-branches", "test-refresh-after-commit", false); |
dca70c0b1f74
Test tags, branches and hgingore information get refreshed on external (and/or internal) change
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
607
diff
changeset
|
305 final String tag = "tag.refresh", branch = "branch-refresh"; |
dca70c0b1f74
Test tags, branches and hgingore information get refreshed on external (and/or internal) change
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
607
diff
changeset
|
306 HgRepository hgRepo = new HgLookup().detect(repoLoc); |
dca70c0b1f74
Test tags, branches and hgingore information get refreshed on external (and/or internal) change
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
607
diff
changeset
|
307 assertFalse(hgRepo.getTags().getAllTags().containsKey(tag)); |
dca70c0b1f74
Test tags, branches and hgingore information get refreshed on external (and/or internal) change
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
607
diff
changeset
|
308 assertNull(hgRepo.getBranches().getBranch(branch)); |
dca70c0b1f74
Test tags, branches and hgingore information get refreshed on external (and/or internal) change
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
607
diff
changeset
|
309 RepoUtils.modifyFileAppend(new File(repoLoc, "a"), "whatever"); |
dca70c0b1f74
Test tags, branches and hgingore information get refreshed on external (and/or internal) change
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
607
diff
changeset
|
310 // |
dca70c0b1f74
Test tags, branches and hgingore information get refreshed on external (and/or internal) change
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
607
diff
changeset
|
311 final int parentCsetRevIndex = hgRepo.getChangelog().getLastRevision(); |
dca70c0b1f74
Test tags, branches and hgingore information get refreshed on external (and/or internal) change
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
607
diff
changeset
|
312 // HgCommitCommand can't do branch yet |
dca70c0b1f74
Test tags, branches and hgingore information get refreshed on external (and/or internal) change
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
607
diff
changeset
|
313 CommitFacility cf = new CommitFacility(Internals.getInstance(hgRepo), parentCsetRevIndex); |
dca70c0b1f74
Test tags, branches and hgingore information get refreshed on external (and/or internal) change
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
607
diff
changeset
|
314 cf.add(hgRepo.getFileNode("a"), new FileContentSupplier(new File(repoLoc, "a"))); |
dca70c0b1f74
Test tags, branches and hgingore information get refreshed on external (and/or internal) change
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
607
diff
changeset
|
315 cf.branch(branch); |
dca70c0b1f74
Test tags, branches and hgingore information get refreshed on external (and/or internal) change
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
607
diff
changeset
|
316 Nodeid commit = cf.commit("FIRST"); |
dca70c0b1f74
Test tags, branches and hgingore information get refreshed on external (and/or internal) change
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
607
diff
changeset
|
317 errorCollector.assertEquals("commit with branch shall update WC", branch, hgRepo.getWorkingCopyBranchName()); |
dca70c0b1f74
Test tags, branches and hgingore information get refreshed on external (and/or internal) change
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
607
diff
changeset
|
318 |
dca70c0b1f74
Test tags, branches and hgingore information get refreshed on external (and/or internal) change
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
607
diff
changeset
|
319 ExecHelper eh = new ExecHelper(new OutputParser.Stub(), repoLoc); |
dca70c0b1f74
Test tags, branches and hgingore information get refreshed on external (and/or internal) change
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
607
diff
changeset
|
320 eh.run("hg", "tag", tag); |
dca70c0b1f74
Test tags, branches and hgingore information get refreshed on external (and/or internal) change
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
607
diff
changeset
|
321 assertEquals("[sanity]", 0, eh.getExitValue()); |
dca70c0b1f74
Test tags, branches and hgingore information get refreshed on external (and/or internal) change
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
607
diff
changeset
|
322 |
dca70c0b1f74
Test tags, branches and hgingore information get refreshed on external (and/or internal) change
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
607
diff
changeset
|
323 errorCollector.assertTrue(hgRepo.getTags().getAllTags().containsKey(tag)); |
dca70c0b1f74
Test tags, branches and hgingore information get refreshed on external (and/or internal) change
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
607
diff
changeset
|
324 errorCollector.assertFalse(hgRepo.getBranches().getBranch(branch) == null); |
dca70c0b1f74
Test tags, branches and hgingore information get refreshed on external (and/or internal) change
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
607
diff
changeset
|
325 errorCollector.assertTrue(hgRepo.getTags().tagged(tag).contains(commit)); |
dca70c0b1f74
Test tags, branches and hgingore information get refreshed on external (and/or internal) change
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
607
diff
changeset
|
326 errorCollector.assertTrue(hgRepo.getTags().tags(commit).contains(tag)); |
dca70c0b1f74
Test tags, branches and hgingore information get refreshed on external (and/or internal) change
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
607
diff
changeset
|
327 } |
605
c56edf42be64
Commit: update active bookmark with new revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
591
diff
changeset
|
328 |
559
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
329 private void assertHgVerifyOk(File repoLoc) throws InterruptedException, IOException { |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
330 ExecHelper verifyRun = new ExecHelper(new OutputParser.Stub(), repoLoc); |
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
331 verifyRun.run("hg", "verify"); |
588
41218d84842a
Update dirstate after commit
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
586
diff
changeset
|
332 errorCollector.assertEquals("hg verify", 0, verifyRun.getExitValue()); |
538
dd4f6311af52
Commit: first working version
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
534
diff
changeset
|
333 } |
539
9edfd5a223b8
Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
538
diff
changeset
|
334 |
538
dd4f6311af52
Commit: first working version
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
534
diff
changeset
|
335 public static void main(String[] args) throws Exception { |
539
9edfd5a223b8
Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
538
diff
changeset
|
336 new TestCommit().testCommitToEmpty(); |
9edfd5a223b8
Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
538
diff
changeset
|
337 if (Boolean.TRUE.booleanValue()) { |
9edfd5a223b8
Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
538
diff
changeset
|
338 return; |
9edfd5a223b8
Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
538
diff
changeset
|
339 } |
538
dd4f6311af52
Commit: first working version
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
534
diff
changeset
|
340 String input = "abcdefghijklmnopqrstuvwxyz"; |
dd4f6311af52
Commit: first working version
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
534
diff
changeset
|
341 ByteArraySupplier bas = new ByteArraySupplier(input.getBytes()); |
dd4f6311af52
Commit: first working version
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
534
diff
changeset
|
342 ByteBuffer bb = ByteBuffer.allocate(7); |
dd4f6311af52
Commit: first working version
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
534
diff
changeset
|
343 byte[] result = new byte[26]; |
dd4f6311af52
Commit: first working version
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
534
diff
changeset
|
344 int rpos = 0; |
dd4f6311af52
Commit: first working version
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
534
diff
changeset
|
345 while (bas.read(bb) != -1) { |
dd4f6311af52
Commit: first working version
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
534
diff
changeset
|
346 bb.flip(); |
dd4f6311af52
Commit: first working version
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
534
diff
changeset
|
347 bb.get(result, rpos, bb.limit()); |
dd4f6311af52
Commit: first working version
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
534
diff
changeset
|
348 rpos += bb.limit(); |
dd4f6311af52
Commit: first working version
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
534
diff
changeset
|
349 bb.clear(); |
dd4f6311af52
Commit: first working version
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
534
diff
changeset
|
350 } |
dd4f6311af52
Commit: first working version
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
534
diff
changeset
|
351 if (input.length() != rpos) { |
dd4f6311af52
Commit: first working version
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
534
diff
changeset
|
352 throw new AssertionError(); |
dd4f6311af52
Commit: first working version
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
534
diff
changeset
|
353 } |
dd4f6311af52
Commit: first working version
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
534
diff
changeset
|
354 String output = new String(result); |
dd4f6311af52
Commit: first working version
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
534
diff
changeset
|
355 if (!input.equals(output)) { |
dd4f6311af52
Commit: first working version
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
534
diff
changeset
|
356 throw new AssertionError(); |
dd4f6311af52
Commit: first working version
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
534
diff
changeset
|
357 } |
dd4f6311af52
Commit: first working version
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
534
diff
changeset
|
358 System.out.println(output); |
dd4f6311af52
Commit: first working version
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
534
diff
changeset
|
359 } |
dd4f6311af52
Commit: first working version
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
534
diff
changeset
|
360 |
dd4f6311af52
Commit: first working version
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
534
diff
changeset
|
361 static class ByteArraySupplier implements CommitFacility.ByteDataSupplier { |
dd4f6311af52
Commit: first working version
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
534
diff
changeset
|
362 |
dd4f6311af52
Commit: first working version
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
534
diff
changeset
|
363 private final byte[] data; |
dd4f6311af52
Commit: first working version
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
534
diff
changeset
|
364 private int pos = 0; |
dd4f6311af52
Commit: first working version
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
534
diff
changeset
|
365 |
dd4f6311af52
Commit: first working version
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
534
diff
changeset
|
366 public ByteArraySupplier(byte[] source) { |
dd4f6311af52
Commit: first working version
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
534
diff
changeset
|
367 data = source; |
dd4f6311af52
Commit: first working version
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
534
diff
changeset
|
368 } |
dd4f6311af52
Commit: first working version
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
534
diff
changeset
|
369 |
dd4f6311af52
Commit: first working version
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
534
diff
changeset
|
370 public int read(ByteBuffer buf) { |
dd4f6311af52
Commit: first working version
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
534
diff
changeset
|
371 if (pos >= data.length) { |
dd4f6311af52
Commit: first working version
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
534
diff
changeset
|
372 return -1; |
dd4f6311af52
Commit: first working version
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
534
diff
changeset
|
373 } |
dd4f6311af52
Commit: first working version
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
534
diff
changeset
|
374 int count = Math.min(buf.remaining(), data.length - pos); |
dd4f6311af52
Commit: first working version
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
534
diff
changeset
|
375 buf.put(data, pos, count); |
dd4f6311af52
Commit: first working version
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
534
diff
changeset
|
376 pos += count; |
dd4f6311af52
Commit: first working version
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
534
diff
changeset
|
377 return count; |
dd4f6311af52
Commit: first working version
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
534
diff
changeset
|
378 } |
534
243202f1bda5
Commit: refactor revision creation code from clone command to work separately, fit into existing library structure
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
379 } |
243202f1bda5
Commit: refactor revision creation code from clone command to work separately, fit into existing library structure
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
380 } |