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

Python commands.init函数代码示例

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

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



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

示例1: test_file_only_copied

    def test_file_only_copied(self):
        """Change by copying a file with no content editing"""
        ui = mock_ui()
        hgcommands.init(ui, self.repo)

        hgrepo = repository(ui, self.repo)
        (
            open(hgrepo.pathto("file.dtd"), "w").write(
                """
             <!ENTITY key1 "Hello">
             <!ENTITY key2 "Cruel">
             """
            )
        )
        hgcommands.addremove(ui, hgrepo)
        hgcommands.commit(ui, hgrepo, user="Jane Doe <[email protected]>", message="initial commit")
        rev0 = hgrepo[0].hex()
        hgcommands.copy(ui, hgrepo, hgrepo.pathto("file.dtd"), hgrepo.pathto("newnamefile.dtd"))
        hgcommands.commit(ui, hgrepo, user="Jane Doe <[email protected]>", message="Second commit")
        rev1 = hgrepo[1].hex()

        Repository.objects.create(name=self.repo_name, url="http://localhost:8001/%s/" % self.repo_name)

        url = reverse("pushes.views.diff")
        response = self.client.get(url, {"repo": self.repo_name, "from": rev0, "to": rev1})
        eq_(response.status_code, 200)
        html_diff = response.content.split("Changed files:")[1]
        ok_("copied from file.dtd" in re.sub("<.*?>", "", html_diff))
        ok_(re.findall(">\s*newnamefile\.dtd\s*<", html_diff))
        ok_(not re.findall(">\s*Hello\s*<", html_diff))
        ok_(not re.findall(">\s*Cruel\s*<", html_diff))
开发者ID:gerv,项目名称:elmo,代码行数:31,代码来源:tests.py


示例2: test_remove_file

    def test_remove_file(self):
        """Change by removing a file, with parser"""
        ui = mock_ui()

        hgcommands.init(ui, self.repo)
        hgrepo = repository(ui, self.repo)
        (
            open(hgrepo.pathto("file.dtd"), "w").write(
                """
             <!ENTITY key1 "Hello">
             <!ENTITY key2 "Cruel">
             """
            )
        )

        hgcommands.addremove(ui, hgrepo)
        hgcommands.commit(ui, hgrepo, user="Jane Doe <[email protected]>", message="initial commit")
        rev0 = hgrepo[0].hex()
        hgcommands.remove(ui, hgrepo, "path:file.dtd")
        hgcommands.commit(ui, hgrepo, user="Jane Doe <[email protected]>", message="Second commit")
        rev1 = hgrepo[1].hex()

        Repository.objects.create(name=self.repo_name, url="http://localhost:8001/%s/" % self.repo_name)

        url = reverse("pushes.views.diff")
        response = self.client.get(url, {"repo": self.repo_name, "from": rev0, "to": rev1})
        eq_(response.status_code, 200)
        html_diff = response.content.split("Changed files:")[1]
        ok_(re.findall(">\s*file\.dtd\s*<", html_diff))
        # 2 entities with 2 rows each
        eq_(html_diff.count('<tr class="line-removed">'), 4)
        ok_(re.findall(">\s*key1\s*<", html_diff))
        ok_(re.findall(">\s*Hello\s*<", html_diff))
        ok_(re.findall(">\s*key2\s*<", html_diff))
        ok_(re.findall(">\s*Cruel\s*<", html_diff))
开发者ID:gerv,项目名称:elmo,代码行数:35,代码来源:tests.py


