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

Python hg.repository函数代码示例

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

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



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

示例1: overview

def overview(ui, repo, source=None, **opts):
    '''provides a general overview of your repository state

    This command combines the output of the hg incomng, hg outgoing,
    hg status, and hg id commands into an easily human-readable explanation
    of the entire state of your current working repository.
    '''
    if not repo:
        return
    originurl = ui.expandpath(source or 'default')
    targeturl = ui.expandpath(source or 'default-push', source or 'default')
    origin, hashbranch = parseurl(originurl)
    origin = hg.repository(remoteui(repo, opts), origin)
    target, hashbranch = parseurl(targeturl)
    target = hg.repository(remoteui(repo, opts), target)
    if originurl == targeturl:
        ui.status(_('parent repository: %s\n') % url.hidepassword(originurl))
    else:
        ui.status(_('source repository: %s\n') % url.hidepassword(getattr(origin, 'root', origin.url())))
        ui.status(_('destination repository: %s\n') % url.hidepassword(getattr(target, 'root', target.url())))

    ui.pushbuffer()
    out = outgoing(repo, target)
    inc = incoming(repo, origin, filter(bool, [hashbranch]))
    ui.popbuffer()

    changed = any(repo.status())
    if changed:
        status = _('uncommitted changes')
    else:
        status = _('working copy up-to-date')

    # grab heads
    heads = repo.branchheads(None, closed=False)
    if len(heads) > 1:
        merge = 'merge required'
    else:
        merge = ''

    ui.status(_('|   Remote   | << %s    |   Local    | %s\n') % (str(len(out)).center(5), merge))
    ui.status(_('| Repository |    %s >> | Repository | %s\n') % (str(len(inc)).center(5), status))

    if opts['detail']:
        if len(out) > 0:
            ui.status(_('\noutgoing changes:\n'))
            for rev in out:
                ui.status('%s %s\n' % (repo[rev],
                                       repo[rev].description().strip().split('\n')[0]))
        if len(inc) > 0:
            ui.status(_('\nincoming changes:\n'))
            for rev in inc:
                ui.status('%s %s\n' % (repo[rev],
                                       repo[rev].description().strip().split('\n')[0]))
        if changed:
            ui.status(_('\nlocal files:\n'))
            ui.pushbuffer()
            commands.status(ui, repo, '', **opts)
            status = ui.popbuffer()
            for l in status.splitlines():
                print '    %s' % l
开发者ID:sergio,项目名称:dotfiles,代码行数:60,代码来源:gestalt.py


示例2: __init__

 def __init__(self, ui, path):
     common.converter_sink.__init__(self, ui, path)
     self.branchnames = ui.configbool('convert', 'hg.usebranchnames', True)
     self.clonebranches = ui.configbool('convert', 'hg.clonebranches', False)
     self.tagsbranch = ui.config('convert', 'hg.tagsbranch', 'default')
     self.lastbranch = None
     if os.path.isdir(path) and len(os.listdir(path)) > 0:
         try:
             self.repo = hg.repository(self.ui, path)
             if not self.repo.local():
                 raise NoRepo(_('%s is not a local Mercurial repository')
                              % path)
         except error.RepoError as err:
             ui.traceback()
             raise NoRepo(err.args[0])
     else:
         try:
             ui.status(_('initializing destination %s repository\n') % path)
             self.repo = hg.repository(self.ui, path, create=True)
             if not self.repo.local():
                 raise NoRepo(_('%s is not a local Mercurial repository')
                              % path)
             self.created.append(path)
         except error.RepoError:
             ui.traceback()
             raise NoRepo(_("could not create hg repository %s as sink")
                          % path)
     self.lock = None
     self.wlock = None
     self.filemapmode = False
     self.subrevmaps = {}
开发者ID:cmjonze,项目名称:mercurial,代码行数:31,代码来源:hg.py


示例3: validate_hg_url

 def validate_hg_url(self, url):
     error = _("Invalid Hg URL: '%s'") % url
     source, branches = hg.parseurl(url)
     try:
         hg.repository(ui.ui(), source)
     except RepoError:
         raise forms.ValidationError(error)
开发者ID:brutasse-archive,项目名称:ci,代码行数:7,代码来源:forms.py


示例4: launch

