Mercurial > public > mercurial-scm > hg
comparison mercurial/cmdutil.py @ 21040:bdf5ed5246d2
cat: move most of the implementation into cmdutils.cat()
This will allow access to the reusable parts from subrepos, similar to add(),
forget(), etc.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Thu, 13 Mar 2014 23:45:18 -0400 |
parents | a1a1bd09e4f4 |
children | a2cc3c08c3ac |
comparison
equal
deleted
inserted
replaced
21039:d0cc92ba0406 | 21040:bdf5ed5246d2 |
---|---|
1809 | 1809 |
1810 rejected = wctx.forget(forget, prefix) | 1810 rejected = wctx.forget(forget, prefix) |
1811 bad.extend(f for f in rejected if f in match.files()) | 1811 bad.extend(f for f in rejected if f in match.files()) |
1812 forgot.extend(forget) | 1812 forgot.extend(forget) |
1813 return bad, forgot | 1813 return bad, forgot |
1814 | |
1815 def cat(ui, repo, ctx, matcher, **opts): | |
1816 err = 1 | |
1817 | |
1818 def write(path): | |
1819 fp = makefileobj(repo, opts.get('output'), ctx.node(), pathname=path) | |
1820 data = ctx[path].data() | |
1821 if opts.get('decode'): | |
1822 data = repo.wwritedata(path, data) | |
1823 fp.write(data) | |
1824 fp.close() | |
1825 | |
1826 # Automation often uses hg cat on single files, so special case it | |
1827 # for performance to avoid the cost of parsing the manifest. | |
1828 if len(matcher.files()) == 1 and not matcher.anypats(): | |
1829 file = matcher.files()[0] | |
1830 mf = repo.manifest | |
1831 mfnode = ctx._changeset[0] | |
1832 if mf.find(mfnode, file)[0]: | |
1833 write(file) | |
1834 return 0 | |
1835 | |
1836 for abs in ctx.walk(matcher): | |
1837 write(abs) | |
1838 err = 0 | |
1839 return err | |
1814 | 1840 |
1815 def duplicatecopies(repo, rev, fromrev): | 1841 def duplicatecopies(repo, rev, fromrev): |
1816 '''reproduce copies from fromrev to rev in the dirstate''' | 1842 '''reproduce copies from fromrev to rev in the dirstate''' |
1817 for dst, src in copies.pathcopies(repo[fromrev], repo[rev]).iteritems(): | 1843 for dst, src in copies.pathcopies(repo[fromrev], repo[rev]).iteritems(): |
1818 # copies.pathcopies returns backward renames, so dst might not | 1844 # copies.pathcopies returns backward renames, so dst might not |