示例3: test_remove_file_no_parser

    def test_remove_file_no_parser(self):
        """Change by removing a file, without parser"""
        ui = mock_ui()

        hgcommands.init(ui, self.repo)
        hgrepo = repository(ui, self.repo)
        (open(hgrepo.pathto("file.txt"), "w").write("line 1\nline 2\n"))

        hgcommands.addremove(ui, hgrepo)
        hgcommands.commit(ui, hgrepo, user="Jane Doe <[email protected]>", message="initial commit")
        rev0 = hgrepo[0].hex()
        hgcommands.remove(ui, hgrepo, "path:file.txt")
        hgcommands.commit(ui, hgrepo, user="Jane Doe <[email protected]>", message="Second commit")
        rev1 = hgrepo[1].hex()

        repo_url = "http://localhost:8001/%s/" % self.repo_name
        Repository.objects.create(name=self.repo_name, url=repo_url)

        url = reverse("pushes.views.diff")
        response = self.client.get(url, {"repo": self.repo_name, "from": rev0, "to": rev1})
        eq_(response.status_code, 200)
        html_diff = response.content.split("Changed files:")[1]
        ok_(re.findall(">\s*file\.txt\s*<", html_diff))
        # 1 removed file
        eq_(html_diff.count('<div class="diff file-removed">'), 1)
        # also, expect a link to the old revision of the file
        change_ref = 'href="%sfile/%s/file.txt"' % (repo_url, rev0)
        ok_(change_ref in html_diff)
        ok_(not re.findall(">\s*line 1\s*<", html_diff))
        ok_(not re.findall(">\s*line 2\s*<", html_diff))
开发者ID:gerv,项目名称:elmo,代码行数:30,代码来源:tests.py


示例4: test_handlePushes_space_files

    def test_handlePushes_space_files(self):
        repo = Repository.objects.create(name="mozilla-central", url="file:///" + self.repo)
        self.assertEqual(handlePushes(repo.pk, []), None)

        ui = mock_ui()

        hgcommands.init(ui, self.repo)
        hgrepo = repository(ui, self.repo)
        (
            open(hgrepo.pathto("file.dtd "), "w").write(  # deliberate trailing space
                """
             <!ENTITY key1 "Hello">
             <!ENTITY key2 "Cruel">
             """
            )
        )

        hgcommands.addremove(ui, hgrepo)
        hgcommands.commit(ui, hgrepo, user="Jane Doe <[email protected]>", message="initial commit")
        rev0 = hgrepo[0].hex()

        timestamp = int(time.time())
        pushjs0 = PushJS(100, {"date": timestamp, "changesets": [rev0], "user": "jdoe"})
        handlePushes(repo.pk, [pushjs0])

        file_, = File.objects.all()
        self.assertEqual(file_.path, "file.dtd ")
开发者ID:gerv,项目名称:elmo,代码行数:27,代码来源:tests.py


示例5: test_file_edited_broken_encoding

    def test_file_edited_broken_encoding(self):
        """Change by editing a good with a broken edit"""
        ui = mock_ui()
        hgcommands.init(ui, self.repo)
        hgrepo = repository(ui, self.repo)

        (open(hgrepo.pathto("file.dtd"), "w").write(u'<!ENTITY key1 "Hello">\n'))

        hgcommands.addremove(ui, hgrepo)
        hgcommands.commit(ui, hgrepo, user="Jane Doe <[email protected]>", message="initial commit")
        rev0 = hgrepo[0].hex()

        # do this to trigger an exception on Mozilla.Parser.readContents
        _content = u'<!ENTITY key1 "Hell\xe3">\n'
        (codecs.open(hgrepo.pathto("file.dtd"), "w", "latin1").write(_content))

        hgcommands.commit(ui, hgrepo, user="Jane Doe <[email protected]>", message="Second commit")
        rev1 = hgrepo[1].hex()

        repo_url = "http://localhost:8001/" + self.repo_name + "/"
        Repository.objects.create(name=self.repo_name, url=repo_url)

        url = reverse("pushes.views.diff")
        response = self.client.get(url, {"repo": self.repo_name, "from": rev0, "to": rev1})
        eq_(response.status_code, 200)
        html_diff = response.content.split("Changed files:")[1]
        ok_("Cannot parse file" in html_diff)
        # also, expect a link to this file
        change_url = repo_url + "file/%s/file.dtd" % rev1
        ok_('href="%s"' % change_url in html_diff)
开发者ID:gerv,项目名称:elmo,代码行数:30,代码来源:tests.py


示例6: _upgrade

