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


Python context.memctx函数代码示例

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


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

示例1: test_push_two_revs_different_local_branch

 def test_push_two_revs_different_local_branch(self):
     def filectxfn(repo, memctx, path):
         return context.memfilectx(path=path,
                                   data=path,
                                   islink=False,
                                   isexec=False,
                                   copied=False)
     oldtiphash = self.repo['default'].node()
     ctx = context.memctx(self.repo,
                          (self.repo[0].node(), revlog.nullid, ),
                          'automated test',
                          ['gamma', ],
                          filectxfn,
                          'testy',
                          '2008-12-21 16:32:00 -0500',
                          {'branch': 'localbranch', })
     newhash = self.repo.commitctx(ctx)
     ctx = context.memctx(self.repo,
                          (newhash, revlog.nullid),
                          'automated test2',
                          ['delta', ],
                          filectxfn,
                          'testy',
                          '2008-12-21 16:32:00 -0500',
                          {'branch': 'localbranch', })
     newhash = self.repo.commitctx(ctx)
     repo = self.repo
     hg.update(repo, newhash)
     commands.push(repo.ui, repo)
     self.assertEqual(self.repo['tip'].parents()[0].parents()[0].node(), oldtiphash)
     self.assertEqual(self.repo['tip'].files(), ['delta', ])
     self.assertEqual(self.repo['tip'].manifest().keys(),
                      ['alpha', 'beta', 'gamma', 'delta'])
开发者ID:bulwinkel,项目名称:dot-files,代码行数:33,代码来源:test_push_command.py

示例2: test_push_single_dir_renamed_branch

    def test_push_single_dir_renamed_branch(self, stupid=False):
        # Tests pulling and pushing with a renamed branch
        # Based on test_push_single_dir
        test_util.load_svndump_fixture(self.repo_path,
                                       'branch_from_tag.svndump')
        cmd = ['clone', '--layout=single', '--branch=flaf']
        if stupid:
            cmd.append('--stupid')
        cmd += [test_util.fileurl(self.repo_path), self.wc_path]
        dispatch.dispatch(cmd)

        def file_callback(repo, memctx, path):
            if path == 'adding_file':
                return context.memfilectx(path=path,
                                          data='foo',
                                          islink=False,
                                          isexec=False,
                                          copied=False)
            raise IOError(errno.EINVAL, 'Invalid operation: ' + path)
        ctx = context.memctx(self.repo,
                             (self.repo['tip'].node(), node.nullid),
                             'automated test',
                             ['adding_file'],
                             file_callback,
                             'an_author',
                             '2009-10-19 18:49:30 -0500',
                             {'branch': 'default',})
        self.repo.commitctx(ctx)
        hg.update(self.repo, self.repo['tip'].node())
        self.pushrevisions()
        self.assertTrue('adding_file' in self.svnls(''))

        self.assertEquals(set(['flaf']),
                          set(self.repo[i].branch() for i in self.repo))
开发者ID:bulwinkel,项目名称:dot-files,代码行数:34,代码来源:test_single_dir_clone.py

示例3: test_push_to_default

 def test_push_to_default(self, commit=True):
     repo = self.repo
     old_tip = repo['tip'].node()
     expected_parent = repo['default'].node()
     def file_callback(repo, memctx, path):
         if path == 'adding_file':
             return context.memfilectx(path=path,
                                       data='foo',
                                       islink=False,
                                       isexec=False,
                                       copied=False)
         raise IOError(errno.EINVAL, 'Invalid operation: ' + path)
     ctx = context.memctx(repo,
                          (repo['default'].node(), node.nullid),
                          'automated test',
                          ['adding_file'],
                          file_callback,
                          'an_author',
                          '2008-10-07 20:59:48 -0500',
                          {'branch': 'default',})
     new_hash = repo.commitctx(ctx)
     if not commit:
         return # some tests use this test as an extended setup.
     hg.update(repo, repo['tip'].node())
     self.pushrevisions()
     tip = self.repo['tip']
     self.assertNotEqual(tip.node(), old_tip)
     self.assertEqual(node.hex(tip.parents()[0].node()),
                      node.hex(expected_parent))
     self.assertEqual(tip['adding_file'].data(), 'foo')
     self.assertEqual(tip.branch(), 'default')
开发者ID:bulwinkel,项目名称:dot-files,代码行数:31,代码来源:test_push_command.py

