示例#1
0
def graph(web, req, tmpl):

    rev = webutil.changectx(web.repo, req).rev()
    bg_height = 39
    revcount = web.maxshortchanges
    if "revcount" in req.form:
        revcount = int(req.form.get("revcount", [revcount])[0])
        revcount = max(revcount, 1)
        tmpl.defaults["sessionvars"]["revcount"] = revcount

    lessvars = copy.copy(tmpl.defaults["sessionvars"])
    lessvars["revcount"] = max(revcount / 2, 1)
    morevars = copy.copy(tmpl.defaults["sessionvars"])
    morevars["revcount"] = revcount * 2

    max_rev = len(web.repo) - 1
    revcount = min(max_rev, revcount)
    revnode = web.repo.changelog.node(rev)
    revnode_hex = hex(revnode)
    uprev = min(max_rev, rev + revcount)
    downrev = max(0, rev - revcount)
    count = len(web.repo)
    changenav = webutil.revnavgen(rev, revcount, count, web.repo.changectx)
    startrev = rev
    # if starting revision is less than 60 set it to uprev
    if rev < web.maxshortchanges:
        startrev = uprev

    dag = graphmod.dagwalker(web.repo, range(startrev, downrev - 1, -1))
    tree = list(graphmod.colored(dag, web.repo))
    canvasheight = (len(tree) + 1) * bg_height - 27
    data = []
    for (id, type, ctx, vtx, edges) in tree:
        if type != graphmod.CHANGESET:
            continue
        node = str(ctx)
        age = templatefilters.age(ctx.date())
        desc = templatefilters.firstline(ctx.description())
        desc = cgi.escape(templatefilters.nonempty(desc))
        user = cgi.escape(templatefilters.person(ctx.user()))
        branch = ctx.branch()
        branch = branch, web.repo.branchtags().get(branch) == ctx.node()
        data.append((node, vtx, edges, desc, user, age, branch, ctx.tags(), ctx.bookmarks()))

    return tmpl(
        "graph",
        rev=rev,
        revcount=revcount,
        uprev=uprev,
        lessvars=lessvars,
        morevars=morevars,
        downrev=downrev,
        canvasheight=canvasheight,
        jsdata=data,
        bg_height=bg_height,
        node=revnode_hex,
        changenav=changenav,
    )
def graph(web, req, tmpl):

    rev = webutil.changectx(web.repo, req).rev()
    bg_height = 39
    revcount = web.maxshortchanges
    if 'revcount' in req.form:
        revcount = int(req.form.get('revcount', [revcount])[0])
        revcount = max(revcount, 1)
        tmpl.defaults['sessionvars']['revcount'] = revcount

    lessvars = copy.copy(tmpl.defaults['sessionvars'])
    lessvars['revcount'] = max(revcount / 2, 1)
    morevars = copy.copy(tmpl.defaults['sessionvars'])
    morevars['revcount'] = revcount * 2

    max_rev = len(web.repo) - 1
    revcount = min(max_rev, revcount)
    revnode = web.repo.changelog.node(rev)
    revnode_hex = hex(revnode)
    uprev = min(max_rev, rev + revcount)
    downrev = max(0, rev - revcount)
    count = len(web.repo)
    changenav = webutil.revnavgen(rev, revcount, count, web.repo.changectx)
    startrev = rev
    # if starting revision is less than 60 set it to uprev
    if rev < web.maxshortchanges:
        startrev = uprev

    dag = graphmod.dagwalker(web.repo, range(startrev, downrev - 1, -1))
    tree = list(graphmod.colored(dag, web.repo))
    canvasheight = (len(tree) + 1) * bg_height - 27
    data = []
    for (id, type, ctx, vtx, edges) in tree:
        if type != graphmod.CHANGESET:
            continue
        node = str(ctx)
        age = templatefilters.age(ctx.date())
        desc = templatefilters.firstline(ctx.description())
        desc = cgi.escape(templatefilters.nonempty(desc))
        user = cgi.escape(templatefilters.person(ctx.user()))
        branch = ctx.branch()
        branch = branch, web.repo.branchtags().get(branch) == ctx.node()
        data.append((node, vtx, edges, desc, user, age, branch, ctx.tags(),
                     ctx.bookmarks()))

    return tmpl('graph',
                rev=rev,
                revcount=revcount,
                uprev=uprev,
                lessvars=lessvars,
                morevars=morevars,
                downrev=downrev,
                canvasheight=canvasheight,
                jsdata=data,
                bg_height=bg_height,
                node=revnode_hex,
                changenav=changenav)