def _upgrade(ui, repo):
    ext_dir = os.path.dirname(os.path.abspath(__file__))
    ui.debug(_('kiln: checking for extensions upgrade for %s\n') % ext_dir)

    try:
        r = localrepo.localrepository(hgui.ui(), ext_dir)
    except RepoError:
        commands.init(hgui.ui(), dest=ext_dir)
        r = localrepo.localrepository(hgui.ui(), ext_dir)

    r.ui.setconfig('kiln', 'autoupdate', False)
    r.ui.pushbuffer()
    try:
        source = 'https://developers.kilnhg.com/Repo/Kiln/Group/Kiln-Extensions'
        if commands.incoming(r.ui, r, bundle=None, force=False, source=source) != 0:
            # no incoming changesets, or an error. Don't try to upgrade.
            ui.debug('kiln: no extensions upgrade available\n')
            return
        ui.write(_('updating Kiln Extensions at %s... ') % ext_dir)
        # pull and update return falsy values on success
        if commands.pull(r.ui, r, source=source) or commands.update(r.ui, r, clean=True):
            url = urljoin(repo.url()[:repo.url().lower().index('/repo')], 'Tools')
            ui.write(_('unable to update\nvisit %s to download the newest extensions\n') % url)
        else:
            ui.write(_('complete\n'))
    except Exception, e:
        ui.debug(_('kiln: error updating extensions: %s\n') % e)
        ui.debug(_('kiln: traceback: %s\n') % traceback.format_exc())
开发者ID:szechyjs,项目名称:dotfiles,代码行数:28,代码来源:kiln.py


示例7: test_handlePushes_repeated

    def test_handlePushes_repeated(self):
        repo = Repository.objects.create(name="mozilla-central", url="file:///" + self.repo)
        self.assertEqual(handlePushes(repo.pk, []), None)

        ui = mock_ui()

        hgcommands.init(ui, self.repo)
        hgrepo = repository(ui, self.repo)
        (
            open(hgrepo.pathto("file.dtd"), "w").write(
                """
             <!ENTITY key1 "Hello">
             <!ENTITY key2 "Cruel">
             """
            )
        )

        hgcommands.addremove(ui, hgrepo)
        hgcommands.commit(ui, hgrepo, user="Jane Doe <[email protected]>", message="initial commit")
        rev0 = hgrepo[0].hex()

        timestamp = int(time.time())
        pushjs0 = PushJS(100, {"date": timestamp, "changesets": [rev0], "user": "jdoe"})
        # first time
        pushes_initial = Push.objects.all().count()
        result = handlePushes(repo.pk, [pushjs0])
        self.assertEqual(result, 1)
        pushes_after = Push.objects.all().count()
        self.assertEqual(pushes_initial, pushes_after - 1)

        # a second time should be harmless
        result = handlePushes(repo.pk, [pushjs0])
        self.assertEqual(result, 1)
        pushes_after_after = Push.objects.all().count()
        self.assertEqual(pushes_after, pushes_after_after)
开发者ID:gerv,项目名称:elmo,代码行数:35,代码来源:tests.py


示例8: test_handlePushes_space_files

    def test_handlePushes_space_files(self):
        repo = Repository.objects.create(
          name='mozilla-central',
          url='file:///' + self.repo
        )
        self.assertEqual(handlePushes(repo.pk, []), None)

        ui = mock_ui()

        hgcommands.init(ui, self.repo)
        hgrepo = repository(ui, self.repo)
        (open(hgrepo.pathto('file.dtd '), 'w')  # deliberate trailing space
             .write('''
             <!ENTITY key1 "Hello">
             <!ENTITY key2 "Cruel">
             '''))

        hgcommands.addremove(ui, hgrepo)
        hgcommands.commit(ui, hgrepo,
                  user="Jane Doe <[email protected]>",
                  message="initial commit")
        rev0 = hgrepo[0].hex()

        timestamp = int(time.time())
        pushjs0 = PushJS(100, {
          'date': timestamp,
          'changesets': [rev0],
          'user': 'jdoe',
        })
        handlePushes(repo.pk, [pushjs0])

        file_, = File.objects.all()
        self.assertEqual(file_.path, 'file.dtd ')
开发者ID:Archaeopteryx,项目名称:elmo,代码行数:33,代码来源:test_pushes.py