示例4: test_push_single_dir_one_incoming_and_two_outgoing

 def test_push_single_dir_one_incoming_and_two_outgoing(self):
     # Tests simple pushing from default branch to a single dir repo
     # Pushes two outgoing over one incoming svn rev
     # (used to cause an "unknown revision")
     # This can happen if someone committed to svn since our last pull (race).
     repo = self._load_fixture_and_fetch('branch_from_tag.svndump',
                                         stupid=False,
                                         layout='single',
                                         subdir='trunk')
     self._add_svn_rev({'trunk/alpha': 'Changed'})
     def file_callback(repo, memctx, path):
         return context.memfilectx(path=path,
                                   data='data of %s' % path,
                                   islink=False,
                                   isexec=False,
                                   copied=False)
     for fn in ['one', 'two']:
         ctx = context.memctx(repo,
                              (repo['tip'].node(), node.nullid),
                              'automated test',
                              [fn],
                              file_callback,
                              'an_author',
                              '2009-10-19 18:49:30 -0500',
                              {'branch': 'default',})
         repo.commitctx(ctx)
     hg.update(repo, repo['tip'].node())
     self.pushrevisions(expected_extra_back=1)
     self.assertTrue('trunk/one' in self.svnls(''))
     self.assertTrue('trunk/two' in self.svnls(''))
开发者ID:bulwinkel,项目名称:dot-files,代码行数:30,代码来源:test_single_dir_clone.py

示例5: test_push_single_dir_at_subdir

 def test_push_single_dir_at_subdir(self):
     repo = self._load_fixture_and_fetch('branch_from_tag.svndump',
                                         stupid=False,
                                         layout='single',
                                         subdir='trunk')
     def filectxfn(repo, memctx, path):
         return context.memfilectx(path=path,
                                   data='contents of %s' % path,
                                   islink=False,
                                   isexec=False,
                                   copied=False)
     ctx = context.memctx(repo,
                          (repo['tip'].node(), node.nullid),
                          'automated test',
                          ['bogus'],
                          filectxfn,
                          'an_author',
                          '2009-10-19 18:49:30 -0500',
                          {'branch': 'localhacking',})
     n = repo.commitctx(ctx)
     self.assertEqual(self.repo['tip']['bogus'].data(),
                      'contents of bogus')
     before = repo['tip'].hex()
     hg.update(repo, self.repo['tip'].hex())
     self.pushrevisions()
     self.assertNotEqual(before, self.repo['tip'].hex())
     self.assertEqual(self.repo['tip']['bogus'].data(),
                      'contents of bogus')
开发者ID:bulwinkel,项目名称:dot-files,代码行数:28,代码来源:test_single_dir_clone.py

示例6: putcommit

    def putcommit(self, files, modes, copies, commit):

        def getfilectx(repo, memctx, name):
            fileid = files[name]
            if fileid is None:  # deleted file
                raise IOError
            data = self.getblob(fileid)
            ctx = context.memfilectx(name, data, 'l' in modes,
                                     'x' in modes, copies.get(name))
            return ctx

        parents = list(set(commit.parents))
        nparents = len(parents)

        if len(parents) < 2:
            parents.append(nullid)
        if len(parents) < 2:
            parents.append(nullid)
        p2 = parents.pop(0)

        text = commit.desc
        extra = commit.extra.copy()
        if self.branchnames and commit.branch:
            extra['branch'] = commit.branch

        while parents:
            p1 = p2
            p2 = parents.pop(0)
            ctx = context.memctx(self.repo, (p1, p2), text, files.keys(),
                                 getfilectx, commit.author, commit.date, extra)
            self.repo.commitctx(ctx)
            text = "(octopus merge fixup)\n"
            p2 = hex(self.repo.changelog.tip())

        return p2
开发者ID:Grahack,项目名称:git,代码行数:35,代码来源:hgimport.py

示例7: test_push_to_branch

 def test_push_to_branch(self, push=True):
     repo = self.repo
     def file_callback(repo, memctx, path):
         if path == 'adding_file':
             return context.memfilectx(path=path,
                                       data='foo',
                                       islink=False,
                                       isexec=False,
                                       copied=False)
         raise IOError(errno.EINVAL, 'Invalid operation: ' + path)
     ctx = context.memctx(repo,
                          (repo['the_branch'].node(), node.nullid),
                          'automated test',
                          ['adding_file'],
                          file_callback,
                          'an_author',
                          '2008-10-07 20:59:48 -0500',
                          {'branch': 'the_branch',})
     new_hash = repo.commitctx(ctx)
     hg.update(repo, repo['tip'].node())
     if push:
         self.pushrevisions()
         tip = self.repo['tip']
         self.assertNotEqual(tip.node(), new_hash)
         self.assertEqual(tip['adding_file'].data(), 'foo')
         self.assertEqual(tip.branch(), 'the_branch')