def launch(root='', files=[], cwd='', main=True):
    u = ui.ui()
    u.updateopts(debug=False, traceback=False)
    repo = hg.repository(u, path=root)
    
    # move cwd to repo root if repo is merged, so we can show
    # all the changed files
    if len(repo.workingctx().parents()) > 1 and repo.root != cwd:
        cwd = repo.root
        repo = hg.repository(u, path=cwd)
        files = [cwd]

    ct = repo.ui.config('tortoisehg', 'commit', 'internal')
    if ct not in ['', 'internal']:
        from hglib import thgdispatch
        args = ['--repository', root, ct]
        try:
            ret = thgdispatch(repo.ui, args=args)
        except SystemExit:
            pass
        return None

    cmdoptions = {
        'user':'', 'date':'',
        'modified':True, 'added':True, 'removed':True, 'deleted':True,
        'unknown':False, 'ignored':False, 
        'exclude':[], 'include':[],
        'check': False, 'git':False, 'logfile':'', 'addremove':False,
    }
    
    dialog = GCommit(u, repo, cwd, files, cmdoptions, main)
    dialog.display()
    return dialog
开发者ID:tdjordan,项目名称:tortoisegit,代码行数:33,代码来源:commit.py


示例5: get_repo

def get_repo(url, alias):
    global peer

    myui = ui.ui()
    myui.setconfig('ui', 'interactive', 'off')
    myui.fout = sys.stderr

    if get_config_bool('remote-hg.insecure'):
        myui.setconfig('web', 'cacerts', '')

    extensions.loadall(myui)

    if hg.islocal(url) and not os.environ.get('GIT_REMOTE_HG_TEST_REMOTE'):
        repo = hg.repository(myui, url)
        if not os.path.exists(dirname):
            os.makedirs(dirname)
    else:
        shared_path = os.path.join(gitdir, 'hg')

        # check and upgrade old organization
        hg_path = os.path.join(shared_path, '.hg')
        if os.path.exists(shared_path) and not os.path.exists(hg_path):
            repos = os.listdir(shared_path)
            for x in repos:
                local_hg = os.path.join(shared_path, x, 'clone', '.hg')
                if not os.path.exists(local_hg):
                    continue
                if not os.path.exists(hg_path):
                    shutil.move(local_hg, hg_path)
                shutil.rmtree(os.path.join(shared_path, x, 'clone'))

        # setup shared repo (if not there)
        try:
            hg.peer(myui, {}, shared_path, create=True)
        except error.RepoError:
            pass

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

        local_path = os.path.join(dirname, 'clone')
        if not os.path.exists(local_path):
            hg.share(myui, shared_path, local_path, update=False)
        else:
            # make sure the shared path is always up-to-date
            util.writefile(os.path.join(local_path, '.hg', 'sharedpath'), hg_path)

        repo = hg.repository(myui, local_path)
        try:
            peer = hg.peer(myui, {}, url)
        except:
            die('Repository error')
        repo.pull(peer, heads=None, force=True)

        updatebookmarks(repo, peer)

    return repo
开发者ID:julienw,项目名称:config-files,代码行数:57,代码来源:git-remote-hg.py


示例6: get_repo_for_repository

def get_repo_for_repository(app, repository=None, repo_path=None):
    # Import from mercurial here to let Galaxy start under Python 3
    from mercurial import (
        hg,
        ui
    )
    if repository is not None:
        return hg.repository(ui.ui(), repository.repo_path(app))
    if repo_path is not None:
        return hg.repository(ui.ui(), repo_path)
开发者ID:lappsgrid-incubator,项目名称:Galaxy,代码行数:10,代码来源:hg_util.py


示例7: create_queue

def create_queue(repo, qname):
    if not has_queue(repo, qname):
        name = qname[8:] if qname != 'patches' else 'patches'
        fh = repo.opener('patches.queues', 'a')
        fh.write('%s\n' % (name,))
        fh.close()

    path = os.path.join(repo.path, qname)
    if not os.path.exists(path):
        hg.repository(repo.ui, path, create=True)
开发者ID:bhuztez,项目名称:hgtools,代码行数:10,代码来源:remotehq.py


示例8: 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


示例9: _local_repo

 def _local_repo(self):
     if self.key not in revision._state.repositories:
         if not os.path.exists(self.local):
             try:
                 os.makedirs(self.local)
                 revision._state.repositories[self.key] = hg.repository(self._ui, self.local, create=True)
             except error.RepoError:
                 pass
         if self.key not in revision._state.repositories:
             revision._state.repositories[self.key] = hg.repository(self._ui, self.local)
     return revision._state.repositories[self.key]
开发者ID:acdha,项目名称:django-versions,代码行数:11,代码来源:base.py


