当前位置: 首页>>代码示例>>Python>>正文


Python hglibext.open函数代码示例

本文整理汇总了Python中repoman.hg.hglibext.open函数的典型用法代码示例。如果您正苦于以下问题:Python open函数的具体用法?Python open怎么用?Python open使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了open函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_branch

    def test_branch(self):
        repo = Repository(self.main_repo)
        repo.branch("new-branch")
        hgrepo = hglib.open(self.main_repo)
        self.assertEquals(hgrepo.branch(), "new-branch")
        hgrepo.close()

        # this does not throw exception, even though the branch already exists,
        # because it is forced
        repo.branch(INITIAL_BRANCH)

        hgrepo = hglib.open(self.main_repo)
        self.assertEquals(hgrepo.branch(), INITIAL_BRANCH)
        hgrepo.close()
开发者ID:angelnan,项目名称:python-repoman,代码行数:14,代码来源:test_hgrepository.py

示例2: _get_tag_changeset

    def _get_tag_changeset(self, tag_name):
        """
        Gets the changeset that correspond to the given tag

        :param tag_name: name of the tag
        :type string
        """
        with hglib.open(self.path) as repo:
            try:
                repo = hglib.open(self.path)
                rev = [t[2] for t in repo.tags() if t[0] == tag_name][0]
                return self._new_changeset_object(self[rev])
            except (IndexError, hglib.error.CommandError) as e:
                logger.exception("Eror getting tag '%s': %s" % (tag_name, e))
                raise RepositoryError(e)
开发者ID:oscarsj,项目名称:python-repoman,代码行数:15,代码来源:repository.py

示例3: test_commit_commits_all

    def test_commit_commits_all(self):
        repo = hglib.open(self.main_repo)

        file_name = "f1"
        file_path = os.path.join(self.main_repo, file_name)
        expected_content = "changed content"
        with open(file_path, "w+") as file:
            file.write("foo test content")
        commit_msg = "Test message"
        repo.add(file_path)
        repo.commit('Creating file', user="foo")
        with open(file_path, "w+") as file:
            file.write(expected_content)

        repository = Repository(self.main_repo)
        repository.commit(commit_msg)

        with open(file_path, "w+") as file:
            file.write('content changed again')

        repo.update(clean=True)

        with open(file_path) as file:
            self.assertEquals(expected_content, file.read())

        repo.close()
开发者ID:angelnan,项目名称:python-repoman,代码行数:26,代码来源:test_hgrepository.py

示例4: set_source

    def set_source(self, path, source):
        """ Inherited method
        :func:`~repoman.depot_operations.DepotOperations.set_source`
        """
        try:
            with hglib.open(path) as dep:
                paths = dep.paths()
        except (hglib.util.error.ServerError,
                hglib.util.error.CommandError,
                hglib.error.ResponseError) as e:
            logger.exception('Error getting depot paths %s: %s' % (path, e))
            raise e

        if not paths or "default" not in paths or paths["default"] != source:
            hgrc_path = os.path.join(path, ".hg/hgrc")
            already_exists = os.path.exists(hgrc_path)
            with open(hgrc_path, 'r+' if already_exists else 'w') as hgrc:
                if already_exists:
                    prev_content = hgrc.read()
                    prev_has_path = re.search("default=.*($|\\n)",
                                              prev_content, re.MULTILINE)
                    if prev_has_path:
                        new_content = re.sub(
                            "default=.*($|\\n)",
                            "default=%s\n" % source, prev_content)
                    else:
                        new_content = "%s\n[paths]\ndefault=%s\n" % (
                            prev_content, source)
                else:
                    new_content = "[paths]\ndefault=%s\n" % source
                logger.debug(
                    "Setting default source in %s hgrc: %s"
                    % (path, new_content))
                hgrc.write(new_content)
开发者ID:oscarsj,项目名称:python-repoman,代码行数:34,代码来源:depot_operations.py

示例5: check_changeset_availability

    def check_changeset_availability(self, path, changesets):
        """ Inherited method
        :func:`~repoman.depot_operations.DepotOperations.check_changeset_availability`
        """
        missing = []
        try:
            with hglib.open(path) as dep:
                branches = dep.branches()
                for changeset in changesets:
                    try:
                        if changeset != 'tip':
                            isbranch = any(x[0] == changeset for x in branches)
                            if isbranch:
                                missing.append(changeset)
                            else:
                                log = dep.log(revrange=changeset)
                                if not log:
                                    missing.append(changeset)
                        else:
                            missing.append('tip')

                    except:
                        missing.append(changeset)
                logger.debug(
                    'Checking availability of changesets in %s: Missing %s' % (
                        path, "'".join(missing)))
        except (hglib.util.error.CommandError, hglib.error.ResponseError) as e:
            logger.exception(
                'Error in check_changeset_availability method: %s' % e)
        return missing
开发者ID:oscarsj,项目名称:python-repoman,代码行数:30,代码来源:depot_operations.py

示例6: test_get_ancestor

    def test_get_ancestor(self):
        repo_main = hglib.open(self.main_repo)
        orig_rev = repo_main.tip()
        commits_integration = ['commit in integration',
                               'another extra commit in integration']
        self.commit_in_repo(self.main_repo, ['f1', 'f2'], commits_integration)
        rev1 = repo_main.tip()
        repo_main.update(rev="tip~%i" % len(commits_integration))
        repo_main.branch("other-branch")
        commits = ['commit in other-branch',
                   'another extra commit in other-branch']
        self.commit_in_repo(self.main_repo, ['f3', 'f2'], commits)
        rev2 = repo_main.tip()
        repo_main.update(rev=orig_rev[1])

        repo = Repository(self.main_repo)
        ancestor = repo.get_ancestor(repo[rev1[1]], repo[rev2[1]])

        self.assertEquals(ancestor.hash, orig_rev[1])
        repo_main.close()

        with self.assertRaises(RepositoryError):
            repo.get_ancestor(None, repo[rev2[1]])

        with self.assertRaises(RepositoryError):
            repo.get_ancestor(repo["bad_revision"], repo["another"])
