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


Python git_handler.GitHandler类代码示例

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


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

示例1: do_POST

 def do_POST(self):
     """ Reply to an HTTP POST """
     if not self.__authenticate():
         self.send_response(403)
         self.end_headers()
         return
     # Send response 202 Accepted
     # We've accepted the request and are processing it.
     self.send_response(202)
     try:
         post_data = json.loads(
             self.rfile.read(
                 int(self.headers['Content-Length'])).decode('utf-8'))
         if post_data['action'] not in ('opened', 'synchronize'):
             # Pull Request is no longer open.
             # Reply with HTTP 409 Conflict
             self.send_response(409)
             self.end_headers()
             return
         handler = GitHandler(post_data)
         handler.clone()
         handler.pylint_and_comment(self.config)
         # Reply 201 Created, we're not using 200 OK
         # because in that case we would have to send the result of
         # processing as a reply.
         # Instead we've created a comment on Github.
         self.send_response(201)
         self.end_headers()
     except Exception as error:
         print('Something gone wrong:\n{}'.format(str(error)))
         self.send_response(500)
         self.end_headers()
开发者ID:StephanMeijer,项目名称:PyLintWebServer,代码行数:32,代码来源:github_webhook_server.py

示例2: write

 def write(self, *args, **kwargs):
     super(ext_ui, self).write(*args, **kwargs)
     # Changesets are printed twice in the current hg code, always with label log.changeset
     if kwargs.has_key('label') and kwargs['label'] == 'log.changeset' and len(args) and cached_repo:
         global changeset_re
         global cached_git
         if not changeset_re:
             changeset_re = re.compile('(\d+):\w+(\s*)$')
         match = changeset_re.search(args[0])
         if match:
             # Parse out from the changeset string: The numeric local rev, and the line terminator
             # (So that we know if we need to print the git revision with a newline or not)
             rev, terminator = match.group(1,2)
             try:        # Works in Mercurial 1.9.x
                 from mercurial.templatefilters import hexfilter, short
             except:     # Works in Mercurial 1.8.x
                 from mercurial.templatefilters import filters
                 hexfilter = filters["hex"]
                 short = filters["short"]
             hgsha = cached_repo.lookup(int(rev)) # Ints are efficient on lookup
             if (hgsha):
                 hgsha = hexfilter(hgsha)
                 if not cached_git:
                     cached_git = GitHandler(cached_repo, self)
                 gitsha = cached_git.map_git_get(hgsha)
             else: # Currently this case is hit when you do hg outgoing. I'm not sure why.
                 gitsha = None
             
             if gitsha:
                 if terminator == '\n': # hg log, etc
                     output = _("git-rev:     %s\n")
                 else:                  # hg sum
                     output = "git:%s "
                 super(ext_ui, self).write(output % (short(gitsha)), label='log.gitchangeset')
开发者ID:mcclure,项目名称:hg-git,代码行数:34,代码来源:__init__.py

示例3: revset_fromgit

def revset_fromgit(repo, subset, x):
    '''``fromgit()``
    Select changesets that originate from Git.
    '''
    args = revset.getargs(x, 0, 0, "fromgit takes no arguments")
    git = GitHandler(repo, repo.ui)
    return [r for r in subset if git.map_git_get(repo[r].hex()) is not None]
开发者ID:CSRedRat,项目名称:hg-git,代码行数:7,代码来源:__init__.py

示例4: findoutgoing

 def findoutgoing(self, remote, base=None, heads=None, force=False):
     if isinstance(remote, gitrepo):
         git = GitHandler(self, self.ui)
         base, heads = git.get_refs(remote.path)
         out, h = super(hgrepo, self).findoutgoing(remote, base, heads, force)
         return out
     else: #pragma: no cover
         return super(hgrepo, self).findoutgoing(remote, base, heads, force)
开发者ID:dgladkov,项目名称:hg-git,代码行数:8,代码来源:hgrepo.py

示例5: getremotechanges

