mercurial/commands.py
changeset 30538 bd5c4320b5a8
parent 30537 22683f2f8100
child 30616 cbc61b1b52ea
equal deleted inserted replaced
30537:22683f2f8100 30538:bd5c4320b5a8
  1856     Returns 0 on success, 1 if errors are encountered.
  1856     Returns 0 on success, 1 if errors are encountered.
  1857     """
  1857     """
  1858     with repo.wlock(False):
  1858     with repo.wlock(False):
  1859         return cmdutil.copy(ui, repo, pats, opts)
  1859         return cmdutil.copy(ui, repo, pats, opts)
  1860 
  1860 
  1861 @command('debugdeltachain',
       
  1862     debugrevlogopts + formatteropts,
       
  1863     _('-c|-m|FILE'),
       
  1864     optionalrepo=True)
       
  1865 def debugdeltachain(ui, repo, file_=None, **opts):
       
  1866     """dump information about delta chains in a revlog
       
  1867 
       
  1868     Output can be templatized. Available template keywords are:
       
  1869 
       
  1870     :``rev``:       revision number
       
  1871     :``chainid``:   delta chain identifier (numbered by unique base)
       
  1872     :``chainlen``:  delta chain length to this revision
       
  1873     :``prevrev``:   previous revision in delta chain
       
  1874     :``deltatype``: role of delta / how it was computed
       
  1875     :``compsize``:  compressed size of revision
       
  1876     :``uncompsize``: uncompressed size of revision
       
  1877     :``chainsize``: total size of compressed revisions in chain
       
  1878     :``chainratio``: total chain size divided by uncompressed revision size
       
  1879                     (new delta chains typically start at ratio 2.00)
       
  1880     :``lindist``:   linear distance from base revision in delta chain to end
       
  1881                     of this revision
       
  1882     :``extradist``: total size of revisions not part of this delta chain from
       
  1883                     base of delta chain to end of this revision; a measurement
       
  1884                     of how much extra data we need to read/seek across to read
       
  1885                     the delta chain for this revision
       
  1886     :``extraratio``: extradist divided by chainsize; another representation of
       
  1887                     how much unrelated data is needed to load this delta chain
       
  1888     """
       
  1889     r = cmdutil.openrevlog(repo, 'debugdeltachain', file_, opts)
       
  1890     index = r.index
       
  1891     generaldelta = r.version & revlog.REVLOGGENERALDELTA
       
  1892 
       
  1893     def revinfo(rev):
       
  1894         e = index[rev]
       
  1895         compsize = e[1]
       
  1896         uncompsize = e[2]
       
  1897         chainsize = 0
       
  1898 
       
  1899         if generaldelta:
       
  1900             if e[3] == e[5]:
       
  1901                 deltatype = 'p1'
       
  1902             elif e[3] == e[6]:
       
  1903                 deltatype = 'p2'
       
  1904             elif e[3] == rev - 1:
       
  1905                 deltatype = 'prev'
       
  1906             elif e[3] == rev:
       
  1907                 deltatype = 'base'
       
  1908             else:
       
  1909                 deltatype = 'other'
       
  1910         else:
       
  1911             if e[3] == rev:
       
  1912                 deltatype = 'base'
       
  1913             else:
       
  1914                 deltatype = 'prev'
       
  1915 
       
  1916         chain = r._deltachain(rev)[0]
       
  1917         for iterrev in chain:
       
  1918             e = index[iterrev]
       
  1919             chainsize += e[1]
       
  1920 
       
  1921         return compsize, uncompsize, deltatype, chain, chainsize
       
  1922 
       
  1923     fm = ui.formatter('debugdeltachain', opts)
       
  1924 
       
  1925     fm.plain('    rev  chain# chainlen     prev   delta       '
       
  1926              'size    rawsize  chainsize     ratio   lindist extradist '
       
  1927              'extraratio\n')
       
  1928 
       
  1929     chainbases = {}
       
  1930     for rev in r:
       
  1931         comp, uncomp, deltatype, chain, chainsize = revinfo(rev)
       
  1932         chainbase = chain[0]
       
  1933         chainid = chainbases.setdefault(chainbase, len(chainbases) + 1)
       
  1934         basestart = r.start(chainbase)
       
  1935         revstart = r.start(rev)
       
  1936         lineardist = revstart + comp - basestart
       
  1937         extradist = lineardist - chainsize
       
  1938         try:
       
  1939             prevrev = chain[-2]
       
  1940         except IndexError:
       
  1941             prevrev = -1
       
  1942 
       
  1943         chainratio = float(chainsize) / float(uncomp)
       
  1944         extraratio = float(extradist) / float(chainsize)
       
  1945 
       
  1946         fm.startitem()
       
  1947         fm.write('rev chainid chainlen prevrev deltatype compsize '
       
  1948                  'uncompsize chainsize chainratio lindist extradist '
       
  1949                  'extraratio',
       
  1950                  '%7d %7d %8d %8d %7s %10d %10d %10d %9.5f %9d %9d %10.5f\n',
       
  1951                  rev, chainid, len(chain), prevrev, deltatype, comp,
       
  1952                  uncomp, chainsize, chainratio, lineardist, extradist,
       
  1953                  extraratio,
       
  1954                  rev=rev, chainid=chainid, chainlen=len(chain),
       
  1955                  prevrev=prevrev, deltatype=deltatype, compsize=comp,
       
  1956                  uncompsize=uncomp, chainsize=chainsize,
       
  1957                  chainratio=chainratio, lindist=lineardist,
       
  1958                  extradist=extradist, extraratio=extraratio)
       
  1959 
       
  1960     fm.end()
       
  1961 
       
  1962 @command('debuginstall', [] + formatteropts, '', norepo=True)
  1861 @command('debuginstall', [] + formatteropts, '', norepo=True)
  1963 def debuginstall(ui, **opts):
  1862 def debuginstall(ui, **opts):
  1964     '''test Mercurial installation
  1863     '''test Mercurial installation
  1965 
  1864 
  1966     Returns 0 on success.
  1865     Returns 0 on success.