开发者ID:angelnan,项目名称:python-repoman,代码行数:26,代码来源:test_hgrepository.py

示例7: test___str__

 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])
开发者ID:angelnan,项目名称:python-repoman,代码行数:7,代码来源:test_changeset_hg.py

示例8: test_merge

    def test_merge(self):
        repo = hglib.open(self.main_repo)
        repository = Repository(self.main_repo)
        orig_rev = repo.tip()[1]
        commits = ['extra commit', '#INT-00 another extra commit']
        self.commit_in_repo(self.main_repo, ['f1', 'f2'], commits)
        new_rev = repository[repo.tip()[1]]
        repo.update(rev=orig_rev)
        self.commit_in_repo(
            self.main_repo,
            ['f3', ' f4'],
            [
                'extra commit in another branch',
                'another extra commit in another branch'
            ])
        third_revision = repository[repo.tip()[1]]

        # need to commit, return true
        repository.merge(other_rev=new_rev)
        cs = repository["tip"]
        self.assertEquals(len(cs.parents), 2)
        repo.update(third_revision, clean=True)
        self.commit_in_repo(
            self.main_repo, ['f1', 'f2'],
            ['this should conflict', 'this should conflict too'])
        # conflicts
        with self.assertRaises(RepositoryError):
            repository.merge(new_rev)

        with self.assertRaises(RepositoryError):
            # this calls send_mail, what raises exception
            # TODO: use stubs
            repository.merge("wrong_revision")
        repo.close()
开发者ID:angelnan,项目名称:python-repoman,代码行数:34,代码来源:test_hgrepository.py

示例9: terminate_branch

    def terminate_branch(self, branch_name, signature, repo_origin, repo_dest):
        """ Inherited method
        :func:`~repoman.repository.Repository.terminate_branch`
        """
        repo = None
        try:
            with hglib.open(self.path) as repo:
                try:
                    repo.pull(repo_origin, branch=branch_name)
                except hglib.error.CommandError:
                    # Ignore this error, the branch could be only local thus
                    # the pull can safely fail
                    pass
                repo.update(branch_name, clean=True)
                repo.commit(
                    message=str(self.message_builder.close_branch(
                        branch=branch_name
                    )),
                    user=signature.user,
                    closebranch=True)

                parents = repo.parents()
                self.push(repo_origin, repo_dest,
                          self._new_changeset_object(parents[0]))
        except hglib.error.CommandError as e:
            if 'can only close branch heads' in e.err:
                logger.exception(
                    "Cannot close %s branch, it's already closed" %
                    branch_name)
                return
            logger.exception("Error closing the release branch %s: %s" % (
                branch_name, e))
            raise RepositoryError(e)
开发者ID:oscarsj,项目名称:python-repoman,代码行数:33,代码来源:repository.py

示例10: test_update

    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)
开发者ID:angelnan,项目名称:python-repoman,代码行数:7,代码来源:test_hgrepository.py

示例11: test_create_branch

 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()
开发者ID:angelnan,项目名称:python-repoman,代码行数:9,代码来源:test_changeset_hg.py

示例12: test_get_changeset_tags

 def test_get_changeset_tags(self):
     hgrepo = hglib.open(self.main_repo)
     hgrepo.update()
     rev = hgrepo.tip().node
     hgrepo.tag("test_tag", rev=rev, user='fake_user')
     hgrepo.tag("test_tag2", rev=rev, user='fake_user')
     repo = Repository(self.main_repo)
     tags = repo.get_changeset_tags(rev)
     self.assertListEqual(tags, ["test_tag", "test_tag2"])
     hgrepo.close()
开发者ID:angelnan,项目名称:python-repoman,代码行数:10,代码来源:test_hgrepository.py

示例13: parents

 def parents(self, repo):
     """ Inherited method
     :func:`~repoman.repository.Repository.parents`
     """
     repo = hglib.open(self.path)
     try:
         return [self._new_changeset_object(cs) for cs in repo.parents()]
     except TypeError:
         raise RepositoryError("Working copy for repo %s has no parents "
                               "(is it bare?)" % self.path)
开发者ID:oscarsj,项目名称:python-repoman,代码行数:10,代码来源:repository.py

示例14: test_strip

 def test_strip(self):
     hgrepo = hglib.open(self.main_repo)
     hgrepo.update(rev=INITIAL_BRANCH)
     rev = self.commit_in_repo(self.main_repo, ['f199'],
                               ['extra commit'])[1]
     repo = Repository(self.main_repo)
     repo.strip(repo[rev])
     with self.assertRaises(hglib.error.CommandError):
         hgrepo.log(revrange=rev)
     hgrepo.close()
开发者ID:angelnan,项目名称:python-repoman,代码行数:10,代码来源:test_hgrepository.py

示例15: test_get_branch_tip

    def test_get_branch_tip(self):
        repo = hglib.open(self.main_repo)
        branch = repo.branch()
        tip = repo.log(branch=branch, limit=1)[0][1]
        repo.close()
        repository = Repository(self.main_repo)
        self.assertEquals(repository.get_branch_tip(branch).hash, tip)

        with self.assertRaises(RepositoryError):
            repository.get_branch_tip("inexistent_branch")
开发者ID:angelnan,项目名称:python-repoman,代码行数:10,代码来源:test_hgrepository.py


注:本文中的repoman.hg.hglibext.open函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。