def getremotechanges(orig, ui, repo, other, revs, *args, **opts):
    if isinstance(other, gitrepo.gitrepo):
        git = GitHandler(repo, ui)
        r, c, cleanup = git.getremotechanges(other, revs)
        # ugh. This is ugly even by mercurial API compatibility standards
        if 'onlyheads' not in orig.func_code.co_varnames:
            cleanup = None
        return r, c, cleanup
    return orig(ui, repo, other, revs, *args, **opts)
开发者ID:MichaelBlume,项目名称:hg-git,代码行数:9,代码来源:__init__.py

示例6: gitnodekw

def gitnodekw(**args):
    """:gitnode: String.  The Git changeset identification hash, as a 40 hexadecimal digit string."""
    node = args['ctx']
    repo = args['repo']
    git = GitHandler(repo, repo.ui)
    gitnode = git.map_git_get(node.hex())
    if gitnode is None:
        gitnode = ''
    return gitnode
开发者ID:CSRedRat,项目名称:hg-git,代码行数:9,代码来源:__init__.py

示例7: push

 def push(self, remote, force=False, revs=None, newbranch=None):
     if isinstance(remote, gitrepo):
         git = GitHandler(self, self.ui)
         git.push(remote.path, revs, force)
     else: #pragma: no cover
         # newbranch was added in 1.6
         if newbranch is None:
             return super(hgrepo, self).push(remote, force, revs)
         else:
             return super(hgrepo, self).push(remote, force, revs,
                                             newbranch)
开发者ID:dgladkov,项目名称:hg-git,代码行数:11,代码来源:hgrepo.py

示例8: __init__

    def __init__(self):
        self.config_file = os.path.dirname(os.path.abspath(__file__)) + '/config.json'
        config_data = self.load_configuration()

        self.command_runner = SystemCommandRunner()
        self.configuration = ConfigurationLoader(json_config_data=config_data)
        self.git_handler = GitHandler(project_path=self.configuration.get_project_path_value())
开发者ID:xedinaska,项目名称:CodestyleAutochecker,代码行数:7,代码来源:preprocessor.py

示例9: findoutgoing

 def findoutgoing(orig, local, remote, *args, **kwargs):
     kw = {}
     kw.update(kwargs)
     for val, k in zip(args, ('base', kwname, 'force')):
         kw[k] = val
     if isinstance(remote, gitrepo.gitrepo):
         # clean up this cruft when we're 1.7-only, remoteheads and
         # the return value change happened between 1.6 and 1.7.
         git = GitHandler(local, local.ui)
         base, heads = git.get_refs(remote.path)
         newkw = {'base': base, kwname: heads}
         newkw.update(kw)
         kw = newkw
         if kwname == 'heads':
             r = orig(local, remote, **kw)
             return [x[0] for x in r]
     return orig(local, remote, **kw)
开发者ID:dgladkov,项目名称:hg-git,代码行数:17,代码来源:__init__.py

示例10: findcommonoutgoing

def findcommonoutgoing(orig, repo, other, *args, **kwargs):
    if isinstance(other, gitrepo.gitrepo):
        git = GitHandler(repo, repo.ui)
        heads = git.get_refs(other.path)[0]
        kw = {}
        kw.update(kwargs)
        for val, k in zip(args,
                ('onlyheads', 'force', 'commoninc', 'portable')):
            kw[k] = val
        force = kw.get('force', False)
        commoninc = kw.get('commoninc', None)
        if commoninc is None:
            commoninc = discovery.findcommonincoming(repo, other,
                heads=heads, force=force)
            kw['commoninc'] = commoninc
        return orig(repo, other, **kw)
    return orig(repo, other, *args, **kwargs)
开发者ID:CSRedRat,项目名称:hg-git,代码行数:17,代码来源:__init__.py

