• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python hg.mercurial函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: clone_branch

def clone_branch(branch, branch_url):
    """
    Clone tip of the specified branch.
    """
    remote = branch_url
    # Set up the clean repository if it doesn't exist,
    # otherwise, it will be updated.
    clean = os.path.join('clean')
    clean_repo = os.path.join(clean, branch)
    if not os.access(clean, os.F_OK):
        log_msg(os.getcwd())
        os.mkdir(clean)
    try:
        mercurial(remote, clean_repo)
    except subprocess.CalledProcessError as error:
        log_msg('[Clone] error cloning \'%s\' into clean repository:\n%s'
                % (remote, error))
        return None
    # Clone that clean repository to active and return that revision
    active = os.path.join('active')
    active_repo = os.path.join(active, branch)
    if not os.access(active, os.F_OK):
        os.mkdir(active)
    elif os.access(active_repo, os.F_OK):
        shutil.rmtree(active_repo)
    try:
        print 'Cloning from %s -----> %s' % (clean_repo, active_repo)
        revision = mercurial(clean_repo, active_repo)
        log_msg('[Clone] Cloned revision %s' %(revision), log.info)
    except subprocess.CalledProcessError as error:
        log_msg('[Clone] error cloning \'%s\' into active repository:\n%s'
                % (remote, error))
        return None

    return revision
开发者ID:lsblakk,项目名称:tools,代码行数:35,代码来源:hgpusher.py


示例2: testMercurialWithShareAndBundle

    def testMercurialWithShareAndBundle(self):
        # First create the bundle
        bundle = os.path.join(self.tmpdir, 'bundle')
        run_cmd(['hg', 'bundle', '-a', bundle], cwd=self.repodir)

        # Create a commit
        open(os.path.join(self.repodir, 'test.txt'), 'w').write('hello!')
        run_cmd(['hg', 'add', 'test.txt'], cwd=self.repodir)
        run_cmd(['hg', 'commit', '-m', 'adding changeset'], cwd=self.repodir)

        # Wrap unbundle so we can tell if it got called
        orig_unbundle = unbundle
        try:
            called = []

            def new_unbundle(*args, **kwargs):
                called.append(True)
                return orig_unbundle(*args, **kwargs)
            hg.unbundle = new_unbundle

            shareBase = os.path.join(self.tmpdir, 'share')
            sharerepo = os.path.join(shareBase, self.repodir.lstrip("/"))
            os.mkdir(shareBase)
            mercurial(
                self.repodir, self.wc, shareBase=shareBase, bundles=[bundle])

            self.assertEquals(called, [True])
            self.assertEquals(
                getRevisions(self.repodir), getRevisions(self.wc))
            self.assertEquals(
                getRevisions(self.repodir), getRevisions(sharerepo))
        finally:
            hg.unbundle = orig_unbundle
开发者ID:bdacode,项目名称:build-tools,代码行数:33,代码来源:test_util_hg.py


示例3: tagOtherRepo

def tagOtherRepo(config, repo, reponame, revision, pushAttempts):
    remote = make_hg_url(HG, repo)
    mercurial(remote, reponame)

    def tagRepo(repo, attempt, config, revision, tags):
        # set totalChangesets=1 because tag() generates exactly 1 commit
        totalChangesets = 1
        # update to the desired revision first, then to the tip of revision's
        # branch to avoid new head creation
        update(repo, revision=revision)
        update(repo)
        tag(repo, revision, tags, config['hgUsername'])
        outgoingRevs = retry(out, kwargs=dict(src=reponame, remote=remote,
                                              ssh_username=config[
                                                  'hgUsername'],
                                              ssh_key=config['hgSshKey']))
        if len(outgoingRevs) != totalChangesets:
            raise Exception("Wrong number of outgoing revisions")

    pushRepo = make_hg_url(HG, repo, protocol='ssh')

    def tag_wrapper(r, n):
        tagRepo(r, n, config, revision, tags)

    def cleanup_wrapper():
        cleanOutgoingRevs(reponame, pushRepo, config['hgUsername'],
                          config['hgSshKey'])
    retry(apply_and_push, cleanup=cleanup_wrapper,
          args=(reponame, pushRepo, tag_wrapper, pushAttempts),
          kwargs=dict(ssh_username=config['hgUsername'],
                      ssh_key=config['hgSshKey']))
开发者ID:SergiosLen,项目名称:browser-f,代码行数:31,代码来源:tag-release.py


示例4: clone_branch

