def test___str__(self):
     clon = hglib.open(os.path.join(self.environment_path, 'repo1'))
     clon.update('default')
     hgrepo = Repository(os.path.join(self.environment_path, 'repo1'))
     hgcs = Changeset(hgrepo, clon.tip())
     self.assertEquals(hgcs.__str__(),
                       clon.tip().node[:Changeset.SHORT_HASH_COUNT])
 def test___str__(self):
     clon = hglib.open(os.path.join(self.environment_path, 'repo1'))
     clon.update('default')
     hgrepo = Repository(os.path.join(self.environment_path, 'repo1'))
     hgcs = Changeset(hgrepo, clon.tip())
     self.assertEquals(
         hgcs.__str__(), clon.tip().node[:Changeset.SHORT_HASH_COUNT])
 def test_create_branch(self):
     clon = hglib.open(os.path.join(self.environment_path, 'repo1'))
     clon.update('default')
     hgrepo = Repository(os.path.join(self.environment_path, 'repo1'))
     hgcs = Changeset(hgrepo, clon.tip())
     branch = hgcs.create_branch('fakebranch')
     self.assertEquals(branch.get_changeset(), hgrepo.tip())
     self.assertEquals('fakebranch', clon.branch())
     clon.close()
 def test_create_branch(self):
     clon = hglib.open(os.path.join(self.environment_path, 'repo1'))
     clon.update('default')
     hgrepo = Repository(os.path.join(self.environment_path, 'repo1'))
     hgcs = Changeset(hgrepo, clon.tip())
     branch = hgcs.create_branch('fakebranch')
     self.assertEquals(branch.get_changeset(), hgrepo.tip())
     self.assertEquals('fakebranch', clon.branch())
     clon.close()
示例#5
0
    def test_update(self):
        hgrepo = hglib.open(self.main_repo)
        tip = Changeset(None, hgrepo.tip())
        repo = Repository(self.main_repo)
        repo.update(tip)

        self.assertEquals(hgrepo.parents()[0].node, tip.hash)
示例#6
0
    def _new_changeset_object(self, changeset_info):
        """
        Return a new Changeset with the provided info

        :param changeset_info: data needed to build a Changeset object, it
               is a tuple that hglib returns
        :type tuple
        """
        return Changeset(self, changeset_info)
 def test_init(self):
     clon = hglib.open(os.path.join(self.environment_path, 'repo1'))
     hgrepo = Repository(os.path.join(self.environment_path, 'repo1'))
     hgcs = Changeset(hgrepo, clon.tip())
     clon.close()
     self.assertEquals(hgcs.author, "Jose Plana <*****@*****.**>")
     self.assertEquals(hgcs.hash,
                       "c377d40d21153bdcc4ec0b24bba48af3899fcc7c")
     self.assertEquals(hgcs.desc, "Second changeset")
     self.assertFalse(hgcs.merge)
     self.assertEquals(hgcs.parents[0].hash,
                       "b93d349f220d892047817f7ab29b2e8bfc5569ba")
示例#8
0
    def _new_changeset_object(self, refname):
        """
        Return a new Changeset object with the provided info
        """
        tags = ' '.join(self.get_changeset_tags(refname))
        info, body = self._git("log", "-1", "--pretty=%H,%ct,%cn%n%B",
                               refname).split("\n", 1)
        sha1, committer_time, committer_name = info.split(",", 2)

        initial_values = [
            None,  # Local changeset that does not exist in GIT
            sha1,
            tags,
            None,
            committer_name,
            body,
            datetime.datetime.utcfromtimestamp(float(committer_time)),
        ]

        c = Changeset(self, tuple(initial_values))
        return c
示例#9
0
    def test_push(self):
        repo = hglib.open(self.main_repo)
        repo.update(rev=INITIAL_BRANCH)
        self.commit_in_repo(self.main_repo, ['f1', 'f2'],
                            ['TICKET-10', 'TICKET-11'])
        self.commit_in_repo(self.second_repo, ['f3', 'f4'],
                            ['TICKET-12', 'TICKET-13'])

        repo2 = Repository(self.second_repo)

        with self.assertRaises(RepositoryError):
            repo2.push(
                self.main_repo, self.main_repo,
                Changeset(None, (1, "inexistent_rev", None, None, None, None)))

        with self.assertRaises(RepositoryError):
            repo2.push(self.main_repo, "inexistent_destination")

        repo2.push(self.main_repo, self.main_repo)

        logs = [changeset[5] for changeset in repo.log()]
        self.assertTrue('TICKET-10' in logs)
        self.assertTrue('TICKET-11' in logs)
        self.assertTrue('TICKET-12' in logs)
        self.assertTrue('TICKET-13' in logs)

        repo.update()
        self.commit_in_repo(self.main_repo, ['f3', 'f4'],
                            ['TICKET-10', 'TICKET-11'])
        self.commit_in_repo(self.second_repo, ['f3', 'f4'],
                            ['TICKET-12', 'TICKET-13'])

        repo.close()
        # now with conflicts
        with self.assertRaises(RepositoryError):
            repo2.push(self.main_repo, self.main_repo, repo2.tip())