mercurial/commands.py
changeset 20293 2f6b3900be64
parent 20282 2cfb720592fe
child 20364 a6cf48b2880d
child 20576 7f865a94691e
equal deleted inserted replaced
20292:8dc254198a8f 20293:2f6b3900be64
  1166     Returns 0 on success.
  1166     Returns 0 on success.
  1167     """
  1167     """
  1168     ctx = scmutil.revsingle(repo, opts.get('rev'))
  1168     ctx = scmutil.revsingle(repo, opts.get('rev'))
  1169     err = 1
  1169     err = 1
  1170     m = scmutil.match(ctx, (file1,) + pats, opts)
  1170     m = scmutil.match(ctx, (file1,) + pats, opts)
  1171     for abs in ctx.walk(m):
  1171 
       
  1172     def write(path):
  1172         fp = cmdutil.makefileobj(repo, opts.get('output'), ctx.node(),
  1173         fp = cmdutil.makefileobj(repo, opts.get('output'), ctx.node(),
  1173                                  pathname=abs)
  1174                                  pathname=path)
  1174         data = ctx[abs].data()
  1175         data = ctx[path].data()
  1175         if opts.get('decode'):
  1176         if opts.get('decode'):
  1176             data = repo.wwritedata(abs, data)
  1177             data = repo.wwritedata(path, data)
  1177         fp.write(data)
  1178         fp.write(data)
  1178         fp.close()
  1179         fp.close()
       
  1180 
       
  1181     # Automation often uses hg cat on single files, so special case it
       
  1182     # for performance to avoid the cost of parsing the manifest.
       
  1183     if len(m.files()) == 1 and not m.anypats():
       
  1184         file = m.files()[0]
       
  1185         mf = repo.manifest
       
  1186         mfnode = ctx._changeset[0]
       
  1187         if mf.find(mfnode, file)[0]:
       
  1188             write(file)
       
  1189             return 0
       
  1190 
       
  1191     for abs in ctx.walk(m):
       
  1192         write(abs)
  1179         err = 0
  1193         err = 0
  1180     return err
  1194     return err
  1181 
  1195 
  1182 @command('^clone',
  1196 @command('^clone',
  1183     [('U', 'noupdate', None,
  1197     [('U', 'noupdate', None,