mercurial/debugcommands.py
changeset 34025 626a28f30dbd
parent 33553 9c4e2aa0a239
child 34120 07f09995e857
equal deleted inserted replaced
34024:19b8eee8b4ec 34025:626a28f30dbd
     5 # This software may be used and distributed according to the terms of the
     5 # This software may be used and distributed according to the terms of the
     6 # GNU General Public License version 2 or any later version.
     6 # GNU General Public License version 2 or any later version.
     7 
     7 
     8 from __future__ import absolute_import
     8 from __future__ import absolute_import
     9 
     9 
       
    10 import collections
    10 import difflib
    11 import difflib
    11 import errno
    12 import errno
    12 import operator
    13 import operator
    13 import os
    14 import os
    14 import random
    15 import random
   321     for phase in phases.allphases:
   322     for phase in phases.allphases:
   322         for head in headsbyphase[phase]:
   323         for head in headsbyphase[phase]:
   323             ui.write(indent_string)
   324             ui.write(indent_string)
   324             ui.write('%s %s\n' % (hex(head), phases.phasenames[phase]))
   325             ui.write('%s %s\n' % (hex(head), phases.phasenames[phase]))
   325 
   326 
       
   327 def _quasirepr(thing):
       
   328     if isinstance(thing, (dict, util.sortdict, collections.OrderedDict)):
       
   329         return '{%s}' % (
       
   330             b', '.join(b'%s: %s' % (k, thing[k]) for k in sorted(thing)))
       
   331     return pycompat.bytestr(repr(thing))
       
   332 
   326 def _debugbundle2(ui, gen, all=None, **opts):
   333 def _debugbundle2(ui, gen, all=None, **opts):
   327     """lists the contents of a bundle2"""
   334     """lists the contents of a bundle2"""
   328     if not isinstance(gen, bundle2.unbundle20):
   335     if not isinstance(gen, bundle2.unbundle20):
   329         raise error.Abort(_('not a bundle2 file'))
   336         raise error.Abort(_('not a bundle2 file'))
   330     ui.write(('Stream params: %s\n' % repr(gen.params)))
   337     ui.write(('Stream params: %s\n' % _quasirepr(gen.params)))
   331     parttypes = opts.get(r'part_type', [])
   338     parttypes = opts.get(r'part_type', [])
   332     for part in gen.iterparts():
   339     for part in gen.iterparts():
   333         if parttypes and part.type not in parttypes:
   340         if parttypes and part.type not in parttypes:
   334             continue
   341             continue
   335         ui.write('%s -- %r\n' % (part.type, repr(part.params)))
   342         ui.write('%s -- %s\n' % (part.type, _quasirepr(part.params)))
   336         if part.type == 'changegroup':
   343         if part.type == 'changegroup':
   337             version = part.params.get('version', '01')
   344             version = part.params.get('version', '01')
   338             cg = changegroup.getunbundler(version, part, 'UN')
   345             cg = changegroup.getunbundler(version, part, 'UN')
   339             _debugchangegroup(ui, cg, all=all, indent=4, **opts)
   346             _debugchangegroup(ui, cg, all=all, indent=4, **opts)
   340         if part.type == 'obsmarkers':
   347         if part.type == 'obsmarkers':