mercurial/commands.py
changeset 29057 add26c663aad
parent 29029 224dd889ecd0
child 29061 fc88a942fe8d
equal deleted inserted replaced
29056:e2178f7d17c0 29057:add26c663aad
  2087             return
  2087             return
  2088 
  2088 
  2089         gen = exchange.readbundle(ui, f, bundlepath)
  2089         gen = exchange.readbundle(ui, f, bundlepath)
  2090         if isinstance(gen, bundle2.unbundle20):
  2090         if isinstance(gen, bundle2.unbundle20):
  2091             return _debugbundle2(ui, gen, all=all, **opts)
  2091             return _debugbundle2(ui, gen, all=all, **opts)
  2092         if all:
  2092         _debugchangegroup(ui, gen, all=all, **opts)
  2093             ui.write(("format: id, p1, p2, cset, delta base, len(delta)\n"))
  2093 
  2094 
  2094 def _debugchangegroup(ui, gen, all=None, indent=0, **opts):
  2095             def showchunks(named):
  2095     indent_string = ' ' * indent
  2096                 ui.write("\n%s\n" % named)
  2096     if all:
  2097                 chain = None
  2097         ui.write("%sformat: id, p1, p2, cset, delta base, len(delta)\n"
  2098                 while True:
  2098                  % indent_string)
  2099                     chunkdata = gen.deltachunk(chain)
  2099 
  2100                     if not chunkdata:
  2100         def showchunks(named):
  2101                         break
  2101             ui.write("\n%s%s\n" % (indent_string, named))
  2102                     node = chunkdata['node']
       
  2103                     p1 = chunkdata['p1']
       
  2104                     p2 = chunkdata['p2']
       
  2105                     cs = chunkdata['cs']
       
  2106                     deltabase = chunkdata['deltabase']
       
  2107                     delta = chunkdata['delta']
       
  2108                     ui.write("%s %s %s %s %s %s\n" %
       
  2109                              (hex(node), hex(p1), hex(p2),
       
  2110                               hex(cs), hex(deltabase), len(delta)))
       
  2111                     chain = node
       
  2112 
       
  2113             chunkdata = gen.changelogheader()
       
  2114             showchunks("changelog")
       
  2115             chunkdata = gen.manifestheader()
       
  2116             showchunks("manifest")
       
  2117             while True:
       
  2118                 chunkdata = gen.filelogheader()
       
  2119                 if not chunkdata:
       
  2120                     break
       
  2121                 fname = chunkdata['filename']
       
  2122                 showchunks(fname)
       
  2123         else:
       
  2124             if isinstance(gen, bundle2.unbundle20):
       
  2125                 raise error.Abort(_('use debugbundle2 for this file'))
       
  2126             chunkdata = gen.changelogheader()
       
  2127             chain = None
  2102             chain = None
  2128             while True:
  2103             while True:
  2129                 chunkdata = gen.deltachunk(chain)
  2104                 chunkdata = gen.deltachunk(chain)
  2130                 if not chunkdata:
  2105                 if not chunkdata:
  2131                     break
  2106                     break
  2132                 node = chunkdata['node']
  2107                 node = chunkdata['node']
  2133                 ui.write("%s\n" % hex(node))
  2108                 p1 = chunkdata['p1']
       
  2109                 p2 = chunkdata['p2']
       
  2110                 cs = chunkdata['cs']
       
  2111                 deltabase = chunkdata['deltabase']
       
  2112                 delta = chunkdata['delta']
       
  2113                 ui.write("%s%s %s %s %s %s %s\n" %
       
  2114                          (indent_string, hex(node), hex(p1), hex(p2),
       
  2115                           hex(cs), hex(deltabase), len(delta)))
  2134                 chain = node
  2116                 chain = node
  2135 
  2117 
  2136 def _debugbundle2(ui, gen, **opts):
  2118         chunkdata = gen.changelogheader()
       
  2119         showchunks("changelog")
       
  2120         chunkdata = gen.manifestheader()
       
  2121         showchunks("manifest")
       
  2122         while True:
       
  2123             chunkdata = gen.filelogheader()
       
  2124             if not chunkdata:
       
  2125                 break
       
  2126             fname = chunkdata['filename']
       
  2127             showchunks(fname)
       
  2128     else:
       
  2129         if isinstance(gen, bundle2.unbundle20):
       
  2130             raise error.Abort(_('use debugbundle2 for this file'))
       
  2131         chunkdata = gen.changelogheader()
       
  2132         chain = None
       
  2133         while True:
       
  2134             chunkdata = gen.deltachunk(chain)
       
  2135             if not chunkdata:
       
  2136                 break
       
  2137             node = chunkdata['node']
       
  2138             ui.write("%s%s\n" % (indent_string, hex(node)))
       
  2139             chain = node
       
  2140 
       
  2141 def _debugbundle2(ui, gen, all=None, **opts):
  2137     """lists the contents of a bundle2"""
  2142     """lists the contents of a bundle2"""
  2138     if not isinstance(gen, bundle2.unbundle20):
  2143     if not isinstance(gen, bundle2.unbundle20):
  2139         raise error.Abort(_('not a bundle2 file'))
  2144         raise error.Abort(_('not a bundle2 file'))
  2140     ui.write(('Stream params: %s\n' % repr(gen.params)))
  2145     ui.write(('Stream params: %s\n' % repr(gen.params)))
  2141     for part in gen.iterparts():
  2146     for part in gen.iterparts():
  2142         ui.write('%s -- %r\n' % (part.type, repr(part.params)))
  2147         ui.write('%s -- %r\n' % (part.type, repr(part.params)))
  2143         if part.type == 'changegroup':
  2148         if part.type == 'changegroup':
  2144             version = part.params.get('version', '01')
  2149             version = part.params.get('version', '01')
  2145             cg = changegroup.getunbundler(version, part, 'UN')
  2150             cg = changegroup.getunbundler(version, part, 'UN')
  2146             chunkdata = cg.changelogheader()
  2151             _debugchangegroup(ui, cg, all=all, indent=4, **opts)
  2147             chain = None
       
  2148             while True:
       
  2149                 chunkdata = cg.deltachunk(chain)
       
  2150                 if not chunkdata:
       
  2151                     break
       
  2152                 node = chunkdata['node']
       
  2153                 ui.write("    %s\n" % hex(node))
       
  2154                 chain = node
       
  2155 
  2152 
  2156 @command('debugcreatestreamclonebundle', [], 'FILE')
  2153 @command('debugcreatestreamclonebundle', [], 'FILE')
  2157 def debugcreatestreamclonebundle(ui, repo, fname):
  2154 def debugcreatestreamclonebundle(ui, repo, fname):
  2158     """create a stream clone bundle file
  2155     """create a stream clone bundle file
  2159 
  2156