示例10: init

    def init(self):
        dest = self.getPath()

        if dest == '':
            qtlib.ErrorMsgBox(_('Error executing init'),
                    _('Destination path is empty'),
                    _('Please enter the directory path'))
            self.dest_edit.setFocus()
            return False

        dest = os.path.normpath(dest)
        self.dest_edit.setText(hglib.tounicode(dest))
        udest = self.dest_edit.text()

        if not os.path.exists(dest):
            p = dest
            l = 0
            while not os.path.exists(p):
                l += 1
                p, t = os.path.split(p)
                if not t:
                    break  # already root path
            if l > 1:
                res = qtlib.QuestionMsgBox(_('Init'),
                        _('Are you sure about adding the new repository '
                          '%d extra levels deep?') % l,
                        _('Path exists up to:\n%s\nand you asked for:\n%s')
                            % (p, udest),
                        defaultbutton=QMessageBox.No)
                if not res:
                    self.dest_edit.setFocus()
                    return
            try:
                # create the folder, just like Hg would
                os.makedirs(dest)
            except:
                qtlib.ErrorMsgBox(_('Error executing init'),
                        _('Cannot create folder %s') % udest)
                return False

        _ui = ui.ui()

        # dotencode is the new default repo format in Mercurial 1.7
        if self.make_pre_1_7_chk.isChecked():
            _ui.setconfig('format', 'dotencode', 'False')

        try:
            # create the new repo
            hg.repository(_ui, dest, create=1)
        except error.RepoError, inst:
            qtlib.ErrorMsgBox(_('Error executing init'),
                    _('Unable to create new repository'),
                    hglib.tounicode(str(inst)))
            return False
开发者ID:gilshwartz,项目名称:tortoisehg-caja,代码行数:54,代码来源:hginit.py


示例11: hgproto_init

def hgproto_init(repo, proto):
    """An hg protocol command handler that creates a new repository.  This gets
    bound to the 'init' command."""
    virtual = proto.req.env.get("PATH_INFO", "").strip("/")

    paths = {}
    for name, value in repo.ui.configitems("paths"):
        paths[name] = value

    local = local_path_for_repo(virtual, paths)
    hg.repository(repo.ui, path=local, create=True)
开发者ID:j3hyde,项目名称:hgwebinit,代码行数:11,代码来源:hgwebinit.py


示例12: __init__

 def __init__(self, parent=None):
     QtCore.QThread.__init__(self, parent)
     self.logger = logging.getLogger('__main__')
     self.info = lambda msg : self.logger.info(msg)
     self.debug = lambda msg : self.logger.debug(msg)        
     self.ui = ui.ui()
     self.url = 'https://open-ihm.googlecode.com/hg/'
     try:
         self.repo = hg.repository(self.ui, REPO_DIR)
     except Exception:
         self.repo = hg.repository(self.ui, REPO_DIR, create=True)
     return
开发者ID:r4vi,项目名称:open-ihm,代码行数:12,代码来源:frmupdateopenihm.py


示例13: create

	def create(self):
		if(self.destinationField.stringValue() is not None):
			try:
				hg.repository(cmdutil.remoteui(ui.ui(), {}), self.destinationField.stringValue(), create=1)
				NSAlert.alertWithMessageText_defaultButton_alternateButton_otherButton_informativeTextWithFormat_(
					NSLocalizedString("ERROR", None), "Ok", None, None, NSLocalizedString("Repository created sucessfully!", None)).runModal()
			except:
				NSAlert.alertWithMessageText_defaultButton_alternateButton_otherButton_informativeTextWithFormat_(
					NSLocalizedString("ERROR", None), "Ok", None, None, NSLocalizedString("An error occurred while creating Mercurial repository!", None)).runModal()
				import traceback
				traceback.print_exc()
				return ERROR(u'Exception, see traceback')
开发者ID:ararog,项目名称:iShareCode,代码行数:12,代码来源:CreateController.py


示例14: handlePushes

def handlePushes(repo_id, submits, do_update=True):
    if not submits:
        return
    repo = Repository.objects.get(id=repo_id)
    revisions = reduce(lambda r,l: r+l,
                       [p.changesets for p in submits],
       [])
    ui = _ui()
    repopath = os.path.join(settings.REPOSITORY_BASE,
                            repo.name)
    configpath = os.path.join(repopath, '.hg', 'hgrc')
    if not os.path.isfile(configpath):
        if not os.path.isdir(os.path.dirname(repopath)):
            os.makedirs(os.path.dirname(repopath))
        clone(ui, str(repo.url), str(repopath),
              pull=False, uncompressed=False, rev=[],
              noupdate=False)
        cfg = open(configpath, 'a')
        cfg.write('default-push = ssh%s\n' % str(repo.url)[4:])
        cfg.close()
        ui.readconfig(configpath)
        hgrepo = repository(ui, repopath)
    else:
        ui.readconfig(configpath)
        hgrepo = repository(ui, repopath)
        cs = submits[-1].changesets[-1]
        try:
            hgrepo.changectx(cs)
        except RepoError:
            pull(ui, hgrepo, source = str(repo.url),
                 force=False, update=False,
                 rev=[])
            if do_update:
                update(ui, hgrepo)
    for data in submits:
        changesets = []
        for revision in data.changesets:
            try:
                cs = getChangeset(repo, hgrepo, revision)
                transaction.commit()
                changesets.append(cs)
            except Exception, e:
                transaction.rollback()
                raise
                print repo.name, e
        p = Push.objects.create(repository = repo,
                                push_id = data.id, user = data.user,
                                push_date =
                                datetime.utcfromtimestamp(data.date))
        p.changesets = changesets
        p.save()
        transaction.commit()