开发者ID:bulwinkel,项目名称:dot-files,代码行数:26,代码来源:test_push_command.py

示例8: test_push_symlink_file

 def test_push_symlink_file(self):
     self.test_push_to_default(commit=True)
     repo = self.repo
     def file_callback(repo, memctx, path):
         if path == 'gamma':
             return context.memfilectx(path=path,
                                       data='foo',
                                       islink=True,
                                       isexec=False,
                                       copied=False)
         raise IOError(errno.EINVAL, 'Invalid operation: ' + path)
     ctx = context.memctx(repo,
                          (repo['tip'].node(), node.nullid),
                          'message',
                          ['gamma', ],
                          file_callback,
                          'author',
                          '2008-10-29 21:26:00 -0500',
                          {'branch': 'default', })
     new_hash = repo.commitctx(ctx)
     hg.update(repo, repo['tip'].node())
     self.pushrevisions()
     tip = self.repo['tip']
     self.assertNotEqual(tip.node(), new_hash)
     self.assertEqual(tip['gamma'].flags(), 'l')
     self.assertEqual(tip['gamma'].data(), 'foo')
     self.assertEqual([x for x in tip.manifest().keys() if 'l' not in
                       tip[x].flags()], ['alpha', 'beta', 'adding_file', ])
开发者ID:bulwinkel,项目名称:dot-files,代码行数:28,代码来源:test_push_command.py

示例9: test_outgoing_output

 def test_outgoing_output(self):
     self._load_fixture_and_fetch('two_heads.svndump')
     u = self.ui()
     parents = (self.repo['the_branch'].node(), revlog.nullid, )
     def filectxfn(repo, memctx, path):
         return context.memfilectx(path=path,
                                   data='added',
                                   islink=False,
                                   isexec=False,
                                   copied=False)
     ctx = context.memctx(self.repo,
                          parents,
                          'automated test',
                          ['added_bogus_file', 'other_added_file', ],
                          filectxfn,
                          'testy',
                          '2008-12-21 16:32:00 -0500',
                          {'branch': 'localbranch', })
     new = self.repo.commitctx(ctx)
     hg.update(self.repo, new)
     u.pushbuffer()
     commands.outgoing(u, self.repo, self.repourl)
     actual = u.popbuffer()
     self.assertTrue(node.hex(self.repo['localbranch'].node())[:8] in actual)
     self.assertEqual(actual.strip(), '5:6de15430fa20')
     hg.update(self.repo, 'default')
     u.pushbuffer()
     commands.outgoing(u, self.repo, self.repourl)
     actual = u.popbuffer()
     self.assertEqual(actual, '')
开发者ID:chaptastic,项目名称:config_files,代码行数:30,代码来源:test_utility_commands.py

示例10: test_push_single_dir

 def test_push_single_dir(self):
     # Tests simple pushing from default branch to a single dir repo
     repo = self._load_fixture_and_fetch('branch_from_tag.svndump',
                                         stupid=False,
                                         layout='single',
                                         subdir='')
     def file_callback(repo, memctx, path):
         if path == 'adding_file':
             return context.memfilectx(path=path,
                                       data='foo',
                                       islink=False,
                                       isexec=False,
                                       copied=False)
         raise IOError(errno.EINVAL, 'Invalid operation: ' + path)
     ctx = context.memctx(repo,
                          (repo['tip'].node(), node.nullid),
                          'automated test',
                          ['adding_file'],
                          file_callback,
                          'an_author',
                          '2009-10-19 18:49:30 -0500',
                          {'branch': 'default',})
     repo.commitctx(ctx)
     hg.update(repo, repo['tip'].node())
     self.pushrevisions()
     self.assertTrue('adding_file' in self.svnls(''))
开发者ID:bulwinkel,项目名称:dot-files,代码行数:26,代码来源:test_single_dir_clone.py

