def test_180_Revert_modified(self): # Get the contents of file.txt with open(self._test_file('file.txt'), 'r') as f: original_contents = f.read() # Replace it's contents with open(self._test_file('file.txt'), "w") as out: out.write("Only one line of content\n") # Get the status status = self.repo.hg_status() self.assertEquals(status, hgapi.Status(modified=['file.txt'])) # Get the modified contents and check with open(self._test_file('file.txt'), 'r') as f: modified_contents = f.read() self.assertEqual(modified_contents, "Only one line of content\n") # Revert and check again self.repo.hg_revert(all=True) # Should have created file.txt.orig self.assertTrue(os.path.exists(self._test_file('file.txt.orig'))) # Check the contents of file.txt with open(self._test_file('file.txt'), 'r') as f: reverted_contents = f.read() self.assertEqual(reverted_contents, original_contents) # Remove file.txt.orig os.unlink(self._test_file('file.txt.orig'))
def test_140_MissingStatus(self): #Commit file created in 120 self.repo.hg_commit("Added file") import os os.unlink(self._test_file('file2.txt')) status = self.repo.hg_status() self.assertEquals(status, hgapi.Status(missing=['file2.txt']))
def test_182_Revert_removed(self): # Remove file.txt self.repo.hg_remove("file.txt") # file.txt should be gone self.assertFalse(os.path.exists(self._test_file('file.txt'))) # Check the status status = self.repo.hg_status() self.assertEquals(status, hgapi.Status(removed=['file.txt'])) # Revert and check again self.repo.hg_revert(all=True) # file.txt should be back self.assertTrue(os.path.exists(self._test_file('file.txt'))) # Check the status status = self.repo.hg_status() self.assertEquals(status, hgapi.Status())
def test_181_Revert_added(self): # Add a new file with open(self._test_file('file_added.txt'), "w") as out: out.write("Added content\n") self.repo.hg_add('file_added.txt') # Get the status status = self.repo.hg_status() self.assertEquals(status, hgapi.Status(added=['file_added.txt'])) with open(self._test_file('file_added.txt'), 'r') as f: new_contents = f.read() self.assertEqual(new_contents, "Added content\n") # Revert and check again self.repo.hg_revert(all=True) # file_added.txt should still exist self.assertTrue(os.path.exists(self._test_file('file_added.txt'))) os.unlink(self._test_file('file_added.txt'))
def test_160_EmptyStatus(self): self.repo.hg_revert(all=True) status = self.repo.hg_status() self.assertEquals(status, hgapi.Status())
def test_150_RemovedStatus(self): #Remove file from repo self.repo.hg_remove("file2.txt") status = self.repo.hg_status() self.assertEquals(status, hgapi.Status(removed=['file2.txt']))
def test_130_AddedStatus(self): #Add file created in 110 self.repo.hg_add("file2.txt") status = self.repo.hg_status() self.assertEquals(status, hgapi.Status(added=['file2.txt']))
def test_120_UntrackedStatus(self): #Create a new file with open(self._test_file('file2.txt'), "w") as out: out.write("stuff stuff stuff") status = self.repo.hg_status() self.assertEquals(status, hgapi.Status(untracked=['file2.txt']))
def test_110_CleanStatus(self): #commit file created in 090 self.repo.hg_commit("Comitting changes", user="******") #Assert status is empty self.assertEquals(self.repo.hg_status(), hgapi.Status())
def test_100_ModifiedStatus(self): #write some more to file with open(self._test_file('file.txt'), "a") as out: out.write("stuff stuff stuff\n") status = self.repo.hg_status() self.assertEquals(status, hgapi.Status(modified=['file.txt']))