开发者ID:lauraxt,项目名称:elmo,代码行数:52,代码来源:utils.py


示例15: __init__

 def __init__(self, path, username):
     uio = ui.ui()
     uio.quiet = True
     if not os.environ.get('HGUSER') and not uio.config("ui", "username"):
         os.environ['HGUSER'] = username
     try:
         repo = hg.repository(ui=uio, path=path)
     except:
         repo = hg.repository(ui=uio, path=path, create=True)
     hgignore = os.path.join(path, '.hgignore')
     if not os.path.exists(hgignore):
         open(hgignore, 'w').write(_hgignore_content)
     self.repo = repo
     self.decode = None
开发者ID:Focus3D,项目名称:rad2py,代码行数:14,代码来源:repo_hg.py


示例16: initial

    def initial(self, prefix):
        """
        Set up the hg repo at ``self.location``, which usually
        is set in ``settings.HG_REPO_PATH``.

        """
        if not os.path.exists(self.location):
            os.makedirs(self.location)
        u = self.hg_ui
        try:
            repo = hg.repository(u, self.location, create=1)
        except error.RepoError:
            repo = hg.repository(u, self.location)
        except Exception, e:
            raise
开发者ID:aleray,项目名称:aa.olga,代码行数:15,代码来源:hg.py


示例17: setup_repo

def setup_repo(url):
  try:
    myui=ui.ui(interactive=False)
  except TypeError:
    myui=ui.ui()
    myui.setconfig('ui', 'interactive', 'off')
  return myui,hg.repository(myui,url)
开发者ID:jasonmc,项目名称:hg-fast-export,代码行数:7,代码来源:hg2git.py


示例18: __init__

 def __init__(self, rev = 'tip', path = '/home/calixte/dev/mozilla/mozilla-central.hg'):
     self.root = path
     self.ui = ui.ui()
     self.rev = rev
     self.repo = hg.repository(self.ui, path)
     self.ctx = self.repo[self.rev]
     self.haspushlog = hasattr(self.repo, 'pushlog')
开发者ID:lizzard,项目名称:clouseau,代码行数:7,代码来源:hgstats.py


示例19: get_repo_changelog_tuples

def get_repo_changelog_tuples( repo_path ):
    repo = hg.repository( ui.ui(), repo_path )
    changelog_tuples = []
    for changeset in repo.changelog:
        ctx = repo.changectx( changeset )
        changelog_tuples.append( ( ctx.rev(), str( ctx ) ) )
    return changelog_tuples
开发者ID:knowingchaos,项目名称:galaxy,代码行数:7,代码来源:check_repositories_for_functional_tests.py


示例20: test_update

    def test_update(self):
        ''' Test 'clone --updaterev' '''
        ui = self.ui()
        _dispatch(ui, ['init', self.wc_path])
        repo = self.repo
        repo.ui.setconfig('ui', 'username', 'anonymous')

        fpath = os.path.join(self.wc_path, 'it')
        f = file(fpath, 'w')
        f.write('C1')
        f.flush()
        commands.add(ui, repo)
        commands.commit(ui, repo, message="C1")
        f.write('C2')
        f.flush()
        commands.commit(ui, repo, message="C2")
        f.write('C3')
        f.flush()
        commands.commit(ui, repo, message="C3")

        self.assertEqual(len(repo), 3)

        updaterev = 1
        _dispatch(ui, ['clone', self.wc_path, self.wc_path + '2',
                                '--updaterev=%s' % updaterev])

        repo2 = hg.repository(ui, self.wc_path + '2')

        self.assertEqual(str(repo[updaterev]), str(repo2['.']))
开发者ID:avuori,项目名称:dotfiles,代码行数:29,代码来源:test_unaffected_core.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python hg.update函数代码示例发布时间:2022-05-27
下一篇:
Python hg.peer函数代码示例发布时间: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