def clone_branch(branch):
    """
    Clone the tip of the specified branch.
    """
    remote = '%s%s' % (config['hg_base_url'], branch)
    # Set up the local/clean repository if it doesn't exist,
    # otherwise, it will update.
    clean = 'clean/%s' % (branch)
    if not os.access('clean', os.F_OK):
        os.mkdir('clean')
    try:
        mercurial(remote, clean)
    except subprocess.CalledProcessError as error:
        log_msg('[Clone] error cloning \'%s\' into local repository :\n%s'
                %(remote,error))
        return None
    # Clone that local repository and return that revision
    active = 'active/%s' % (branch)
    if not os.access('active', os.F_OK):
        os.mkdir('active')
    elif os.access(active, os.F_OK):
        shutil.rmtree(active)
    try:
        revision = mercurial(clean, active)
        log_msg('[Clone] Cloned revision %s' % (revision))
    except subprocess.CalledProcessError as error:
        log_msg('[Clone] error cloning \'%s\' into active repository :\n%s'
                %(remote,error))
        return None

    return revision
开发者ID:mjessome,项目名称:tools,代码行数:31,代码来源:hgpusher.py


示例5: testMercurialWithNewShare

 def testMercurialWithNewShare(self):
     shareBase = os.path.join(self.tmpdir, 'share')
     sharerepo = os.path.join(shareBase, self.repodir.lstrip("/"))
     os.mkdir(shareBase)
     mercurial(self.repodir, self.wc, shareBase=shareBase)
     self.assertEquals(getRevisions(self.repodir), getRevisions(self.wc))
     self.assertEquals(getRevisions(self.repodir), getRevisions(sharerepo))
开发者ID:bdacode,项目名称:build-tools,代码行数:7,代码来源:test_util_hg.py


示例6: testMercurialChangeRepo

    def testMercurialChangeRepo(self):
        # Create a new repo
        old_env = os.environ.copy()
        if 'HG_SHARE_BASE_DIR' in os.environ:
            del os.environ['HG_SHARE_BASE_DIR']

        try:
            repo2 = os.path.join(self.tmpdir, 'repo2')
            run_cmd(['%s/init_hgrepo.sh' % os.path.dirname(__file__), repo2])

            self.assertNotEqual(self.revisions, getRevisions(repo2))

            # Clone the original repo
            mercurial(self.repodir, self.wc)
            self.assertEquals(getRevisions(self.wc), self.revisions)
            open(os.path.join(self.wc, 'test.txt'), 'w').write("hello!")

            # Clone the new one
            mercurial(repo2, self.wc)
            self.assertEquals(getRevisions(self.wc), getRevisions(repo2))
            # Make sure our local file went away
            self.failUnless(
                not os.path.exists(os.path.join(self.wc, 'test.txt')))
        finally:
            os.environ.clear()
            os.environ.update(old_env)
开发者ID:bdacode,项目名称:build-tools,代码行数:26,代码来源:test_util_hg.py


示例7: testMercurialWithShareAndBundle

    def testMercurialWithShareAndBundle(self):
        # First create the bundle
        bundle = os.path.join(self.tmpdir, "bundle")
        run_cmd(["hg", "bundle", "-a", bundle], cwd=self.repodir)

        # Create a commit
        open(os.path.join(self.repodir, "test.txt"), "w").write("hello!")
        run_cmd(["hg", "add", "test.txt"], cwd=self.repodir)
        run_cmd(["hg", "commit", "-m", "adding changeset"], cwd=self.repodir)

        # Wrap unbundle so we can tell if it got called
        orig_unbundle = unbundle
        try:
            called = []

            def new_unbundle(*args, **kwargs):
                called.append(True)
                return orig_unbundle(*args, **kwargs)

            hg.unbundle = new_unbundle

            shareBase = os.path.join(self.tmpdir, "share")
            sharerepo = os.path.join(shareBase, self.repodir.lstrip("/"))
            os.mkdir(shareBase)
            mercurial(self.repodir, self.wc, shareBase=shareBase, bundles=[bundle])

            self.assertEquals(called, [True])
            self.assertEquals(getRevisions(self.repodir), getRevisions(self.wc))
            self.assertEquals(getRevisions(self.repodir), getRevisions(sharerepo))
        finally:
            hg.unbundle = orig_unbundle
开发者ID:B-Rich,项目名称:build-tools,代码行数:31,代码来源:test_util_hg.py


