Example #1
0
 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')
Example #2
0
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]
Example #3
0
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]
Example #4
0
 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')
Example #5
0
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
Example #6
0
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
Example #7
0
def gsummary(ui, repo):
    ctx = repo[None]
    parents = ctx.parents()
    git = GitHandler(repo, ui)
    for p in parents:
        repo.ui.status(_('git-rev: %s\n') % git.map_git_get(p.hex()))
Example #8
0
def gsummary(ui, repo):
    ctx = repo[None]
    parents = ctx.parents()
    git = GitHandler(repo, ui)
    for p in parents:
        repo.ui.status(_('git-rev: %s\n') % git.map_git_get(p.hex()))