Mercurial > hg4j
comparison test/org/tmatesoft/hg/test/TestCommit.java @ 624:507602cb4fb3
FIXMEs and TODOs: pay some technical debt
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Mon, 20 May 2013 20:34:33 +0200 |
parents | fedc54356091 |
children | 5afc7eedb3dd |
comparison
equal
deleted
inserted
replaced
623:fedc54356091 | 624:507602cb4fb3 |
---|---|
73 RepoUtils.createFile(new File(repoLoc, "file1"), "hello\n"); | 73 RepoUtils.createFile(new File(repoLoc, "file1"), "hello\n"); |
74 new ExecHelper(new OutputParser.Stub(), repoLoc).run("hg", "commit", "--addremove", "-m", "FIRST"); | 74 new ExecHelper(new OutputParser.Stub(), repoLoc).run("hg", "commit", "--addremove", "-m", "FIRST"); |
75 // | 75 // |
76 HgRepository hgRepo = new HgLookup().detect(repoLoc); | 76 HgRepository hgRepo = new HgLookup().detect(repoLoc); |
77 CommitFacility cf = new CommitFacility(Internals.getInstance(hgRepo), 0); | 77 CommitFacility cf = new CommitFacility(Internals.getInstance(hgRepo), 0); |
78 // FIXME test diff for processing changed newlines (ie \r\n -> \n or vice verse) - if a whole line or | |
79 // just changed endings are in the patch! | |
80 HgDataFile df = hgRepo.getFileNode("file1"); | 78 HgDataFile df = hgRepo.getFileNode("file1"); |
81 cf.add(df, new ByteArrayDataSource("hello\nworld".getBytes())); | 79 cf.add(df, new ByteArrayDataSource("hello\nworld".getBytes())); |
82 Transaction tr = newTransaction(hgRepo); | 80 Transaction tr = newTransaction(hgRepo); |
83 Nodeid secondRev = cf.commit("SECOND", tr); | 81 Nodeid secondRev = cf.commit("SECOND", tr); |
84 tr.commit(); | 82 tr.commit(); |
315 errorCollector.assertEquals(c, hgRepo.getBookmarks().getRevision(activeBookmark)); | 313 errorCollector.assertEquals(c, hgRepo.getBookmarks().getRevision(activeBookmark)); |
316 // reload repo, and repeat the check | 314 // reload repo, and repeat the check |
317 hgRepo = new HgLookup().detect(repoLoc); | 315 hgRepo = new HgLookup().detect(repoLoc); |
318 errorCollector.assertEquals(activeBookmark, hgRepo.getBookmarks().getActiveBookmarkName()); | 316 errorCollector.assertEquals(activeBookmark, hgRepo.getBookmarks().getActiveBookmarkName()); |
319 errorCollector.assertEquals(c, hgRepo.getBookmarks().getRevision(activeBookmark)); | 317 errorCollector.assertEquals(c, hgRepo.getBookmarks().getRevision(activeBookmark)); |
318 } | |
319 | |
320 /** | |
321 * from the wiki: | |
322 * "active bookmarks are automatically updated when committing to the changeset they are pointing to" | |
323 * Synopsis: commit 1 (c1), hg bookmark active (points to commit1), make commit 2, hg bookmark -f -r c1 active, commit 3, check active still points to c1 | |
324 */ | |
325 @Test | |
326 public void testNoBookmarkUpdate() throws Exception { | |
327 File repoLoc = RepoUtils.cloneRepoToTempLocation("log-1", "test-no-bookmark-upd", false); | |
328 HgRepository hgRepo = new HgLookup().detect(repoLoc); | |
329 assertNull("[sanity]", hgRepo.getBookmarks().getActiveBookmarkName()); | |
330 ExecHelper eh = new ExecHelper(new OutputParser.Stub(), repoLoc); | |
331 String activeBookmark = "bm1"; | |
332 eh.run("hg", "bookmarks", activeBookmark); | |
333 assertEquals("Bookmarks has to reload", activeBookmark, hgRepo.getBookmarks().getActiveBookmarkName()); | |
334 Nodeid initialBookmarkRevision = hgRepo.getBookmarks().getRevision(activeBookmark); // c1 | |
335 assertEquals("[sanity]", initialBookmarkRevision, hgRepo.getWorkingCopyParents().first()); | |
336 | |
337 File fileD = new File(repoLoc, "d"); | |
338 assertTrue("[sanity]", fileD.canRead()); | |
339 RepoUtils.modifyFileAppend(fileD, " 1 \n"); | |
340 HgCommitCommand cmd = new HgCommitCommand(hgRepo).message("FIRST"); | |
341 Outcome r = cmd.execute(); | |
342 errorCollector.assertTrue(r.isOk()); | |
343 Nodeid c2 = cmd.getCommittedRevision(); | |
344 errorCollector.assertEquals(c2, hgRepo.getBookmarks().getRevision(activeBookmark)); | |
345 // | |
346 eh.run("hg", "bookmark", activeBookmark, "--force", "--rev", initialBookmarkRevision.toString()); | |
347 // | |
348 RepoUtils.modifyFileAppend(fileD, " 2 \n"); | |
349 cmd = new HgCommitCommand(hgRepo).message("SECOND"); | |
350 r = cmd.execute(); | |
351 errorCollector.assertTrue(r.isOk()); | |
352 //Nodeid c3 = cmd.getCommittedRevision(); | |
353 errorCollector.assertEquals(initialBookmarkRevision, hgRepo.getBookmarks().getRevision(activeBookmark)); | |
320 } | 354 } |
321 | 355 |
322 @Test | 356 @Test |
323 public void testRefreshTagsAndBranches() throws Exception { | 357 public void testRefreshTagsAndBranches() throws Exception { |
324 File repoLoc = RepoUtils.cloneRepoToTempLocation("log-branches", "test-refresh-after-commit", false); | 358 File repoLoc = RepoUtils.cloneRepoToTempLocation("log-branches", "test-refresh-after-commit", false); |