示例8: testOutofSyncMirrorFailingMaster

    def testOutofSyncMirrorFailingMaster(self):
        # First create the mirror
        mirror = os.path.join(self.tmpdir, "repo2")
        clone(self.repodir, mirror)

        shareBase = os.path.join(self.tmpdir, "share")
        os.mkdir(shareBase)
        mercurial(self.repodir, self.wc, shareBase=shareBase, mirrors=[mirror])

        # Create a bundle
        bundle = os.path.join(self.tmpdir, "bundle")
        run_cmd(["hg", "bundle", "-a", bundle], cwd=self.repodir)

        # Move our repodir out of the way so that pulling/cloning from it fails
        os.rename(self.repodir, self.repodir + "-bad")

        # Try and update to a non-existent revision using our mirror and
        # bundle, with the master failing. We should fail
        self.assertRaises(
            subprocess.CalledProcessError,
            mercurial,
            self.repodir,
            self.wc,
            shareBase=shareBase,
            mirrors=[mirror],
            bundles=[bundle],
            revision="1234567890",
        )
开发者ID:B-Rich,项目名称:build-tools,代码行数:28,代码来源:test_util_hg.py


示例9: testMercurialSkipPull

    def testMercurialSkipPull(self):
        # Clone once into our working copy
        mercurial(self.repodir, self.wc)

        # The second clone should avoid calling pull()
        with patch('util.hg.pull') as patched_pull:
            mercurial(self.repodir, self.wc, revision=self.revisions[-1])
            self.assertEquals(patched_pull.call_count, 0)
开发者ID:MihaiTabara,项目名称:build-tools,代码行数:8,代码来源:test_util_hg.py


示例10: testMercurialUpdateRev

    def testMercurialUpdateRev(self):
        rev = mercurial(self.repodir, self.wc, revision=self.revisions[-1])
        self.assertEquals(rev, self.revisions[-1])
        open(os.path.join(self.wc, 'test.txt'), 'w').write("hello!")

        rev = mercurial(self.repodir, self.wc, revision=self.revisions[0])
        self.assertEquals(rev, self.revisions[0])
        # Make sure our local file didn't go away
        self.failUnless(os.path.exists(os.path.join(self.wc, 'test.txt')))
开发者ID:bdacode,项目名称:build-tools,代码行数:9,代码来源:test_util_hg.py


示例11: tagRepo

def tagRepo(config, repo, reponame, revision, tags, bumpFiles, relbranch,
            pushAttempts, defaultBranch='default'):
    remote = make_hg_url(HG, repo)
    mercurial(remote, reponame)

    def bump_and_tag(repo, attempt, config, relbranch, revision, tags,
                     defaultBranch):
        # set relbranchChangesets=1 because tag() generates exactly 1 commit
        relbranchChangesets = 1
        defaultBranchChangesets = 0

        if relbranch in get_branches(reponame):
            update(reponame, revision=relbranch)
        else:
            update(reponame, revision=revision)
            run_cmd(['hg', 'branch', relbranch], cwd=reponame)

        if len(bumpFiles) > 0:
            # Bump files on the relbranch, if necessary
            bump(reponame, bumpFiles, 'version')
            run_cmd(['hg', 'diff'], cwd=repo)
            try:
                get_output(['hg', 'commit', '-u', config['hgUsername'],
                            '-m', getBumpCommitMessage(config['productName'], config['version'])],
                           cwd=reponame)
                relbranchChangesets += 1
            except subprocess.CalledProcessError, e:
                # We only want to ignore exceptions caused by having nothing to
                # commit, which are OK. We still want to raise exceptions caused
                # by any other thing.
                if e.returncode != 1 or "nothing changed" not in e.output:
                    raise

        # We always want our tags pointing at the tip of the relbranch
        # so we need to grab the current revision after we've switched
        # branches and bumped versions.
        revision = get_revision(reponame)
        # Create the desired tags on the relbranch
        tag(repo, revision, tags, config['hgUsername'])

        # This is the bump of the version on the default branch
        # We do it after the other one in order to get the tip of the
        # repository back on default, thus avoiding confusion.
        if len(bumpFiles) > 0:
            update(reponame, revision=defaultBranch)
            bump(reponame, bumpFiles, 'nextVersion')
            run_cmd(['hg', 'diff'], cwd=repo)
            try:
                get_output(['hg', 'commit', '-u', config['hgUsername'],
                            '-m', getBumpCommitMessage(config['productName'], config['version'])],
                           cwd=reponame)
                defaultBranchChangesets += 1
            except subprocess.CalledProcessError, e:
                if e.returncode != 1 or "nothing changed" not in e.output:
                    raise
