Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/commands.py @ 30537:22683f2f8100
debugcommands: move 'debugindex' and 'debugindexdot' in the new module
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Wed, 17 Aug 2016 21:00:11 -0700 |
parents | 243ecbd4f5c9 |
children | bd5c4320b5a8 |
comparison
equal
deleted
inserted
replaced
30536:243ecbd4f5c9 | 30537:22683f2f8100 |
---|---|
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('debugindex', debugrevlogopts + | |
1862 [('f', 'format', 0, _('revlog format'), _('FORMAT'))], | |
1863 _('[-f FORMAT] -c|-m|FILE'), | |
1864 optionalrepo=True) | |
1865 def debugindex(ui, repo, file_=None, **opts): | |
1866 """dump the contents of an index file""" | |
1867 r = cmdutil.openrevlog(repo, 'debugindex', file_, opts) | |
1868 format = opts.get('format', 0) | |
1869 if format not in (0, 1): | |
1870 raise error.Abort(_("unknown format %d") % format) | |
1871 | |
1872 generaldelta = r.version & revlog.REVLOGGENERALDELTA | |
1873 if generaldelta: | |
1874 basehdr = ' delta' | |
1875 else: | |
1876 basehdr = ' base' | |
1877 | |
1878 if ui.debugflag: | |
1879 shortfn = hex | |
1880 else: | |
1881 shortfn = short | |
1882 | |
1883 # There might not be anything in r, so have a sane default | |
1884 idlen = 12 | |
1885 for i in r: | |
1886 idlen = len(shortfn(r.node(i))) | |
1887 break | |
1888 | |
1889 if format == 0: | |
1890 ui.write((" rev offset length " + basehdr + " linkrev" | |
1891 " %s %s p2\n") % ("nodeid".ljust(idlen), "p1".ljust(idlen))) | |
1892 elif format == 1: | |
1893 ui.write((" rev flag offset length" | |
1894 " size " + basehdr + " link p1 p2" | |
1895 " %s\n") % "nodeid".rjust(idlen)) | |
1896 | |
1897 for i in r: | |
1898 node = r.node(i) | |
1899 if generaldelta: | |
1900 base = r.deltaparent(i) | |
1901 else: | |
1902 base = r.chainbase(i) | |
1903 if format == 0: | |
1904 try: | |
1905 pp = r.parents(node) | |
1906 except Exception: | |
1907 pp = [nullid, nullid] | |
1908 ui.write("% 6d % 9d % 7d % 6d % 7d %s %s %s\n" % ( | |
1909 i, r.start(i), r.length(i), base, r.linkrev(i), | |
1910 shortfn(node), shortfn(pp[0]), shortfn(pp[1]))) | |
1911 elif format == 1: | |
1912 pr = r.parentrevs(i) | |
1913 ui.write("% 6d %04x % 8d % 8d % 8d % 6d % 6d % 6d % 6d %s\n" % ( | |
1914 i, r.flags(i), r.start(i), r.length(i), r.rawsize(i), | |
1915 base, r.linkrev(i), pr[0], pr[1], shortfn(node))) | |
1916 | |
1917 @command('debugindexdot', debugrevlogopts, | |
1918 _('-c|-m|FILE'), optionalrepo=True) | |
1919 def debugindexdot(ui, repo, file_=None, **opts): | |
1920 """dump an index DAG as a graphviz dot file""" | |
1921 r = cmdutil.openrevlog(repo, 'debugindexdot', file_, opts) | |
1922 ui.write(("digraph G {\n")) | |
1923 for i in r: | |
1924 node = r.node(i) | |
1925 pp = r.parents(node) | |
1926 ui.write("\t%d -> %d\n" % (r.rev(pp[0]), i)) | |
1927 if pp[1] != nullid: | |
1928 ui.write("\t%d -> %d\n" % (r.rev(pp[1]), i)) | |
1929 ui.write("}\n") | |
1930 | |
1931 @command('debugdeltachain', | 1861 @command('debugdeltachain', |
1932 debugrevlogopts + formatteropts, | 1862 debugrevlogopts + formatteropts, |
1933 _('-c|-m|FILE'), | 1863 _('-c|-m|FILE'), |
1934 optionalrepo=True) | 1864 optionalrepo=True) |
1935 def debugdeltachain(ui, repo, file_=None, **opts): | 1865 def debugdeltachain(ui, repo, file_=None, **opts): |