mercurial/hgweb/webcommands.py
changeset 35566 baca93a47992
parent 35530 acd8a2454b47
child 36248 0ef50a5e3ae1
equal deleted inserted replaced
35565:bdae51a83dfb 35566:baca93a47992
    11 import mimetypes
    11 import mimetypes
    12 import os
    12 import os
    13 import re
    13 import re
    14 
    14 
    15 from ..i18n import _
    15 from ..i18n import _
    16 from ..node import hex, short
    16 from ..node import hex, nullid, short
    17 
    17 
    18 from .common import (
    18 from .common import (
    19     ErrorResponse,
    19     ErrorResponse,
    20     HTTP_FORBIDDEN,
    20     HTTP_FORBIDDEN,
    21     HTTP_NOT_FOUND,
    21     HTTP_NOT_FOUND,
  1246         dag = graphmod.dagwalker(web.repo, smartset.baseset(revs))
  1246         dag = graphmod.dagwalker(web.repo, smartset.baseset(revs))
  1247         # As we said one line above... not lazy.
  1247         # As we said one line above... not lazy.
  1248         tree = list(item for item in graphmod.colored(dag, web.repo)
  1248         tree = list(item for item in graphmod.colored(dag, web.repo)
  1249                     if item[1] == graphmod.CHANGESET)
  1249                     if item[1] == graphmod.CHANGESET)
  1250 
  1250 
       
  1251     def nodecurrent(ctx):
       
  1252         wpnodes = web.repo.dirstate.parents()
       
  1253         if wpnodes[1] == nullid:
       
  1254             wpnodes = wpnodes[:1]
       
  1255         if ctx.node() in wpnodes:
       
  1256             return '@'
       
  1257         return ''
       
  1258 
       
  1259     def nodesymbol(ctx):
       
  1260         if ctx.obsolete():
       
  1261             return 'x'
       
  1262         elif ctx.isunstable():
       
  1263             return '*'
       
  1264         elif ctx.closesbranch():
       
  1265             return '_'
       
  1266         else:
       
  1267             return 'o'
       
  1268 
  1251     def fulltree():
  1269     def fulltree():
  1252         pos = web.repo[graphtop].rev()
  1270         pos = web.repo[graphtop].rev()
  1253         tree = []
  1271         tree = []
  1254         if pos != -1:
  1272         if pos != -1:
  1255             revs = web.repo.changelog.revs(pos, lastrev)
  1273             revs = web.repo.changelog.revs(pos, lastrev)
  1258                         if item[1] == graphmod.CHANGESET)
  1276                         if item[1] == graphmod.CHANGESET)
  1259         return tree
  1277         return tree
  1260 
  1278 
  1261     def jsdata():
  1279     def jsdata():
  1262         return [{'node': pycompat.bytestr(ctx),
  1280         return [{'node': pycompat.bytestr(ctx),
       
  1281                  'graphnode': nodecurrent(ctx) + nodesymbol(ctx),
  1263                  'vertex': vtx,
  1282                  'vertex': vtx,
  1264                  'edges': edges}
  1283                  'edges': edges}
  1265                 for (id, type, ctx, vtx, edges) in fulltree()]
  1284                 for (id, type, ctx, vtx, edges) in fulltree()]
  1266 
  1285 
  1267     def nodes():
  1286     def nodes():