开发者ID:SergiosLen,项目名称:browser-f,代码行数:55,代码来源:tag-release.py


示例12: testMercurialWithExistingShare

 def testMercurialWithExistingShare(self):
     shareBase = os.path.join(self.tmpdir, 'share')
     sharerepo = os.path.join(shareBase, self.repodir.lstrip("/"))
     os.mkdir(shareBase)
     mercurial(self.repodir, sharerepo)
     open(os.path.join(self.repodir, 'test.txt'), 'w').write('hello!')
     run_cmd(['hg', 'add', 'test.txt'], cwd=self.repodir)
     run_cmd(['hg', 'commit', '-m', 'adding changeset'], cwd=self.repodir)
     mercurial(self.repodir, self.wc, shareBase=shareBase)
     self.assertEquals(getRevisions(self.repodir), getRevisions(self.wc))
     self.assertEquals(getRevisions(self.repodir), getRevisions(sharerepo))
开发者ID:bdacode,项目名称:build-tools,代码行数:11,代码来源:test_util_hg.py


示例13: testMercurialWithShareBaseInEnv

 def testMercurialWithShareBaseInEnv(self):
     shareBase = os.path.join(self.tmpdir, "share")
     sharerepo = os.path.join(shareBase, self.repodir.lstrip("/"))
     os.mkdir(shareBase)
     try:
         os.environ["HG_SHARE_BASE_DIR"] = shareBase
         mercurial(self.repodir, self.wc)
         self.assertEquals(getRevisions(self.repodir), getRevisions(self.wc))
         self.assertEquals(getRevisions(self.repodir), getRevisions(sharerepo))
     finally:
         del os.environ["HG_SHARE_BASE_DIR"]
开发者ID:B-Rich,项目名称:build-tools,代码行数:11,代码来源:test_util_hg.py


示例14: testMercurialShareOutgoing

 def testMercurialShareOutgoing(self):
     # ensure that outgoing changesets in a shared clone affect the shared history
     repo5 = os.path.join(self.tmpdir, 'repo5')
     repo6 = os.path.join(self.tmpdir, 'repo6')
     mercurial(self.repodir, repo5)
     share(repo5, repo6)
     open(os.path.join(repo6, 'test.txt'), 'w').write("hello!")
     # modify the history of the new clone
     run_cmd(['hg', 'add', 'test.txt'], cwd=repo6)
     run_cmd(['hg', 'commit', '-m', 'adding changeset'], cwd=repo6)
     self.assertNotEquals(self.revisions, getRevisions(repo6))
     self.assertNotEquals(self.revisions, getRevisions(repo5))
     self.assertEquals(getRevisions(repo5), getRevisions(repo6))
开发者ID:EkkiD,项目名称:build-tools,代码行数:13,代码来源:test_util_hg.py


示例15: testMercurialByRevWithShareAndMirror

    def testMercurialByRevWithShareAndMirror(self):
        # First create the mirror
        mirror = os.path.join(self.tmpdir, 'repo2')
        clone(self.repodir, mirror)

        shareBase = os.path.join(self.tmpdir, 'share')
        sharerepo = os.path.join(shareBase, self.repodir.lstrip("/"))
        os.mkdir(shareBase)
        mercurial(self.repodir, self.wc, shareBase=shareBase, mirrors=[mirror], clone_by_rev=True, revision=self.revisions[-1])

        # We should only have the one revision
        self.assertEquals(getRevisions(sharerepo), self.revisions[-1:])
        self.assertEquals(getRevisions(self.wc), self.revisions[-1:])
开发者ID:EkkiD,项目名称:build-tools,代码行数:13,代码来源:test_util_hg.py


示例16: testMercurialRelativeDir

    def testMercurialRelativeDir(self):
        os.chdir(os.path.dirname(self.repodir))

        repo = os.path.basename(self.repodir)
        wc = os.path.basename(self.wc)

        rev = mercurial(repo, wc, revision=self.revisions[-1])
        self.assertEquals(rev, self.revisions[-1])
        open(os.path.join(self.wc, 'test.txt'), 'w').write("hello!")

        rev = mercurial(repo, wc)
        self.assertEquals(rev, self.revisions[0])
        # Make sure our local file didn't go away
        self.failUnless(os.path.exists(os.path.join(self.wc, 'test.txt')))
开发者ID:bdacode,项目名称:build-tools,代码行数:14,代码来源:test_util_hg.py