示例9: test_handlePushes_cause_repoerror

    def test_handlePushes_cause_repoerror(self):
        repo = Repository.objects.create(
          name='mozilla-central',
          url='file:///does/not/exist'
        )
        self.assertEqual(handlePushes(repo.pk, []), None)

        ui = mock_ui()

        hgcommands.init(ui, self.repo)
        hgrepo = repository(ui, self.repo)
        (open(hgrepo.pathto('file.dtd'), 'w')
             .write('''
             <!ENTITY key1 "Hello">
             <!ENTITY key2 "Cruel">
             '''))

        hgcommands.addremove(ui, hgrepo)
        hgcommands.commit(ui, hgrepo,
                  user="Jane Doe <[email protected]>",
                  message="initial commit")
        rev0 = hgrepo[0].hex()

        timestamp = int(time.time())
        pushjs0 = PushJS(100, {
          'date': timestamp,
          'changesets': [rev0],
          'user': 'jdoe',
        })
        self.assertRaises(RepoError, handlePushes,
                          repo.pk, [pushjs0])
开发者ID:Archaeopteryx,项目名称:elmo,代码行数:31,代码来源:test_pushes.py


示例10: setUp

    def setUp(self):
        self.repo_path = mkdtemp()
        self.ui = ui.ui()
        self.ui.setconfig('ui', 'username', 'foo <[email protected]>')
        self.ui.setconfig('ui', 'quiet', True)
        commands.init(self.ui, self.repo_path)
        self.repo = hg.repository(self.ui, self.repo_path)
        file_dir = os.path.join(self.repo_path, 'content')
        if not os.path.isdir(file_dir):
            os.makedirs(file_dir)
        for i in range(3):
            file_path = os.path.join(file_dir, 'page-%i.rst' % i)
            with codecs.open(file_path, 'w', encoding='utf-8') as fp:
                fp.write(SAMPLE_PAGE)
            commands.add(self.ui, self.repo, file_path)
        file_path = os.path.join(file_dir, 'about.rst')
        with codecs.open(file_path, 'w', encoding='utf-8') as fp:
            fp.write(SAMPLE_PAGE + """
.. aliases: 301:/my-old-post-location/,/another-old-location/""")
        commands.add(self.ui, self.repo, file_path)
        file_dir = os.path.join(self.repo_path, 'content', 'post')
        if not os.path.isdir(file_dir):
            os.makedirs(file_dir)
        for i in range(3):
            file_path = os.path.join(file_dir, 'post-%i.rst' % i)
            with codecs.open(file_path, 'w', encoding='utf-8') as fp:
                fp.write(SAMPLE_POST)
            commands.add(self.ui, self.repo, file_path)
        file_path = os.path.join(file_dir, 'foo.rst')
        with codecs.open(file_path, 'w', encoding='utf-8') as fp:
            # using the page template, because we want to set tags manually
            fp.write(SAMPLE_PAGE + """
.. tags: foo, bar, lol""")
        commands.add(self.ui, self.repo, file_path)
        commands.commit(self.ui, self.repo, message='foo', user='foo')
开发者ID:GoGoBunny,项目名称:blohg,代码行数:35,代码来源:models.py


示例11: test_error_handling

    def test_error_handling(self):
        """Test various bad request parameters to the diff_app
        and assure that it responds with the right error codes."""
        ui = mock_ui()
        hgcommands.init(ui, self.repo)

        url = reverse("pushes.views.diff")
        response = self.client.get(url, {})
        eq_(response.status_code, 400)
        response = self.client.get(url, {"repo": "junk"})
        eq_(response.status_code, 404)

        hgrepo = repository(ui, self.repo)
        (
            open(hgrepo.pathto("file.dtd"), "w").write(
                """
             <!ENTITY key1 "Hello">
             <!ENTITY key2 "Cruel">
             """
            )
        )
        hgcommands.addremove(ui, hgrepo)
        hgcommands.commit(ui, hgrepo, user="Jane Doe <[email protected]>", message="initial commit")
        rev0 = hgrepo[0].hex()

        Repository.objects.create(name=self.repo_name, url="http://localhost:8001/%s/" % self.repo_name)

        # missing 'from' and 'to'
        response = self.client.get(url, {"repo": self.repo_name})
        eq_(response.status_code, 400)

        # missing 'to'
        response = self.client.get(url, {"repo": self.repo_name, "from": rev0})
        eq_(response.status_code, 400)