示例11: test_rebase

 def test_rebase(self):
     self._load_fixture_and_fetch('two_revs.svndump')
     parents = (self.repo[0].node(), revlog.nullid, )
     def filectxfn(repo, memctx, path):
         return context.memfilectx(path=path,
                                   data='added',
                                   islink=False,
                                   isexec=False,
                                   copied=False)
     ctx = context.memctx(self.repo,
                          parents,
                          'automated test',
                          ['added_bogus_file', 'other_added_file', ],
                          filectxfn,
                          'testy',
                          '2008-12-21 16:32:00 -0500',
                          {'branch': 'localbranch', })
     self.repo.commitctx(ctx)
     self.assertEqual(self.repo['tip'].branch(), 'localbranch')
     beforerebasehash = self.repo['tip'].node()
     hg.update(self.repo, 'tip')
     wrappers.rebase(rebase.rebase, self.ui(), self.repo, svn=True)
     self.assertEqual(self.repo['tip'].branch(), 'localbranch')
     self.assertEqual(self.repo['tip'].parents()[0].parents()[0], self.repo[0])
     self.assertNotEqual(beforerebasehash, self.repo['tip'].node())
开发者ID:chaptastic,项目名称:config_files,代码行数:25,代码来源:test_utility_commands.py

示例12: puttags

    def puttags(self, tags):
        try:
            parentctx = self.repo[self.tagsbranch]
            tagparent = parentctx.node()
        except error.RepoError:
            parentctx = None
            tagparent = nullid

        try:
            oldlines = sorted(parentctx['.hgtags'].data().splitlines(True))
        except:
            oldlines = []

        newlines = sorted([("%s %s\n" % (tags[tag], tag)) for tag in tags])
        if newlines == oldlines:
            return None, None
        data = "".join(newlines)
        def getfilectx(repo, memctx, f):
            return context.memfilectx(f, data, False, False, None)

        self.ui.status(_("updating tags\n"))
        date = "%s 0" % int(time.mktime(time.gmtime()))
        extra = {'branch': self.tagsbranch}
        ctx = context.memctx(self.repo, (tagparent, None), "update tags",
                             [".hgtags"], getfilectx, "convert-repo", date,
                             extra)
        self.repo.commitctx(ctx)
        return hex(self.repo.changelog.tip()), hex(tagparent)
开发者ID:MezzLabs,项目名称:mercurial,代码行数:28,代码来源:hg.py

示例13: test_cant_push_with_changes

 def test_cant_push_with_changes(self):
     repo = self.repo
     def file_callback(repo, memctx, path):
         return compathacks.makememfilectx(repo,
                                           path=path,
                                           data='foo',
                                           islink=False,
                                           isexec=False,
                                           copied=False)
     ctx = context.memctx(repo,
                          (repo['default'].node(), node.nullid),
                          'automated test',
                          ['adding_file'],
                          file_callback,
                          'an_author',
                          '2008-10-07 20:59:48 -0500',
                          {'branch': 'default', })
     new_hash = repo.commitctx(ctx)
     hg.update(repo, repo['tip'].node())
     # Touch an existing file
     repo.wwrite('beta', 'something else', '')
     try:
         self.pushrevisions()
     except hgutil.Abort:
         pass
     tip = self.repo['tip']
     self.assertEqual(new_hash, tip.node())
开发者ID:fuzzball81,项目名称:dotfiles,代码行数:27,代码来源:test_push_command.py

示例14: _commitcontext

def _commitcontext(rdst, parents, ctx, dstfiles, getfilectx, revmap):
    mctx = context.memctx(rdst, parents, ctx.description(), dstfiles,
                          getfilectx, ctx.user(), ctx.date(), ctx.extra())
    ret = rdst.commitctx(mctx)
    lfutil.copyalltostore(rdst, ret)
    rdst.setparents(ret)
    revmap[ctx.node()] = rdst.changelog.tip()
开发者ID:RayFerr000,项目名称:PLTL,代码行数:7,代码来源:lfcommands.py

示例15: commit

    def commit(self, items):
        def file_callback(repo, memctx, path):
            return context.memfilectx(
                path=path,
                data=items[path],
                islink=False,
                isexec=False,
                copied=False,
                )
        local_repo = self._local_repo
        remote_repo = self._remote_repo

        lock = local_repo.lock()
        try:
            if remote_repo:
                local_repo.pull(self._remote_repo)

            ctx = context.memctx(
                repo=local_repo,
                parents=('tip', None),
                text=revision.message,
                files=items.keys(),
                filectxfn=file_callback,
                user=str(revision.user.id),
                )
            version = node.hex(local_repo.commitctx(ctx))
            # TODO: if we want the working copy of the repository to be updated as well add logic to enable this.
            # hg.update(local_repo, local_repo['tip'].node())
            if remote_repo:
                local_repo.push(remote_repo)

            return version
        finally:
            lock.release()
开发者ID:acdha,项目名称:django-versions,代码行数:34,代码来源:base.py


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