Esempio n. 1
0
def smartdate(context, mapping, args):
    """Date.  Returns one of two values depending on whether the date provided
    is in the past and recent or not."""
    date = templater.evalfuncarg(context, mapping, args[0])
    threshold = templater.evalinteger(context, mapping, args[1])
    now = time.time()
    then = date[0]
    if now - threshold <= then <= now:
        return templater.evalstring(context, mapping, args[2])
    else:
        return templater.evalstring(context, mapping, args[3])
Esempio n. 2
0
def showdonecommits(context, mapping, args):
    """String.  Changectxs reverseindex repo states ago."""
    reverseindex = templater.evalinteger(
        context, mapping, args[0], _("donecommits needs an integer argument"))
    repo = mapping["ctx"]._repo
    ctx = mapping["ctx"]
    hexnodes = _donehexnodes(repo, reverseindex)
    if ctx.node() in hexnodes:
        result = ctx.hex()
    else:
        result = None
    return result
Esempio n. 3
0
def oldworkingparenttemplate(context, mapping, args):
    """String. Workingcopyparent reverseindex repo states ago."""
    reverseindex = templater.evalinteger(
        context, mapping, args[0],
        _("undonecommits needs an integer argument"))
    repo = mapping["ctx"]._repo
    ctx = mapping["ctx"]
    revstring = revsetlang.formatspec("oldworkingcopyparent(%d)", reverseindex)
    nodes = list(repo.nodes(revstring))
    if ctx.node() in nodes:
        result = ctx.hex()
    else:
        result = None
    return result
Esempio n. 4
0
def showoldbookmarks(context, mapping, args):
    """List of Strings. Bookmarks that used to be at the changectx reverseindex
    repo states ago."""
    reverseindex = templater.evalinteger(
        context, mapping, args[0], _("oldbookmarks needs an integer argument"))
    repo = mapping["ctx"]._repo
    ctx = mapping["ctx"]
    oldmarks = _oldmarks(repo, reverseindex)
    bookmarks = []
    ctxhex = ctx.hex()
    for kv in oldmarks:
        if kv[1] == ctxhex:
            bookmarks.append(kv[0])
    active = repo._activebookmark
    makemap = lambda v: {"bookmark": v, "active": active, "current": active}
    f = templatekw._showlist("bookmark", bookmarks, mapping)
    return templatekw._hybrid(f, bookmarks, makemap, lambda x: x["bookmark"])
Esempio n. 5
0
def removedbookmarks(context, mapping, args):
    """List of Strings.  Bookmarks that have been moved or removed from a given
    changectx by reverseindex repo state."""
    reverseindex = templater.evalinteger(
        context, mapping, args[0],
        _("removedbookmarks needs an integer argument"))
    repo = mapping["ctx"]._repo
    ctx = mapping["ctx"]
    currentbookmarks = mapping["ctx"].bookmarks()
    oldmarks = _oldmarks(repo, reverseindex)
    oldbookmarks = []
    ctxhex = ctx.hex()
    for kv in oldmarks:
        if kv[1] == ctxhex:
            oldbookmarks.append(kv[0])
    bookmarks = list(set(currentbookmarks) - set(oldbookmarks))
    active = repo._activebookmark
    makemap = lambda v: {"bookmark": v, "active": active, "current": active}
    f = templatekw._showlist("bookmark", bookmarks, mapping)
    return templatekw._hybrid(f, bookmarks, makemap, lambda x: x["bookmark"])