hgext3rd/evolve/__init__.py
changeset 2350 ea816b5c1cf6
parent 2349 521a18a10a06
child 2396 c1485ebdd6b9
equal deleted inserted replaced
2349:521a18a10a06 2350:ea816b5c1cf6
  3265     _('hg debugobshistory [OPTION]... [REV]'))
  3265     _('hg debugobshistory [OPTION]... [REV]'))
  3266 def debugobshistory(ui, repo, *revs, **opts):
  3266 def debugobshistory(ui, repo, *revs, **opts):
  3267     revs = scmutil.revrange(repo, revs)
  3267     revs = scmutil.revrange(repo, revs)
  3268     fm = ui.formatter('debugobshistory', opts)
  3268     fm = ui.formatter('debugobshistory', opts)
  3269 
  3269 
  3270     for rev in revs:
  3270     revs.reverse()
  3271         _debugobshistorysingle(ui, fm, repo, rev)
  3271     _debugobshistorysingle(fm, repo, revs)
  3272 
  3272 
  3273     fm.end()
  3273     fm.end()
  3274 
  3274 
  3275 def _debugobshistorysingle(ui, fm, repo, rev):
  3275 def _debugobshistorysingle(fm, repo, revs):
  3276     """ Display the obsolescence history for a single revision
  3276     """ Display the obsolescence history for a single revision
  3277     """
  3277     """
  3278     precursors = repo.obsstore.precursors
  3278     precursors = repo.obsstore.precursors
  3279     successors = repo.obsstore.successors
  3279     successors = repo.obsstore.successors
  3280     nodec = repo.changelog.node
  3280     nodec = repo.changelog.node
  3281     nodes = [nodec(rev)]
  3281     nodes = [nodec(r) for r in revs]
       
  3282 
       
  3283     seen = set(nodes)
  3282 
  3284 
  3283     while nodes:
  3285     while nodes:
  3284         ctxnode = nodes.pop()
  3286         ctxnode = nodes.pop()
  3285         _debugobshistorydisplaynode(ui, fm, repo, ctxnode)
  3287 
       
  3288         _debugobshistorydisplaynode(fm, repo, ctxnode)
  3286 
  3289 
  3287         succs = successors.get(ctxnode, ())
  3290         succs = successors.get(ctxnode, ())
  3288 
  3291 
  3289         markerfm = fm.nested("debugobshistory.markers")
  3292         markerfm = fm.nested("debugobshistory.markers")
  3290         for successor in sorted(succs):
  3293         for successor in sorted(succs):
  3291             _debugobshistorydisplaymarker(markerfm, repo, successor)
  3294             _debugobshistorydisplaymarker(markerfm, repo, successor)
  3292         markerfm.end()
  3295         markerfm.end()
  3293 
  3296 
  3294         precs = precursors.get(ctxnode, ())
  3297         precs = precursors.get(ctxnode, ())
  3295         nodes.extend(precursor[0] for precursor in sorted(precs))
  3298         for p in sorted(precs):
  3296 
  3299             # Only show nodes once
  3297 def _debugobshistorydisplaynode(ui, fm, repo, node):
  3300             if p[0] not in seen:
       
  3301                 seen.add(p[0])
       
  3302                 nodes.append(p[0])
       
  3303 
       
  3304 def _debugobshistorydisplaynode(fm, repo, node):
  3298     if node in repo.unfiltered():
  3305     if node in repo.unfiltered():
  3299         _debugobshistorydisplayctx(fm, repo.unfiltered()[node])
  3306         _debugobshistorydisplayctx(fm, repo.unfiltered()[node])
  3300     else:
  3307     else:
  3301         _debugobshistorydisplaymissingctx(fm, node)
  3308         _debugobshistorydisplaymissingctx(fm, node)
  3302 
  3309