Mercurial > hg
comparison mercurial/commands.py @ 14304:64c22db0bc38
add debugrevlog command
Displays data and statistics about revlogs, including generaldelta details.
author | Sune Foldager <cryo@cyanite.org> |
---|---|
date | Thu, 12 May 2011 18:22:49 +0200 |
parents | b0f97b2589cc |
children | 32a548776b65 |
comparison
equal
deleted
inserted
replaced
14303:e2be0bba0d83 | 14304:64c22db0bc38 |
---|---|
1852 rel = m.rel(abs) | 1852 rel = m.rel(abs) |
1853 if o: | 1853 if o: |
1854 ui.write(_("%s renamed from %s:%s\n") % (rel, o[0], hex(o[1]))) | 1854 ui.write(_("%s renamed from %s:%s\n") % (rel, o[0], hex(o[1]))) |
1855 else: | 1855 else: |
1856 ui.write(_("%s not renamed\n") % rel) | 1856 ui.write(_("%s not renamed\n") % rel) |
1857 | |
1858 @command('debugrevlog', [], _('FILE')) | |
1859 def debugrevlog(ui, repo, file_): | |
1860 """show data and statistics about a revlog""" | |
1861 r = None | |
1862 if repo: | |
1863 filelog = repo.file(file_) | |
1864 if len(filelog): | |
1865 r = filelog | |
1866 if not r: | |
1867 r = revlog.revlog(scmutil.opener(os.getcwd(), audit=False), file_) | |
1868 | |
1869 v = r.version | |
1870 format = v & 0xFFFF | |
1871 flags = [] | |
1872 gdelta = False | |
1873 if v & revlog.REVLOGNGINLINEDATA: | |
1874 flags.append('inline') | |
1875 if v & revlog.REVLOGGENERALDELTA: | |
1876 gdelta = True | |
1877 flags.append('generaldelta') | |
1878 | |
1879 nummerges = 0 | |
1880 numchains = 0 | |
1881 numprev = 0 | |
1882 nump1 = 0 | |
1883 nump2 = 0 | |
1884 numother = 0 | |
1885 nump1prev = 0 | |
1886 nump2prev = 0 | |
1887 | |
1888 datasize = [None, 0, 0L] | |
1889 snapshotsize = [None, 0, 0L] | |
1890 deltasize = [None, 0, 0L] | |
1891 | |
1892 def addsize(size, l): | |
1893 if l[0] is None or size < l[0]: | |
1894 l[0] = size | |
1895 if size > l[1]: | |
1896 l[1] = size | |
1897 l[2] += size | |
1898 | |
1899 numrevs = len(r) | |
1900 for rev in xrange(numrevs): | |
1901 p1, p2 = r.parentrevs(rev) | |
1902 delta = r.deltaparent(rev) | |
1903 if format > 0: | |
1904 addsize(r.rawsize(rev), datasize) | |
1905 if p2 != nullrev: | |
1906 nummerges += 1 | |
1907 size = r.length(rev) | |
1908 if delta == nullrev: | |
1909 numchains += 1 | |
1910 addsize(size, snapshotsize) | |
1911 else: | |
1912 addsize(size, deltasize) | |
1913 if gdelta: | |
1914 if delta == rev - 1: | |
1915 numprev += 1 | |
1916 if delta == p1: | |
1917 nump1prev += 1 | |
1918 elif delta == p2: | |
1919 nump2prev += 1 | |
1920 elif delta == p1: | |
1921 nump1 += 1 | |
1922 elif delta == p2: | |
1923 nump2 += 1 | |
1924 elif delta != nullrev: | |
1925 numother += 1 | |
1926 | |
1927 numotherprev = numprev - nump1prev - nump2prev | |
1928 datasize[2] /= numrevs | |
1929 snapshotsize[2] /= numchains | |
1930 deltasize[2] /= numrevs - numchains | |
1931 | |
1932 ui.write('format : %d\n' % format) | |
1933 ui.write('flags : %s\n' % ', '.join(flags)) | |
1934 ui.write('revisions : %d\n' % numrevs) | |
1935 ui.write('merges : %d\n' % nummerges) | |
1936 ui.write('chains : %d\n' % numchains) | |
1937 | |
1938 if format > 0: | |
1939 ui.write('\ndata size (min/max/avg) : %d / %d / %d\n' | |
1940 % tuple(datasize)) | |
1941 ui.write('compressed snapshot size (min/max/avg) : %d / %d / %d\n' | |
1942 % tuple(snapshotsize)) | |
1943 ui.write('compressed delta size (min/max/avg) : %d / %d / %d\n' | |
1944 % tuple(deltasize)) | |
1945 | |
1946 if gdelta: | |
1947 ui.write('\ndeltas against prev : %d\n' % numprev) | |
1948 ui.write(' ..where prev = p1 : %d\n' % nump1prev) | |
1949 ui.write(' ..where prev = p2 : %d\n' % nump2prev) | |
1950 ui.write(' ..other : %d\n' % numotherprev) | |
1951 ui.write('deltas against p1 : %d\n' % nump1) | |
1952 ui.write('deltas against p2 : %d\n' % nump2) | |
1953 ui.write('deltas against other : %d\n' % numother) | |
1857 | 1954 |
1858 @command('debugrevspec', [], ('REVSPEC')) | 1955 @command('debugrevspec', [], ('REVSPEC')) |
1859 def debugrevspec(ui, repo, expr): | 1956 def debugrevspec(ui, repo, expr): |
1860 '''parse and apply a revision specification''' | 1957 '''parse and apply a revision specification''' |
1861 if ui.verbose: | 1958 if ui.verbose: |