示例#3
0
    def graphdata(usetuples, **map):
        data = []

        row = 0
        for (id, type, ctx, vtx, edges) in tree:
            if type != graphmod.CHANGESET:
                continue
            node = str(ctx)
            age = templatefilters.age(ctx.date())
            desc = templatefilters.firstline(ctx.description())
            desc = cgi.escape(templatefilters.nonempty(desc))
            user = cgi.escape(templatefilters.person(ctx.user()))
            branch = cgi.escape(ctx.branch())
            try:
                branchnode = web.repo.branchtip(branch)
            except error.RepoLookupError:
                branchnode = None
            branch = branch, branchnode == ctx.node()

            if usetuples:
                data.append((node, vtx, edges, desc, user, age, branch,
                             [cgi.escape(x) for x in ctx.tags()
                              ], [cgi.escape(x) for x in ctx.bookmarks()]))
            else:
                edgedata = [
                    dict(col=edge[0],
                         nextcol=edge[1],
                         color=(edge[2] - 1) % 6 + 1,
                         width=edge[3],
                         bcolor=edge[4]) for edge in edges
                ]

                data.append(
                    dict(node=node,
                         col=vtx[0],
                         color=(vtx[1] - 1) % 6 + 1,
                         edges=edgedata,
                         row=row,
                         nextrow=row + 1,
                         desc=desc,
                         user=user,
                         age=age,
                         bookmarks=webutil.nodebookmarksdict(
                             web.repo, ctx.node()),
                         branches=webutil.nodebranchdict(web.repo, ctx),
                         inbranch=webutil.nodeinbranch(web.repo, ctx),
                         tags=webutil.nodetagsdict(web.repo, ctx.node())))

            row += 1

        return data
示例#4
0
def listcmd(ui, repo, pats, opts):
    """subcommand that displays the list of shelves"""
    pats = set(pats)
    width = 80
    if not ui.plain():
        width = ui.termwidth()
    namelabel = 'shelve.newest'
    for mtime, name in listshelves(repo):
        sname = util.split(name)[1]
        if pats and sname not in pats:
            continue
        ui.write(sname, label=namelabel)
        namelabel = 'shelve.name'
        if ui.quiet:
            ui.write('\n')
            continue
        ui.write(' ' * (16 - len(sname)))
        used = 16
        age = '(%s)' % templatefilters.age(util.makedate(mtime), abbrev=True)
        ui.write(age, label='shelve.age')
        ui.write(' ' * (12 - len(age)))
        used += 12
        fp = open(name + '.patch', 'rb')
        try:
            while True:
                line = fp.readline()
                if not line:
                    break
                if not line.startswith('#'):
                    desc = line.rstrip()
                    if ui.formatted():
                        desc = util.ellipsis(desc, width - used)
                    ui.write(desc)
                    break
            ui.write('\n')
            if not (opts['patch'] or opts['stat']):
                continue
            difflines = fp.readlines()
            if opts['patch']:
                for chunk, label in patch.difflabel(iter, difflines):
                    ui.write(chunk, label=label)
            if opts['stat']:
                for chunk, label in patch.diffstatui(difflines,
                                                     width=width,
                                                     git=True):
                    ui.write(chunk, label=label)
        finally:
            fp.close()
示例#5
0
    def graphdata(usetuples, **map):
        data = []

        row = 0
        for (id, type, ctx, vtx, edges) in tree:
            if type != graphmod.CHANGESET:
                continue
            node = str(ctx)
            age = templatefilters.age(ctx.date())
            desc = templatefilters.firstline(ctx.description())
            desc = cgi.escape(templatefilters.nonempty(desc))
            user = cgi.escape(templatefilters.person(ctx.user()))
            branch = cgi.escape(ctx.branch())
            try:
                branchnode = web.repo.branchtip(branch)
            except error.RepoLookupError:
                branchnode = None
            branch = branch, branchnode == ctx.node()

            if usetuples:
                data.append((node, vtx, edges, desc, user, age, branch,
                             [cgi.escape(x) for x in ctx.tags()],
                             [cgi.escape(x) for x in ctx.bookmarks()]))
            else:
                edgedata = [dict(col=edge[0], nextcol=edge[1],
                                 color=(edge[2] - 1) % 6 + 1,
                                 width=edge[3], bcolor=edge[4])
                            for edge in edges]

                data.append(
                    dict(node=node,
                         col=vtx[0],
                         color=(vtx[1] - 1) % 6 + 1,
                         edges=edgedata,
                         row=row,
                         nextrow=row + 1,
                         desc=desc,
                         user=user,
                         age=age,
                         bookmarks=webutil.nodebookmarksdict(
                            web.repo, ctx.node()),
                         branches=webutil.nodebranchdict(web.repo, ctx),
                         inbranch=webutil.nodeinbranch(web.repo, ctx),
                         tags=webutil.nodetagsdict(web.repo, ctx.node())))

            row += 1

        return data