开发者ID:gerv,项目名称:elmo,代码行数:34,代码来源:tests.py


示例12: init

 def init(cls, path):
     if os.path.isdir(path):
         shutil.rmtree(path)
     os.mkdir(path)
     ui = cls._ui()
     hgcommands.init(ui, path)
     return repository(ui, path)
开发者ID:flodolo,项目名称:elmo,代码行数:7,代码来源:repo_fixtures.py


示例13: test_handlePushes_twice

    def test_handlePushes_twice(self):
        repo = Repository.objects.create(
          name='mozilla-central',
          url='file://' + self.repo
        )

        ui = mock_ui()
        hgcommands.init(ui, self.repo)
        hgrepo = repository(ui, self.repo)
        (open(hgrepo.pathto('file.dtd'), 'w')
             .write('''
             <!ENTITY key1 "Hello">
             <!ENTITY key2 "Cruel">
             '''))

        hgcommands.addremove(ui, hgrepo)
        hgcommands.commit(ui, hgrepo,
                  user="Jane Doe <[email protected]>",
                  message="initial commit")
        rev0 = hgrepo[0].hex()

        timestamp = int(time.time())
        pushjs0 = PushJS(100, {
          'date': timestamp,
          'changesets': [rev0],
          'user': 'jdoe',
        })
        result = handlePushes(repo.pk, [pushjs0])

        (open(hgrepo.pathto('file.dtd'), 'w')
             .write('''
             <!ENTITY key1 "Hello">
             <!ENTITY key2 "Cruel">
             <!ENTITY key3 "World">
             '''))
        hgcommands.commit(ui, hgrepo,
                  user="Jane Doe <[email protected]>",
                  message="Second commit")
        rev1 = hgrepo[1].hex()

        # a second time
        timestamp = int(time.time())
        pushjs0 = PushJS(101, {
          'date': timestamp,
          'changesets': [rev1],
          'user': 'jdoe',
        })

        # re-fetch
        repo = Repository.objects.get(pk=repo.pk)
        self.assertEqual(repo.changesets.all().count(), 2)

        result = handlePushes(repo.pk, [pushjs0])
        self.assertEqual(result, 1)

        # re-fetch
        repo = Repository.objects.get(pk=repo.pk)
        self.assertEqual(repo.changesets.all().count(), 3)
开发者ID:Archaeopteryx,项目名称:elmo,代码行数:58,代码来源:test_pushes.py


示例14: test_diff_base_against_clone

    def test_diff_base_against_clone(self):
        """Test that the right error is raised on trying to do a diff across
        a different divergant clone"""
        ui = mock_ui()
        orig = os.path.join(settings.REPOSITORY_BASE, "orig")
        clone = os.path.join(settings.REPOSITORY_BASE, "clone")
        hgcommands.init(ui, orig)
        hgorig = repository(ui, orig)
        (
            open(hgorig.pathto("file.dtd"), "w").write(
                """
          <!ENTITY old "content we will delete">
          <!ENTITY mod "this has stuff to keep and delete">
        """
            )
        )
        hgcommands.addremove(ui, hgorig)
        hgcommands.commit(ui, hgorig, user="Jane Doe <[email protected]", message="initial commit")
        assert len(hgorig) == 1  # 1 commit

        # set up a second repo called 'clone'
        hgcommands.clone(ui, orig, clone)
        hgclone = repository(ui, clone)

        # new commit on base
        (
            open(hgorig.pathto("file.dtd"), "w").write(
                """
         <!ENTITY mod "this has stuff to keep and add">
         <!ENTITY new "this has stuff that is new">
         """
            )
        )
        hgcommands.commit(ui, hgorig, user="Jane Doe <[email protected]", message="second commit on base")
        assert len(hgorig) == 2  # 2 commits
        rev_from = hgorig[1].hex()

        # different commit on clone
        (
            open(hgclone.pathto("file.dtd"), "w").write(
                """
         <!ENTITY mod "this has stuff to keep and change">
         <!ENTITY new_in_clone "this has stuff that is different from base">
         """
            )
        )
        hgcommands.commit(ui, hgclone, user="John Doe <[email protected]", message="a different commit on clone")
        rev_to = hgclone[1].hex()

        Repository.objects.create(name="orig", url="http://localhost:8001/orig/")
        Repository.objects.create(name="clone", url="http://localhost:8001/clone/")

        url = reverse("pushes.views.diff")
        # right now, we can't diff between repos, this might change!
        self.assertRaises(RepoError, self.client.get, url, {"repo": "clone", "from": rev_from[:12], "to": rev_to[:12]})
