##// END OF EJS Templates
cat: move most of the implementation into cmdutils.cat()...
Matt Harbison -
r21040:bdf5ed52 default
parent child Browse files
Show More
@@ -1812,6 +1812,32 b' def forget(ui, repo, match, prefix, expl'
1812 forgot.extend(forget)
1812 forgot.extend(forget)
1813 return bad, forgot
1813 return bad, forgot
1814
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
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():
@@ -1172,32 +1172,9 b' def cat(ui, repo, file1, *pats, **opts):'
1172 Returns 0 on success.
1172 Returns 0 on success.
1173 """
1173 """
1174 ctx = scmutil.revsingle(repo, opts.get('rev'))
1174 ctx = scmutil.revsingle(repo, opts.get('rev'))
1175 err = 1
1176 m = scmutil.match(ctx, (file1,) + pats, opts)
1175 m = scmutil.match(ctx, (file1,) + pats, opts)
1177
1176
1178 def write(path):
1177 return cmdutil.cat(ui, repo, ctx, m, **opts)
1179 fp = cmdutil.makefileobj(repo, opts.get('output'), ctx.node(),
1180 pathname=path)
1181 data = ctx[path].data()
1182 if opts.get('decode'):
1183 data = repo.wwritedata(path, data)
1184 fp.write(data)
1185 fp.close()
1186
1187 # Automation often uses hg cat on single files, so special case it
1188 # for performance to avoid the cost of parsing the manifest.
1189 if len(m.files()) == 1 and not m.anypats():
1190 file = m.files()[0]
1191 mf = repo.manifest
1192 mfnode = ctx._changeset[0]
1193 if mf.find(mfnode, file)[0]:
1194 write(file)
1195 return 0
1196
1197 for abs in ctx.walk(m):
1198 write(abs)
1199 err = 0
1200 return err
1201
1178
1202 @command('^clone',
1179 @command('^clone',
1203 [('U', 'noupdate', None,
1180 [('U', 'noupdate', None,
General Comments 0
You need to be logged in to leave comments. Login now