Exemplo n.º 1
0
def displaylocalbookmarks(ui, repo, opts, fm):
    # copy pasta from commands.py; need to patch core
    hexfn = fm.hexfunc
    marks = repo._bookmarks
    if len(marks) == 0 and (not fm or fm.isplain()):
        ui.status_err(_("no bookmarks set\n"))

    tracking = _readtracking(repo)
    distances = readdistancecache(repo)
    nq = not ui.quiet

    for bmark, n in sorted(pycompat.iteritems(marks)):
        current = repo._activebookmark
        if bmark == current:
            prefix, label = "*", "bookmarks.current bookmarks.active"
        else:
            prefix, label = " ", ""

        fm.startitem()
        if nq:
            fm.plain(" %s " % prefix, label=label)
        fm.write("bookmark", "%s", bmark, label=label)
        pad = " " * (25 - encoding.colwidth(bmark))
        rev = repo.changelog.rev(n)
        h = hexfn(n)
        if ui.plain():
            fm.condwrite(nq, "rev node", pad + " %d:%s", rev, h, label=label)
        else:
            fm.condwrite(nq, "node", pad + " %s", h, label=label)
        if ui.verbose and bmark in tracking:
            tracked = tracking[bmark]
            if bmark in distances:
                distance = distances[bmark]
            else:
                distance = calculatenamedistance(repo, bmark, tracked)
            if tracked:
                fmt = "%s"
                args = (tracked, )
                fields = ["tracking"]
                if distance != (0, 0) and distance != (None, None):
                    ahead, behind = distance
                    fmt += ": %s ahead, %s behind"
                    args += ahead, behind
                    fields += ["ahead", "behind"]
                pad = " " * (25 - encoding.colwidth(str(rev)) -
                             encoding.colwidth(str(h)))
                fm.write(" ".join(fields),
                         "%s[%s]" % (pad, fmt),
                         *args,
                         label=label)
                if distance != (None, None):
                    distances[bmark] = distance
        fm.data(active=(bmark == current))
        fm.plain("\n")

    # write distance cache
    writedistancecache(repo, distances)
Exemplo n.º 2
0
def _showfetchedbookmarks(ui, remote, bookmarks, opts, fm):
    remotepath = activepath(ui, remote)
    for bmark, n in sorted(pycompat.iteritems(bookmarks)):
        fm.startitem()
        if not ui.quiet:
            fm.plain("   ")
        fm.write("remotebookmark", "%s", joinremotename(remotepath, bmark))
        pad = " " * (25 - encoding.colwidth(bmark))
        fm.condwrite(not ui.quiet, "node", pad + " %s", n)
        fm.plain("\n")
Exemplo n.º 3
0
def _showbookmarks(ui, remotebookmarks, **opts):
    # Copy-paste from commands.py
    fm = ui.formatter("bookmarks", opts)
    for bmark, n in sorted(pycompat.iteritems(remotebookmarks)):
        fm.startitem()
        if not ui.quiet:
            fm.plain("   ")
        fm.write("bookmark", "%s", bmark)
        pad = " " * (25 - encoding.colwidth(bmark))
        fm.condwrite(not ui.quiet, "node", pad + " %s", n)
        fm.plain("\n")
    fm.end()
Exemplo n.º 4
0
def displayremotebookmarks(ui, repo, opts, fm):
    n = "remotebookmarks"
    if n not in repo.names:
        return
    ns = repo.names[n]
    color = ns.colorname
    label = "log." + color

    # it seems overkill to hide displaying hidden remote bookmarks
    useformatted = repo.ui.formatted

    for name in sorted(ns.listnames(repo)):
        nodes = ns.nodes(repo, name)
        if not nodes:
            continue

        node = nodes[0]
        ctx = repo[node]
        fm.startitem()

        if not ui.quiet:
            fm.plain("   ")

        padsize = max(25 - encoding.colwidth(name), 0)

        tmplabel = label
        if useformatted and ctx.obsolete():
            tmplabel = tmplabel + " changeset.obsolete"
        fm.write(color, "%s", name, label=label)
        if ui.plain():
            fmt = " " * padsize + " %d:%s"
            fm.condwrite(
                not ui.quiet,
                "rev node",
                fmt,
                ctx.rev(),
                fm.hexfunc(node),
                label=tmplabel,
            )
        else:
            fmt = " " * padsize + " %s"
            fm.condwrite(not ui.quiet,
                         "node",
                         fmt,
                         fm.hexfunc(node),
                         label=tmplabel)
        fm.plain("\n")
Exemplo n.º 5
0
 def pad(s, l):
     return s + " " * (l - encoding.colwidth(s))