开发者ID:gerv,项目名称:elmo,代码行数:55,代码来源:tests.py


示例15: setUp

 def setUp(self):
     self.repo_path = mkdtemp()
     self.ui = ui.ui()
     self.ui.setconfig('ui', 'quiet', True)
     commands.init(self.ui, self.repo_path)
     self.file_name = 'foo.rst'
     self.file_path = os.path.join(self.repo_path, self.file_name)
     with codecs.open(self.file_path, 'w', encoding='utf-8') as fp:
         fp.write('test\n')
     self.repo = hg.repository(self.ui, self.repo_path)
     self.changectx = self.repo[None]
     commands.commit(self.ui, self.repo, message='foo',
                     user='foo <[email protected]>', addremove=True)
开发者ID:GoGoBunny,项目名称:blohg,代码行数:13,代码来源:filectx.py


示例16: test_handlePushes

    def test_handlePushes(self):
        repo = Repository.objects.create(
          name='mozilla-central',
          url='file:///' + self.repo
        )
        self.assertEqual(handlePushes(repo.pk, []), None)

        ui = mock_ui()
        hgcommands.init(ui, self.repo)
        hgrepo = repository(ui, self.repo)
        (open(hgrepo.pathto('file.dtd'), 'w')
             .write('''
             <!ENTITY key1 "Hello">
             <!ENTITY key2 "Cruel">
             '''))

        hgcommands.addremove(ui, hgrepo)
        hgcommands.commit(ui, hgrepo,
                  user="Jane Doe <[email protected]>",
                  message="initial commit")
        rev0 = hgrepo[0].hex()

        timestamp = int(time.time())
        push_id = 100
        username = 'jdoe'
        pushjs0 = PushJS(push_id, {
          'date': timestamp,
          'changesets': [rev0],
          'user': username,
        })
        result = handlePushes(repo.pk, [pushjs0])
        self.assertEqual(result, 1)

        # expect all of these to have been created
        push, = Push.objects.all()
        branch, = Branch.objects.all()
        changeset, = push.changesets.all()

        self.assertEqual(push.repository, repo)
        self.assertEqual(push.push_id, push_id)
        self.assertEqual(push.user, username)
        self.assertEqual(push.push_date.strftime('%Y%m%d%H%M'),
                         datetime.datetime.utcnow().strftime('%Y%m%d%H%M'))

        self.assertEqual(changeset.description, 'initial commit')
        self.assertEqual(changeset.user, 'Jane Doe <[email protected]>')
        self.assertEqual(changeset.revision, rev0)
        self.assertEqual(changeset.branch, branch)

        self.assertEqual(branch.name, 'default')
开发者ID:Archaeopteryx,项目名称:elmo,代码行数:50,代码来源:test_pushes.py


