Mercurial > hg4j
comparison test/org/tmatesoft/hg/test/TestCommit.java @ 591:e447384f3771
CommitFacility as internal class; refactored infrastructure around internals (access to RevlogStream)
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Tue, 30 Apr 2013 18:55:42 +0200 |
parents | 41218d84842a |
children | c56edf42be64 |
comparison
equal
deleted
inserted
replaced
590:8cbc2a883d95 | 591:e447384f3771 |
---|---|
33 import org.tmatesoft.hg.core.HgLogCommand; | 33 import org.tmatesoft.hg.core.HgLogCommand; |
34 import org.tmatesoft.hg.core.HgStatus.Kind; | 34 import org.tmatesoft.hg.core.HgStatus.Kind; |
35 import org.tmatesoft.hg.core.HgStatusCommand; | 35 import org.tmatesoft.hg.core.HgStatusCommand; |
36 import org.tmatesoft.hg.core.Nodeid; | 36 import org.tmatesoft.hg.core.Nodeid; |
37 import org.tmatesoft.hg.internal.ByteArrayChannel; | 37 import org.tmatesoft.hg.internal.ByteArrayChannel; |
38 import org.tmatesoft.hg.internal.CommitFacility; | |
38 import org.tmatesoft.hg.internal.FileContentSupplier; | 39 import org.tmatesoft.hg.internal.FileContentSupplier; |
39 import org.tmatesoft.hg.repo.CommitFacility; | 40 import org.tmatesoft.hg.internal.Internals; |
40 import org.tmatesoft.hg.repo.HgDataFile; | 41 import org.tmatesoft.hg.repo.HgDataFile; |
41 import org.tmatesoft.hg.repo.HgLookup; | 42 import org.tmatesoft.hg.repo.HgLookup; |
42 import org.tmatesoft.hg.repo.HgRepository; | 43 import org.tmatesoft.hg.repo.HgRepository; |
43 import org.tmatesoft.hg.util.Outcome; | 44 import org.tmatesoft.hg.util.Outcome; |
44 import org.tmatesoft.hg.util.Path; | 45 import org.tmatesoft.hg.util.Path; |
60 File repoLoc = RepoUtils.initEmptyTempRepo("test-commit2non-empty"); | 61 File repoLoc = RepoUtils.initEmptyTempRepo("test-commit2non-empty"); |
61 RepoUtils.createFile(new File(repoLoc, "file1"), "hello\n"); | 62 RepoUtils.createFile(new File(repoLoc, "file1"), "hello\n"); |
62 new ExecHelper(new OutputParser.Stub(), repoLoc).run("hg", "commit", "--addremove", "-m", "FIRST"); | 63 new ExecHelper(new OutputParser.Stub(), repoLoc).run("hg", "commit", "--addremove", "-m", "FIRST"); |
63 // | 64 // |
64 HgRepository hgRepo = new HgLookup().detect(repoLoc); | 65 HgRepository hgRepo = new HgLookup().detect(repoLoc); |
65 CommitFacility cf = new CommitFacility(hgRepo, 0); | 66 CommitFacility cf = new CommitFacility(Internals.getInstance(hgRepo), 0); |
66 // FIXME test diff for processing changed newlines (ie \r\n -> \n or vice verse) - if a whole line or | 67 // FIXME test diff for processing changed newlines (ie \r\n -> \n or vice verse) - if a whole line or |
67 // just changed endings are in the patch! | 68 // just changed endings are in the patch! |
68 HgDataFile df = hgRepo.getFileNode("file1"); | 69 HgDataFile df = hgRepo.getFileNode("file1"); |
69 cf.add(df, new ByteArraySupplier("hello\nworld".getBytes())); | 70 cf.add(df, new ByteArraySupplier("hello\nworld".getBytes())); |
70 Nodeid secondRev = cf.commit("SECOND"); | 71 Nodeid secondRev = cf.commit("SECOND"); |
88 RepoUtils.createFile(new File(repoLoc, fname), null); | 89 RepoUtils.createFile(new File(repoLoc, fname), null); |
89 new ExecHelper(new OutputParser.Stub(), repoLoc).run("hg", "add", fname); | 90 new ExecHelper(new OutputParser.Stub(), repoLoc).run("hg", "add", fname); |
90 // | 91 // |
91 HgRepository hgRepo = new HgLookup().detect(repoLoc); | 92 HgRepository hgRepo = new HgLookup().detect(repoLoc); |
92 assertEquals("[sanity]", 0, new HgLogCommand(hgRepo).execute().size()); | 93 assertEquals("[sanity]", 0, new HgLogCommand(hgRepo).execute().size()); |
93 CommitFacility cf = new CommitFacility(hgRepo, NO_REVISION); | 94 CommitFacility cf = new CommitFacility(Internals.getInstance(hgRepo), NO_REVISION); |
94 HgDataFile df = hgRepo.getFileNode(fname); | 95 HgDataFile df = hgRepo.getFileNode(fname); |
95 final byte[] initialContent = "hello\nworld".getBytes(); | 96 final byte[] initialContent = "hello\nworld".getBytes(); |
96 cf.add(df, new ByteArraySupplier(initialContent)); | 97 cf.add(df, new ByteArraySupplier(initialContent)); |
97 String comment = "commit 1"; | 98 String comment = "commit 1"; |
98 Nodeid c1Rev = cf.commit(comment); | 99 Nodeid c1Rev = cf.commit(comment); |
123 final int parentCsetRevIndex = hgRepo.getChangelog().getLastRevision(); | 124 final int parentCsetRevIndex = hgRepo.getChangelog().getLastRevision(); |
124 HgChangeset parentCset = new HgLogCommand(hgRepo).range(parentCsetRevIndex, parentCsetRevIndex).execute().get(0); | 125 HgChangeset parentCset = new HgLogCommand(hgRepo).range(parentCsetRevIndex, parentCsetRevIndex).execute().get(0); |
125 assertEquals("[sanity]", DEFAULT_BRANCH_NAME, parentCset.getBranch()); | 126 assertEquals("[sanity]", DEFAULT_BRANCH_NAME, parentCset.getBranch()); |
126 // | 127 // |
127 RepoUtils.modifyFileAppend(fileD, "A CHANGE\n"); | 128 RepoUtils.modifyFileAppend(fileD, "A CHANGE\n"); |
128 CommitFacility cf = new CommitFacility(hgRepo, parentCsetRevIndex); | 129 CommitFacility cf = new CommitFacility(Internals.getInstance(hgRepo), parentCsetRevIndex); |
129 FileContentSupplier contentProvider = new FileContentSupplier(fileD); | 130 FileContentSupplier contentProvider = new FileContentSupplier(fileD); |
130 cf.add(dfD, contentProvider); | 131 cf.add(dfD, contentProvider); |
131 cf.branch("branch1"); | 132 cf.branch("branch1"); |
132 Nodeid commitRev1 = cf.commit("FIRST"); | 133 Nodeid commitRev1 = cf.commit("FIRST"); |
133 contentProvider.done(); | 134 contentProvider.done(); |
153 HgRepository hgRepo = new HgLookup().detect(repoLoc); | 154 HgRepository hgRepo = new HgLookup().detect(repoLoc); |
154 assertTrue("[sanity]", hgRepo.getFileNode("d").exists()); | 155 assertTrue("[sanity]", hgRepo.getFileNode("d").exists()); |
155 assertTrue("[sanity]", new File(repoLoc, "d").canRead()); | 156 assertTrue("[sanity]", new File(repoLoc, "d").canRead()); |
156 RepoUtils.createFile(new File(repoLoc, "xx"), "xyz"); | 157 RepoUtils.createFile(new File(repoLoc, "xx"), "xyz"); |
157 new HgAddRemoveCommand(hgRepo).add(Path.create("xx")).remove(Path.create("d")).execute(); | 158 new HgAddRemoveCommand(hgRepo).add(Path.create("xx")).remove(Path.create("d")).execute(); |
158 CommitFacility cf = new CommitFacility(hgRepo, hgRepo.getChangelog().getLastRevision()); | 159 CommitFacility cf = new CommitFacility(Internals.getInstance(hgRepo), hgRepo.getChangelog().getLastRevision()); |
159 FileContentSupplier contentProvider = new FileContentSupplier(new File(repoLoc, "xx")); | 160 FileContentSupplier contentProvider = new FileContentSupplier(new File(repoLoc, "xx")); |
160 cf.add(hgRepo.getFileNode("xx"), contentProvider); | 161 cf.add(hgRepo.getFileNode("xx"), contentProvider); |
161 cf.forget(hgRepo.getFileNode("d")); | 162 cf.forget(hgRepo.getFileNode("d")); |
162 Nodeid commitRev = cf.commit("Commit with add/remove cmd"); | 163 Nodeid commitRev = cf.commit("Commit with add/remove cmd"); |
163 contentProvider.done(); | 164 contentProvider.done(); |
189 File fileD = new File(repoLoc, "d"); | 190 File fileD = new File(repoLoc, "d"); |
190 assertTrue("[sanity]", fileD.canRead()); | 191 assertTrue("[sanity]", fileD.canRead()); |
191 // | 192 // |
192 RepoUtils.modifyFileAppend(fileD, " 1 \n"); | 193 RepoUtils.modifyFileAppend(fileD, " 1 \n"); |
193 final int parentCsetRevIndex = hgRepo.getChangelog().getLastRevision(); | 194 final int parentCsetRevIndex = hgRepo.getChangelog().getLastRevision(); |
194 CommitFacility cf = new CommitFacility(hgRepo, parentCsetRevIndex); | 195 CommitFacility cf = new CommitFacility(Internals.getInstance(hgRepo), parentCsetRevIndex); |
195 FileContentSupplier contentProvider = new FileContentSupplier(fileD); | 196 FileContentSupplier contentProvider = new FileContentSupplier(fileD); |
196 cf.add(dfD, contentProvider); | 197 cf.add(dfD, contentProvider); |
197 cf.branch("branch1"); | 198 cf.branch("branch1"); |
198 Nodeid commitRev1 = cf.commit("FIRST"); | 199 Nodeid commitRev1 = cf.commit("FIRST"); |
199 contentProvider.done(); | 200 contentProvider.done(); |