Example #1
0
    def changelist(limit=0, **map):
        l = [] # build a list in forward order for efficiency
        for i in xrange(start, end):
            ctx = web.repo[i]
            n = ctx.node()
            showtags = webutil.showtag(web.repo, tmpl, 'changelogtag', n)
            files = webutil.listfilediffs(tmpl, ctx.files(), n, web.maxfiles)

            l.insert(0, {"parity": parity.next(),
                         "author": ctx.user(),
                         "parent": webutil.parents(ctx, i - 1),
                         "child": webutil.children(ctx, i + 1),
                         "changelogtag": showtags,
                         "desc": ctx.description(),
                         "date": ctx.date(),
                         "files": files,
                         "rev": i,
                         "node": hex_(n),
                         "tags": webutil.nodetagsdict(web.repo, n),
                         "inbranch": webutil.nodeinbranch(web.repo, ctx),
                         "branches": webutil.nodebranchdict(web.repo, ctx)
                        })

        if limit > 0:
            l = l[:limit]

        for e in l:
            yield e
Example #2
0
def create_entry(ctx, web, pushid, user, date, node, mergehidden, parity, pushcount=None):
    """Creates an entry to be yielded in the `changelist` generator

    `pushcount` will be non-None when we are generating an entry for the first change
    in a given push
    """
    repo = web.repo
    n = ctx.node()
    ctxfiles = ctx.files()
    firstchange = pushcount is not None

    mergerollupval = templateutil.mappinglist(
        [{'count': pushcount}]
        if firstchange and mergehidden == 'hidden'
        else []
    )

    pushval = templateutil.mappinglist(
        [{"date": localdate(date), "user": user}]
        if firstchange
        else []
    )

    # TRACKING hg47
    # Call the function with whichever signature is correct
    if util.versiontuple(n=2) >= (4, 7):
        filediffs = webutil.listfilediffs(ctxfiles, node, len(ctxfiles))
    else:
        filediffs = webutil.listfilediffs(web.tmpl, ctxfiles, node, len(ctxfiles))

    return {
        "author": ctx.user(),
        "desc": ctx.description(),
        "files": filediffs,
        "rev": ctx.rev(),
        "node": hex(n),
        "parents": [c.hex() for c in ctx.parents()],
        "tags": webutil.nodetagsdict(repo, n),
        "branches": webutil.nodebranchdict(repo, ctx),
        "inbranch": webutil.nodeinbranch(repo, ctx),
        "hidden": mergehidden,
        "mergerollup": mergerollupval,
        "id": pushid,
        "parity": parity,
        "push": pushval,
    }
Example #3
0
def create_entry(ctx,
                 web,
                 pushid,
                 user,
                 date,
                 node,
                 mergehidden,
                 parity,
                 pushcount=None):
    """Creates an entry to be yielded in the `changelist` generator

    `pushcount` will be non-None when we are generating an entry for the first change
    in a given push
    """
    repo = web.repo
    n = ctx.node()
    ctxfiles = ctx.files()
    firstchange = pushcount is not None

    mergerollupval = templateutil.mappinglist([{
        b'count': pushcount
    }] if firstchange and mergehidden == b'hidden' else [])

    pushval = templateutil.mappinglist([{
        b"date": localdate(date),
        b"user": user
    }] if firstchange else [])

    filediffs = webutil.listfilediffs(ctxfiles, node, len(ctxfiles))

    return {
        b"author": ctx.user(),
        b"desc": ctx.description(),
        b"files": filediffs,
        b"rev": ctx.rev(),
        b"node": hex(n),
        b"parents": [c.hex() for c in ctx.parents()],
        b"tags": webutil.nodetagsdict(repo, n),
        b"branches": webutil.nodebranchdict(repo, ctx),
        b"inbranch": webutil.nodeinbranch(repo, ctx),
        b"hidden": mergehidden,
        b"mergerollup": mergerollupval,
        b"id": pushid,
        b"parity": parity,
        b"push": pushval,
    }
Example #4
0
def status(web, tmpl, ctx, path, st, datefmt='isodate'):
    """\
    Based on hgweb.manifest, adapted to included features found in
    hg status.

    Initial parameters are the same as manifest.  New parameters:

    ctx
        - should be the workingctx
    st 
        - the tuple returned from repo.status
    datefmt
        - the date format of the full filelist.
    """

    changetypes = (
        'modified', 'added', 'removed', 'deleted', 'unknown', 'ignored',
        'clean',
    )
    # status listing
    statlist = dict(zip(changetypes, st))
    filestatlist = {}
    for k, v in statlist.iteritems():
        for f in v:
            filestatlist[f] = k
    mf = ctx.manifest()
    node = ctx.node()

    files = {}
    parity = paritygen(web.stripecount)

    if path and path[-1] != "/":
        path += "/"
    l = len(path)
    abspath = "/" + path

    for f, n in mf.items():
        if f[:l] != path:
            continue
        remain = f[l:]
        if "/" in remain:
            short = remain[:remain.index("/") + 1] # bleah
            files[short] = (f, None)
        else:
            short = os.path.basename(remain)
            files[short] = (f, n)

    def filelist(**map):
        fl = files.keys()
        fl.sort()
        for f in fl:
            full, fnode = files[f]
            if not fnode:
                continue
            fctx = ctx.filectx(full)
            yield {"file": full,
                   "status": filestatlist[full],
                   "parity": parity.next(),
                   "basename": f,
                   "date": fctx.changectx().date(),
                   "size": fctx.size(),
                   "permissions": mf.flags(full),
                   }

    def dirlist(**map):
        fl = files.keys()
        fl.sort()
        for f in fl:
            full, fnode = files[f]
            if fnode:
                continue

            yield {"parity": parity.next(),
                   "path": "%s%s" % (abspath, f),
                   "basename": f[:-1]}

    def fulllist(**map):
        for i in dirlist():
            # remove first slash
            i['file'] = i['path'][1:]
            i['permissions'] = 'drwxr-xr-x'
            yield i
        for i in filelist():
            i['date'] = utils.filter(i['date'], datefmt)
            i['permissions'] = utils.filter(i['permissions'], 'permissions')
            yield i

    return tmpl("status",
                 rev=ctx.rev(),
                 node=hex_(node),
                 path=abspath,
                 up=webutil.up(abspath),
                 upparity=parity.next(),
                 fentries=filelist,
                 dentries=dirlist,
                 aentries=fulllist,
                 archives=[], # web.archivelist(hex_(node)),
                 tags=webutil.nodetagsdict(web.repo, ctx),
                 branches=webutil.nodebranchdict(web.repo, ctx))