示例17: compareLocales

def compareLocales(repo, locale, l10nRepoDir, localeSrcDir, l10nIni,
                   revision="default", merge=True):
    mercurial(repo, "compare-locales")
    update("compare-locales", revision=revision)
    mergeDir = path.join(localeSrcDir, "merged")
    if path.exists(mergeDir):
        log.info("Deleting %s" % mergeDir)
        shutil.rmtree(mergeDir)
    run_cmd(["python", path.join("compare-locales", "scripts",
                                 "compare-locales"),
             "-m", mergeDir,
             l10nIni,
             l10nRepoDir, locale],
            env={"PYTHONPATH": path.join("compare-locales", "lib")})
开发者ID:lundjordan,项目名称:build-tools,代码行数:14,代码来源:l10n.py


示例18: tagRepo

def tagRepo(config, repo, reponame, revision, tags, bumpFiles, relbranch,
            pushAttempts):
    remote = make_hg_url(HG, repo)
    mercurial(remote, reponame)

    def bump_and_tag(repo, attempt, config, relbranch, revision, tags):
        # set relbranchChangesets=1 because tag() generates exactly 1 commit
        relbranchChangesets = 1

        if relbranch in get_branches(reponame):
            update(reponame, revision=relbranch)
        else:
            update(reponame, revision=revision)
            run_cmd(['hg', 'branch', relbranch], cwd=reponame)

        if len(bumpFiles) > 0:
            # Bump files on the relbranch, if necessary
            bump(reponame, bumpFiles, 'version')
            run_cmd(['hg', 'diff'], cwd=repo)
            try:
                get_output(['hg', 'commit', '-u', config['hgUsername'],
                            '-m', getBumpCommitMessage(config['productName'], config['version'])],
                           cwd=reponame)
                relbranchChangesets += 1
            except subprocess.CalledProcessError, e:
                # We only want to ignore exceptions caused by having nothing to
                # commit, which are OK. We still want to raise exceptions caused
                # by any other thing.
                if e.returncode != 1 or "nothing changed" not in e.output:
                    raise

        # We always want our tags pointing at the tip of the relbranch
        # so we need to grab the current revision after we've switched
        # branches and bumped versions.
        revision = get_revision(reponame)
        # Create the desired tags on the relbranch
        tag(repo, revision, tags, config['hgUsername'])

        # Validate that the repository is only different from the remote in
        # ways we expect.
        outgoingRevs = out(src=reponame, remote=remote,
                           ssh_username=config['hgUsername'],
                           ssh_key=config['hgSshKey'])

        if len([r for r in outgoingRevs if r[BRANCH] == relbranch]) != relbranchChangesets:
            raise Exception("Incorrect number of revisions on %s" % relbranch)
        if len(outgoingRevs) != relbranchChangesets:
            raise Exception("Wrong number of outgoing revisions")
开发者ID:MihaiTabara,项目名称:build-tools,代码行数:48,代码来源:tag-release.py


示例19: testBustedHgrc

    def testBustedHgrc(self):
        # Test that we can recover from hgrc being lost
        mercurial(self.repodir, self.wc)

        # Delete .hg/hgrc
        os.unlink(os.path.join(self.wc, '.hg', 'hgrc'))

        # path is busted now
        p = path(self.wc)
        self.assertEquals(p, None)

        # cloning again should fix this up
        mercurial(self.repodir, self.wc)

        p = path(self.wc)
        self.assertEquals(p, self.repodir)
开发者ID:bdacode,项目名称:build-tools,代码行数:16,代码来源:test_util_hg.py


示例20: testShareUnrelated

    def testShareUnrelated(self):
        # Create a new repo
        repo2 = os.path.join(self.tmpdir, 'repo2')
        run_cmd(['%s/init_hgrepo.sh' % os.path.dirname(__file__), repo2])

        self.assertNotEqual(self.revisions, getRevisions(repo2))

        shareBase = os.path.join(self.tmpdir, 'share')

        # Clone the original repo
        mercurial(self.repodir, self.wc, shareBase=shareBase)

        # Clone the new repo
        mercurial(repo2, self.wc, shareBase=shareBase)

        self.assertEquals(getRevisions(self.wc), getRevisions(repo2))
开发者ID:bdacode,项目名称:build-tools,代码行数:16,代码来源:test_util_hg.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python hg.path函数代码示例发布时间:2022-05-26
下一篇:
Python hg.make_hg_url函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap