Exemple #1
0
def buildmetadata(ctx):
    '''build content of .hg_archival.txt'''
    repo = ctx.repo()
    hex = ctx.hex()
    if ctx.rev() is None:
        hex = ctx.p1().hex()
        if ctx.dirty():
            hex += '+'

    base = 'repo: %s\nnode: %s\nbranch: %s\n' % (
        _rootctx(repo).hex(), hex, encoding.fromlocal(ctx.branch()))

    tags = ''.join('tag: %s\n' % t for t in ctx.tags()
                   if repo.tagtype(t) == 'global')
    if not tags:
        repo.ui.pushbuffer()
        opts = {'template': '{latesttag}\n{latesttagdistance}',
                'style': '', 'patch': None, 'git': None}
        cmdutil.show_changeset(repo.ui, repo, opts).show(ctx)
        ltags, dist = repo.ui.popbuffer().split('\n')
        ltags = ltags.split(':')
        if ctx.rev() is None:
            changessince = len(repo.revs('only(%d,%s)', ctx.p1(),
                                         ltags[0])) + 1
        else:
            changessince = len(repo.revs('only(%d,%s)', ctx.rev(), ltags[0]))
        tags = ''.join('latesttag: %s\n' % t for t in ltags)
        tags += 'latesttagdistance: %s\n' % dist
        tags += 'changessincelatesttag: %s\n' % changessince

    return base + tags
Exemple #2
0
def buildmetadata(ctx):
    '''build content of .hg_archival.txt'''
    repo = ctx.repo()
    hex = ctx.hex()
    if ctx.rev() is None:
        hex = ctx.p1().hex()
        if ctx.dirty():
            hex += '+'

    base = 'repo: %s\nnode: %s\nbranch: %s\n' % (
        _rootctx(repo).hex(), hex, encoding.fromlocal(ctx.branch()))

    tags = ''.join('tag: %s\n' % t for t in ctx.tags()
                   if repo.tagtype(t) == 'global')
    if not tags:
        repo.ui.pushbuffer()
        opts = {
            'template': '{latesttag}\n{latesttagdistance}',
            'style': '',
            'patch': None,
            'git': None
        }
        cmdutil.show_changeset(repo.ui, repo, opts).show(ctx)
        ltags, dist = repo.ui.popbuffer().split('\n')
        ltags = ltags.split(':')
        if ctx.rev() is None:
            changessince = len(repo.revs('only(%d,%s)', ctx.p1(),
                                         ltags[0])) + 1
        else:
            changessince = len(repo.revs('only(%d,%s)', ctx.rev(), ltags[0]))
        tags = ''.join('latesttag: %s\n' % t for t in ltags)
        tags += 'latesttagdistance: %s\n' % dist
        tags += 'changessincelatesttag: %s\n' % changessince

    return base + tags
Exemple #3
0
        def metadata():
            base = "repo: %s\nnode: %s\nbranch: %s\n" % (repo[0].hex(), hex(node), encoding.fromlocal(ctx.branch()))

            tags = "".join("tag: %s\n" % t for t in ctx.tags() if repo.tagtype(t) == "global")
            if not tags:
                repo.ui.pushbuffer()
                opts = {"template": "{latesttag}\n{latesttagdistance}", "style": "", "patch": None, "git": None}
                cmdutil.show_changeset(repo.ui, repo, opts).show(ctx)
                ltags, dist = repo.ui.popbuffer().split("\n")
                tags = "".join("latesttag: %s\n" % t for t in ltags.split(":"))
                tags += "latesttagdistance: %s\n" % dist

            return base + tags
Exemple #4
0
def outgoing(ui, repo, dest, opts):
    def recurse():
        ret = 1
        if opts.get('subrepos'):
            ctx = repo[None]
            for subpath in sorted(ctx.substate):
                sub = ctx.sub(subpath)
                ret = min(ret, sub.outgoing(ui, dest, opts))
        return ret

    limit = cmdutil.loglimit(opts)
    o, other = _outgoing(ui, repo, dest, opts)
    if not o:
        cmdutil.outgoinghooks(ui, repo, other, opts, o)
        return recurse()

    if opts.get('newest_first'):
        o.reverse()
    displayer = cmdutil.show_changeset(ui, repo, opts)
    count = 0
    for n in o:
        if limit is not None and count >= limit:
            break
        parents = [p for p in repo.changelog.parents(n) if p != nullid]
        if opts.get('no_merges') and len(parents) == 2:
            continue
        count += 1
        displayer.show(repo[n])
    displayer.close()
    cmdutil.outgoinghooks(ui, repo, other, opts, o)
    recurse()
    return 0  # exit code is zero since we found outgoing changes
Exemple #5
0
def _incoming(displaychlist,
              subreporecurse,
              ui,
              repo,
              source,
              opts,
              buffered=False):
    """
    Helper for incoming / gincoming.
    displaychlist gets called with
        (remoterepo, incomingchangesetlist, displayer) parameters,
    and is supposed to contain only code that can't be unified.
    """
    source, branches = parseurl(ui.expandpath(source), opts.get('branch'))
    other = peer(repo, opts, source)
    ui.status(_('comparing with %s\n') % util.hidepassword(source))
    revs, checkout = addbranchrevs(repo, other, branches, opts.get('rev'))

    if revs:
        revs = [other.lookup(rev) for rev in revs]
    other, chlist, cleanupfn = bundlerepo.getremotechanges(
        ui, repo, other, revs, opts["bundle"], opts["force"])
    try:
        if not chlist:
            ui.status(_("no changes found\n"))
            return subreporecurse()

        displayer = cmdutil.show_changeset(ui, other, opts, buffered)
        displaychlist(other, chlist, displayer)
        displayer.close()
    finally:
        cleanupfn()
    subreporecurse()
    return 0  # exit code is zero since we found incoming changes
Exemple #6
0
def outgoing(ui, repo, dest, opts):
    def recurse():
        ret = 1
        if opts.get('subrepos'):
            ctx = repo[None]
            for subpath in sorted(ctx.substate):
                sub = ctx.sub(subpath)
                ret = min(ret, sub.outgoing(ui, dest, opts))
        return ret

    limit = cmdutil.loglimit(opts)
    o = _outgoing(ui, repo, dest, opts)
    if o is None:
        return recurse()

    if opts.get('newest_first'):
        o.reverse()
    displayer = cmdutil.show_changeset(ui, repo, opts)
    count = 0
    for n in o:
        if limit is not None and count >= limit:
            break
        parents = [p for p in repo.changelog.parents(n) if p != nullid]
        if opts.get('no_merges') and len(parents) == 2:
            continue
        count += 1
        displayer.show(repo[n])
    displayer.close()
    recurse()
    return 0 # exit code is zero since we found outgoing changes
Exemple #7
0
def _incoming(displaychlist, subreporecurse, ui, repo, source,
        opts, buffered=False):
    """
    Helper for incoming / gincoming.
    displaychlist gets called with
        (remoterepo, incomingchangesetlist, displayer) parameters,
    and is supposed to contain only code that can't be unified.
    """
    source, branches = parseurl(ui.expandpath(source), opts.get('branch'))
    other = peer(repo, opts, source)
    ui.status(_('comparing with %s\n') % util.hidepassword(source))
    revs, checkout = addbranchrevs(repo, other, branches, opts.get('rev'))

    if revs:
        revs = [other.lookup(rev) for rev in revs]
    other, chlist, cleanupfn = bundlerepo.getremotechanges(ui, repo, other,
                                revs, opts["bundle"], opts["force"])
    try:
        if not chlist:
            ui.status(_("no changes found\n"))
            return subreporecurse()

        displayer = cmdutil.show_changeset(ui, other, opts, buffered)

        # XXX once graphlog extension makes it into core,
        # should be replaced by a if graph/else
        displaychlist(other, chlist, displayer)

        displayer.close()
    finally:
        cleanupfn()
    subreporecurse()
    return 0 # exit code is zero since we found incoming changes
        def metadata():
            base = 'repo: %s\nnode: %s\nbranch: %s\n' % (
                repo[0].hex(), hex(node), encoding.fromlocal(ctx.branch()))

            tags = ''.join('tag: %s\n' % t for t in ctx.tags()
                           if repo.tagtype(t) == 'global')
            if not tags:
                repo.ui.pushbuffer()
                opts = {'template': '{latesttag}\n{latesttagdistance}',
                        'style': '', 'patch': None, 'git': None}
                cmdutil.show_changeset(repo.ui, repo, opts).show(ctx)
                ltags, dist = repo.ui.popbuffer().split('\n')
                tags = ''.join('latesttag: %s\n' % t for t in ltags.split(':'))
                tags += 'latesttagdistance: %s\n' % dist

            return base + tags
Exemple #9
0
        def metadata():
            base = 'repo: %s\nnode: %s\nbranch: %s\n' % (hex(
                repo.changelog.node(0)), hex(node), ctx.branch())

            tags = ''.join('tag: %s\n' % t for t in ctx.tags()
                           if repo.tagtype(t) == 'global')
            if not tags:
                repo.ui.pushbuffer()
                opts = {
                    'template': '{latesttag}\n{latesttagdistance}',
                    'style': '',
                    'patch': None,
                    'git': None
                }
                cmdutil.show_changeset(repo.ui, repo, opts).show(ctx)
                ltags, dist = repo.ui.popbuffer().split('\n')
                tags = ''.join('latesttag: %s\n' % t for t in ltags.split(':'))
                tags += 'latesttagdistance: %s\n' % dist

            return base + tags
Exemple #10
0
        def metadata():
            base = 'repo: %s\nnode: %s\nbranch: %s\n' % (
                repo[0].hex(), hex(node), encoding.fromlocal(ctx.branch()))

            tags = ''.join('tag: %s\n' % t for t in ctx.tags()
                           if repo.tagtype(t) == 'global')
            if not tags:
                repo.ui.pushbuffer()
                opts = {
                    'template': '{latesttag}\n{latesttagdistance}',
                    'style': '',
                    'patch': None,
                    'git': None
                }
                cmdutil.show_changeset(repo.ui, repo, opts).show(ctx)
                ltags, dist = repo.ui.popbuffer().split('\n')
                ltags = ltags.split(':')
                changessince = len(repo.revs('only(.,%s)', ltags[0]))
                tags = ''.join('latesttag: %s\n' % t for t in ltags)
                tags += 'latesttagdistance: %s\n' % dist
                tags += 'changessincelatesttag: %s\n' % changessince

            return base + tags
Exemple #11
0
def _incoming(displaychlist,
              subreporecurse,
              ui,
              repo,
              source,
              opts,
              buffered=False):
    """
    Helper for incoming / gincoming.
    displaychlist gets called with
        (remoterepo, incomingchangesetlist, displayer) parameters,
    and is supposed to contain only code that can't be unified.
    """
    source, branches = parseurl(ui.expandpath(source), opts.get('branch'))
    other = repository(remoteui(repo, opts), source)
    ui.status(_('comparing with %s\n') % url.hidepassword(source))
    revs, checkout = addbranchrevs(repo, other, branches, opts.get('rev'))

    if revs:
        revs = [other.lookup(rev) for rev in revs]
    other, incoming, bundle = bundlerepo.getremotechanges(
        ui, repo, other, revs, opts["bundle"], opts["force"])
    if incoming is None:
        ui.status(_("no changes found\n"))
        return subreporecurse()

    try:
        chlist = other.changelog.nodesbetween(incoming, revs)[0]
        displayer = cmdutil.show_changeset(ui, other, opts, buffered)

        # XXX once graphlog extension makes it into core,
        # should be replaced by a if graph/else
        displaychlist(other, chlist, displayer)

        displayer.close()
    finally:
        if hasattr(other, 'close'):
            other.close()
        if bundle:
            os.unlink(bundle)
    subreporecurse()
    return 0  # exit code is zero since we found incoming changes