示例17: test_handlePushes_twice

    def test_handlePushes_twice(self):
        repo = Repository.objects.create(name="mozilla-central", url="file://" + self.repo)

        ui = mock_ui()
        hgcommands.init(ui, self.repo)
        hgrepo = repository(ui, self.repo)
        (
            open(hgrepo.pathto("file.dtd"), "w").write(
                """
             <!ENTITY key1 "Hello">
             <!ENTITY key2 "Cruel">
             """
            )
        )

        hgcommands.addremove(ui, hgrepo)
        hgcommands.commit(ui, hgrepo, user="Jane Doe <[email protected]>", message="initial commit")
        rev0 = hgrepo[0].hex()

        timestamp = int(time.time())
        pushjs0 = PushJS(100, {"date": timestamp, "changesets": [rev0], "user": "jdoe"})
        result = handlePushes(repo.pk, [pushjs0])

        (
            open(hgrepo.pathto("file.dtd"), "w").write(
                """
             <!ENTITY key1 "Hello">
             <!ENTITY key2 "Cruel">
             <!ENTITY key3 "World">
             """
            )
        )
        hgcommands.commit(ui, hgrepo, user="Jane Doe <[email protected]>", message="Second commit")
        rev1 = hgrepo[1].hex()

        # a second time
        timestamp = int(time.time())
        pushjs0 = PushJS(101, {"date": timestamp, "changesets": [rev1], "user": "jdoe"})

        # re-fetch
        repo = Repository.objects.get(pk=repo.pk)
        self.assertEqual(repo.changesets.all().count(), 2)

        result = handlePushes(repo.pk, [pushjs0])
        self.assertEqual(result, 1)

        # re-fetch
        repo = Repository.objects.get(pk=repo.pk)
        self.assertEqual(repo.changesets.all().count(), 3)
开发者ID:gerv,项目名称:elmo,代码行数:49,代码来源:tests.py


示例18: __init__

    def __init__(self,
                 path,
                 init=False):

        GeneralVCSInterface.__init__(self,path,init)

        if init:
            commands.init(ui.ui(),self.path)
            open(opath.join(self.path,".hgignore"),"w").write("syntax: re\n\n")

        self.repo=hg.repository(ui.ui(),self.path)
        self.ui=self.repo.ui

        if init:
            self.addPath(opath.join(self.repo.root,".hgignore"))
            self.addStandardIgnores()
开发者ID:LeeRuns,项目名称:PyFoam,代码行数:16,代码来源:HgInterface.py


示例19: setUp

    def setUp(self):
        self.repo_path = mkdtemp()
        self.ui = ui.ui()
        self.ui.setconfig('ui', 'quiet', True)
        self.ui.setconfig('ui', 'username', 'foo')
        commands.init(self.ui, self.repo_path)

        # create files
        self.repo_files = ['a%i.rst' % i for i in range(5)]
        for i in self.repo_files:
            with codecs.open(os.path.join(self.repo_path, i), 'w',
                             encoding='utf-8') as fp:
                fp.write('dumb file %s\n' % i)

        self.repo = hg.repository(self.ui, self.repo_path)
        commands.commit(self.ui, self.repo, message='foo', user='foo',
                        addremove=True)
开发者ID:foyslei,项目名称:blohg,代码行数:17,代码来源:changectx.py


示例20: create_repo

    def create_repo(repo_path):
        """Function to initialize a blohg repo, with the default template files
        inside.
        """

        template_path = resource_filename('blohg', 'repo_template')
        template_rootfiles = resource_listdir('blohg', 'repo_template')

        initialized = False
        for f in template_rootfiles + ['.hg']:
            if os.path.exists(os.path.join(repo_path, f)):
                initialized = True

        if initialized:
            raise RuntimeError('repository already initialized: %s' % \
                               repo_path)

        if not os.path.exists(repo_path):
            os.makedirs(repo_path)

        for f in template_rootfiles:
            full_path = os.path.join(template_path, f)
            if os.path.isdir(full_path):
                shutil.copytree(full_path, os.path.join(repo_path, f))
            elif os.path.isfile(full_path):
                shutil.copy2(full_path, os.path.join(repo_path, f))
            else:
                raise RuntimeError('unrecognized file: %s' % full_path)

        # create a .hgignore, to avoid people to acidentally push a build/ dir
        # with stuff built with 'blohg freeze'. creating the file here because
        # a .hgignore file in the repo may cause some weird behavior that we
        # are not aware of.
        with codecs.open(os.path.join(repo_path, '.hgignore'), 'w',
                         encoding='utf-8') as fp:
            fp.write('^build/' + os.linesep)

        ui = _ui.ui()
        ui.setconfig('ui', 'quiet', True)
        try:
            commands.init(ui, repo_path)
        except error, err:
            raise RuntimeError('an error was occurred: %s' % err)
开发者ID:GoGoBunny,项目名称:blohg,代码行数:43,代码来源:__init__.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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