示例#6
0
    def graphdata(usetuples, **map):
        data = []

        row = 0
        for (id, type, ctx, vtx, edges) in tree:
            if type != graphmod.CHANGESET:
                continue
            node = str(ctx)
            age = templatefilters.age(ctx.date())
            desc = templatefilters.firstline(ctx.description())
            desc = cgi.escape(templatefilters.nonempty(desc))
            user = cgi.escape(templatefilters.person(ctx.user()))
            branch = cgi.escape(ctx.branch())
            try:
                branchnode = web.repo.branchtip(branch)
            except error.RepoLookupError:
                branchnode = None
            branch = branch, branchnode == ctx.node()

            if usetuples:
                data.append((node, vtx, edges, desc, user, age, branch,
                             [cgi.escape(x) for x in ctx.tags()],
                             [cgi.escape(x) for x in ctx.bookmarks()]))
            else:
                edgedata = [{'col': edge[0], 'nextcol': edge[1],
                             'color': (edge[2] - 1) % 6 + 1,
                             'width': edge[3], 'bcolor': edge[4]}
                            for edge in edges]

                data.append(
                    {'node': node,
                     'col': vtx[0],
                     'color': (vtx[1] - 1) % 6 + 1,
                     'edges': edgedata,
                     'row': row,
                     'nextrow': row + 1,
                     'desc': desc,
                     'user': user,
                     'age': age,
                     'bookmarks': webutil.nodebookmarksdict(
                         web.repo, ctx.node()),
                     'branches': webutil.nodebranchdict(web.repo, ctx),
                     'inbranch': webutil.nodeinbranch(web.repo, ctx),
                     'tags': webutil.nodetagsdict(web.repo, ctx.node())})

            row += 1

        return data
示例#7
0
def listcmd(ui, repo, pats, opts):
    """subcommand that displays the list of shelves"""
    pats = set(pats)
    width = 80
    if not ui.plain():
        width = ui.termwidth()
    namelabel = 'shelve.newest'
    for mtime, name in listshelves(repo):
        sname = util.split(name)[1]
        if pats and sname not in pats:
            continue
        ui.write(sname, label=namelabel)
        namelabel = 'shelve.name'
        if ui.quiet:
            ui.write('\n')
            continue
        ui.write(' ' * (16 - len(sname)))
        used = 16
        age = '(%s)' % templatefilters.age(util.makedate(mtime), abbrev=True)
        ui.write(age, label='shelve.age')
        ui.write(' ' * (12 - len(age)))
        used += 12
        fp = open(name + '.patch', 'rb')
        try:
            while True:
                line = fp.readline()
                if not line:
                    break
                if not line.startswith('#'):
                    desc = line.rstrip()
                    if ui.formatted():
                        desc = util.ellipsis(desc, width - used)
                    ui.write(desc)
                    break
            ui.write('\n')
            if not (opts['patch'] or opts['stat']):
                continue
            difflines = fp.readlines()
            if opts['patch']:
                for chunk, label in patch.difflabel(iter, difflines):
                    ui.write(chunk, label=label)
            if opts['stat']:
                for chunk, label in patch.diffstatui(difflines, width=width,
                                                     git=True):
                    ui.write(chunk, label=label)
        finally:
            fp.close()
示例#8
0
def graph(web, req, tmpl):
    rev = webutil.changectx(web.repo, req).rev()
    bg_height = 39

    revcount = 25
    if 'revcount' in req.form:
        revcount = int(req.form.get('revcount', [revcount])[0])
        tmpl.defaults['sessionvars']['revcount'] = revcount

    lessvars = copy.copy(tmpl.defaults['sessionvars'])
    lessvars['revcount'] = revcount / 2
    morevars = copy.copy(tmpl.defaults['sessionvars'])
    morevars['revcount'] = revcount * 2

    max_rev = len(web.repo) - 1
    revcount = min(max_rev, revcount)
    revnode = web.repo.changelog.node(rev)
    revnode_hex = hex(revnode)
    uprev = min(max_rev, rev + revcount)
    downrev = max(0, rev - revcount)
    count = len(web.repo)
    changenav = webutil.revnavgen(rev, revcount, count, web.repo.changectx)

    dag = graphmod.revisions(web.repo, rev, downrev)
    tree = list(graphmod.colored(dag))
    canvasheight = (len(tree) + 1) * bg_height - 27;
    data = []
    for (id, type, ctx, vtx, edges) in tree:
        if type != graphmod.CHANGESET:
            continue
        node = short(ctx.node())
        age = templatefilters.age(ctx.date())
        desc = templatefilters.firstline(ctx.description())
        desc = cgi.escape(templatefilters.nonempty(desc))
        user = cgi.escape(templatefilters.person(ctx.user()))
        branch = ctx.branch()
        branch = branch, web.repo.branchtags().get(branch) == ctx.node()
        data.append((node, vtx, edges, desc, user, age, branch, ctx.tags()))

    return tmpl('graph', rev=rev, revcount=revcount, uprev=uprev,
                lessvars=lessvars, morevars=morevars, downrev=downrev,
                canvasheight=canvasheight, jsdata=data, bg_height=bg_height,
                node=revnode_hex, changenav=changenav)
示例#9
0
def display_age(ctx):
    return templatefilters.age(ctx.date())