Mercurial > hg4j
comparison test/org/tmatesoft/hg/test/TestCommit.java @ 605:c56edf42be64
Commit: update active bookmark with new revision
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Mon, 06 May 2013 20:28:21 +0200 |
parents | e447384f3771 |
children | 66f1cc23b906 |
comparison
equal
deleted
inserted
replaced
604:c3505001a42a | 605:c56edf42be64 |
---|---|
275 errorCollector.assertEquals(csets.get(0).getComment(), "FIRST"); | 275 errorCollector.assertEquals(csets.get(0).getComment(), "FIRST"); |
276 errorCollector.assertEquals(csets.get(1).getComment(), "SECOND"); | 276 errorCollector.assertEquals(csets.get(1).getComment(), "SECOND"); |
277 assertHgVerifyOk(repoLoc); | 277 assertHgVerifyOk(repoLoc); |
278 } | 278 } |
279 | 279 |
280 @Test | |
281 public void testUpdateActiveBookmark() throws Exception { | |
282 File repoLoc = RepoUtils.cloneRepoToTempLocation("log-1", "test-commit-cmd", false); | |
283 ExecHelper eh = new ExecHelper(new OutputParser.Stub(), repoLoc); | |
284 String activeBookmark = "bm1"; | |
285 eh.run("hg", "bookmarks", activeBookmark); | |
286 | |
287 HgRepository hgRepo = new HgLookup().detect(repoLoc); | |
288 assertEquals("[sanity]", activeBookmark, hgRepo.getBookmarks().getActiveBookmarkName()); | |
289 Nodeid activeBookmarkRevision = hgRepo.getBookmarks().getRevision(activeBookmark); | |
290 assertEquals("[sanity]", activeBookmarkRevision, hgRepo.getWorkingCopyParents().first()); | |
291 | |
292 HgDataFile dfD = hgRepo.getFileNode("d"); | |
293 File fileD = new File(repoLoc, "d"); | |
294 assertTrue("[sanity]", dfD.exists()); | |
295 assertTrue("[sanity]", fileD.canRead()); | |
296 | |
297 RepoUtils.modifyFileAppend(fileD, " 1 \n"); | |
298 HgCommitCommand cmd = new HgCommitCommand(hgRepo).message("FIRST"); | |
299 Outcome r = cmd.execute(); | |
300 errorCollector.assertTrue(r.isOk()); | |
301 Nodeid c = cmd.getCommittedRevision(); | |
302 | |
303 errorCollector.assertEquals(activeBookmark, hgRepo.getBookmarks().getActiveBookmarkName()); | |
304 errorCollector.assertEquals(c, hgRepo.getBookmarks().getRevision(activeBookmark)); | |
305 // reload repo, and repeat the check | |
306 hgRepo = new HgLookup().detect(repoLoc); | |
307 errorCollector.assertEquals(activeBookmark, hgRepo.getBookmarks().getActiveBookmarkName()); | |
308 errorCollector.assertEquals(c, hgRepo.getBookmarks().getRevision(activeBookmark)); | |
309 } | |
310 | |
280 private void assertHgVerifyOk(File repoLoc) throws InterruptedException, IOException { | 311 private void assertHgVerifyOk(File repoLoc) throws InterruptedException, IOException { |
281 ExecHelper verifyRun = new ExecHelper(new OutputParser.Stub(), repoLoc); | 312 ExecHelper verifyRun = new ExecHelper(new OutputParser.Stub(), repoLoc); |
282 verifyRun.run("hg", "verify"); | 313 verifyRun.run("hg", "verify"); |
283 errorCollector.assertEquals("hg verify", 0, verifyRun.getExitValue()); | 314 errorCollector.assertEquals("hg verify", 0, verifyRun.getExitValue()); |
284 } | 315 } |