Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/commands.py @ 30536:243ecbd4f5c9
debugcommands: move 'debugignore' in the new module
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Wed, 17 Aug 2016 20:59:13 -0700 |
parents | 9c10905f4b48 |
children | 22683f2f8100 |
comparison
equal
deleted
inserted
replaced
30535:9c10905f4b48 | 30536:243ecbd4f5c9 |
---|---|
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('debugignore', [], '[FILE]') | |
1862 def debugignore(ui, repo, *files, **opts): | |
1863 """display the combined ignore pattern and information about ignored files | |
1864 | |
1865 With no argument display the combined ignore pattern. | |
1866 | |
1867 Given space separated file names, shows if the given file is ignored and | |
1868 if so, show the ignore rule (file and line number) that matched it. | |
1869 """ | |
1870 ignore = repo.dirstate._ignore | |
1871 if not files: | |
1872 # Show all the patterns | |
1873 includepat = getattr(ignore, 'includepat', None) | |
1874 if includepat is not None: | |
1875 ui.write("%s\n" % includepat) | |
1876 else: | |
1877 raise error.Abort(_("no ignore patterns found")) | |
1878 else: | |
1879 for f in files: | |
1880 nf = util.normpath(f) | |
1881 ignored = None | |
1882 ignoredata = None | |
1883 if nf != '.': | |
1884 if ignore(nf): | |
1885 ignored = nf | |
1886 ignoredata = repo.dirstate._ignorefileandline(nf) | |
1887 else: | |
1888 for p in util.finddirs(nf): | |
1889 if ignore(p): | |
1890 ignored = p | |
1891 ignoredata = repo.dirstate._ignorefileandline(p) | |
1892 break | |
1893 if ignored: | |
1894 if ignored == nf: | |
1895 ui.write(_("%s is ignored\n") % f) | |
1896 else: | |
1897 ui.write(_("%s is ignored because of " | |
1898 "containing folder %s\n") | |
1899 % (f, ignored)) | |
1900 ignorefile, lineno, line = ignoredata | |
1901 ui.write(_("(ignore rule in %s, line %d: '%s')\n") | |
1902 % (ignorefile, lineno, line)) | |
1903 else: | |
1904 ui.write(_("%s is not ignored\n") % f) | |
1905 | |
1906 @command('debugindex', debugrevlogopts + | 1861 @command('debugindex', debugrevlogopts + |
1907 [('f', 'format', 0, _('revlog format'), _('FORMAT'))], | 1862 [('f', 'format', 0, _('revlog format'), _('FORMAT'))], |
1908 _('[-f FORMAT] -c|-m|FILE'), | 1863 _('[-f FORMAT] -c|-m|FILE'), |
1909 optionalrepo=True) | 1864 optionalrepo=True) |
1910 def debugindex(ui, repo, file_=None, **opts): | 1865 def debugindex(ui, repo, file_=None, **opts): |