示例11: findoutgoing

 def findoutgoing(orig, local, remote, *args, **kwargs):
     if isinstance(remote, gitrepo.gitrepo):
         hgver = hg.util.version()
         if hgver >= "1.8.9" or (hgver > "1.8" and "+" in hgver):
             raise hgutil.Abort("hg-git outgoing support is broken on hg 1.9.x")
         # clean up this cruft when we're 1.7-only, remoteheads and
         # the return value change happened between 1.6 and 1.7.
         kw = {}
         kw.update(kwargs)
         for val, k in zip(args, ("base", kwname, "force")):
             kw[k] = val
         git = GitHandler(local, local.ui)
         base, heads = git.get_refs(remote.path)
         newkw = {"base": base, kwname: heads}
         newkw.update(kw)
         kw = newkw
         if kwname == "heads":
             r = orig(local, remote, **kw)
             return [x[0] for x in r]
         if kwname == "onlyheads":
             del kw["base"]
         return orig(local, remote, **kw)
     return orig(local, remote, *args, **kwargs)
开发者ID:hadisdc,项目名称:dotfiles,代码行数:23,代码来源:__init__.py

示例12: findoutgoing

 def findoutgoing(orig, local, remote, *args, **kwargs):
     if isinstance(remote, gitrepo.gitrepo):
         hgver = hg.util.version()
         if hgver >= '1.8.9' or (hgver > '1.8' and '+' in hgver):
             raise hgutil.Abort(
                 'hg-git outgoing support is broken on hg 1.9.x')
         # clean up this cruft when we're 1.7-only, remoteheads and
         # the return value change happened between 1.6 and 1.7.
         kw = {}
         kw.update(kwargs)
         for val, k in zip(args, ('base', kwname, 'force')):
             kw[k] = val
         git = GitHandler(local, local.ui)
         base, heads = git.get_refs(remote.path)
         newkw = {'base': base, kwname: heads}
         newkw.update(kw)
         kw = newkw
         if kwname == 'heads':
             r = orig(local, remote, **kw)
             return [x[0] for x in r]
         if kwname == 'onlyheads':
             del kw['base']
         return orig(local, remote, **kw)
     return orig(local, remote, *args, **kwargs)
开发者ID:mcclure,项目名称:hg-git,代码行数:24,代码来源:__init__.py

示例13: gremote

def gremote(ui, repo, *args):
    git = GitHandler(repo, ui)

    if len(args) == 0:
        git.remote_list()
    elif len(args) < 2:
        repo.ui.warn(_("must supply an action and a remote\n"))
    else:
        verb = args[0]
        nick = args[1]

        if verb == 'add':
            if len(args) == 3:
                git.remote_add(nick, args[2])
            else:
                repo.ui.warn(_("must supply a url to add as a remote\n"))
        elif verb == 'rm':
            git.remote_remove(nick)
        elif verb == 'show':
            git.remote_show(nick)
        else:
            repo.ui.warn(_("unrecognized command to gremote\n"))
开发者ID:SRabbelier,项目名称:hg-git,代码行数:22,代码来源:__init__.py

示例14: gclone

def gclone(ui, git_url, hg_repo_path=None):
    # determine new repo name
    if not hg_repo_path:
        hg_repo_path = hg.defaultdest(git_url)
        if hg_repo_path.endswith('.git'):
            hg_repo_path = hg_repo_path[:-4]
        hg_repo_path += '-hg'
    dest_repo = hg.repository(ui, hg_repo_path, create=True)

    # fetch the initial git data
    git = GitHandler(dest_repo, ui)
    git.remote_add('origin', git_url)
    git.fetch('origin')
    
    # checkout the tip
    node = git.remote_head('origin')
    hg.update(dest_repo, node)
开发者ID:zig,项目名称:hg-git,代码行数:17,代码来源:__init__.py

示例15: __init__

    def __init__(self, ui, path, create=True):
        dest = hg.defaultdest(path)

        if dest.endswith('.git'):
            dest = dest[:-4]

        # create the local hg repo on disk
        dest_repo = hg.repository(ui, dest, create=True)

        # fetch the initial git data
        git = GitHandler(dest_repo, ui)
        git.remote_add('origin', path)
        git.fetch('origin')

        # checkout the tip
        node = git.remote_head('origin')
        hg.update(dest_repo, node)

        # exit to stop normal `hg clone` flow
        raise SystemExit
开发者ID:SRabbelier,项目名称:hg-git,代码行数:20,代码来源:gitrepo.py


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