##// END OF EJS Templates
largefiles: fix cat of non-largefiles from subdirectory...
Mads Kiilerich -
r18974:d78a136a default
parent child Browse files
Show More
@@ -530,24 +530,6 b' def _updatelfile(repo, lfdirstate, lfile'
530 lfdirstate.drop(lfile)
530 lfdirstate.drop(lfile)
531 return ret
531 return ret
532
532
533 def catlfile(repo, lfile, rev, filename):
534 hash = lfutil.readstandin(repo, lfile, rev)
535 if not lfutil.inusercache(repo.ui, hash):
536 store = basestore._openstore(repo)
537 success, missing = store.get([(lfile, hash)])
538 if len(success) != 1:
539 raise util.Abort(
540 _('largefile %s is not in cache and could not be downloaded')
541 % lfile)
542 path = lfutil.usercachepath(repo.ui, hash)
543 fpout = cmdutil.makefileobj(repo, filename)
544 fpin = open(path, "rb")
545 for chunk in lfutil.blockstream(fpin):
546 fpout.write(chunk)
547 fpout.close()
548 fpin.close()
549 return 0
550
551 # -- hg commands declarations ------------------------------------------------
533 # -- hg commands declarations ------------------------------------------------
552
534
553 cmdtable = {
535 cmdtable = {
@@ -19,6 +19,7 b' from hgext import rebase'
19
19
20 import lfutil
20 import lfutil
21 import lfcommands
21 import lfcommands
22 import basestore
22
23
23 # -- Utility functions: commonly/repeatedly needed functionality ---------------
24 # -- Utility functions: commonly/repeatedly needed functionality ---------------
24
25
@@ -1155,13 +1156,37 b' def overridecat(orig, ui, repo, file1, *'
1155 notbad.add(lf)
1156 notbad.add(lf)
1156 return origmatchfn(lf)
1157 return origmatchfn(lf)
1157 m.matchfn = lfmatchfn
1158 m.matchfn = lfmatchfn
1158 m.bad = lambda f, msg: f not in notbad
1159 origbadfn = m.bad
1160 def lfbadfn(f, msg):
1161 if not f in notbad:
1162 return origbadfn(f, msg)
1163 m.bad = lfbadfn
1159 for f in ctx.walk(m):
1164 for f in ctx.walk(m):
1165 fp = cmdutil.makefileobj(repo, opts.get('output'), ctx.node(),
1166 pathname=f)
1160 lf = lfutil.splitstandin(f)
1167 lf = lfutil.splitstandin(f)
1161 if lf is None:
1168 if lf is None:
1162 err = orig(ui, repo, f, **opts)
1169 # duplicating unreachable code from commands.cat
1170 data = ctx[f].data()
1171 if opts.get('decode'):
1172 data = repo.wwritedata(f, data)
1173 fp.write(data)
1163 else:
1174 else:
1164 err = lfcommands.catlfile(repo, lf, ctx.rev(), opts.get('output'))
1175 hash = lfutil.readstandin(repo, lf, ctx.rev())
1176 if not lfutil.inusercache(repo.ui, hash):
1177 store = basestore._openstore(repo)
1178 success, missing = store.get([(lf, hash)])
1179 if len(success) != 1:
1180 raise util.Abort(
1181 _('largefile %s is not in cache and could not be '
1182 'downloaded') % lf)
1183 path = lfutil.usercachepath(repo.ui, hash)
1184 fpin = open(path, "rb")
1185 for chunk in lfutil.blockstream(fpin):
1186 fp.write(chunk)
1187 fpin.close()
1188 fp.close()
1189 err = 0
1165 return err
1190 return err
1166
1191
1167 def mercurialsinkbefore(orig, sink):
1192 def mercurialsinkbefore(orig, sink):
@@ -1486,7 +1486,10 b' Cat a largefile'
1486 $ hg cat -r '.^' sub/large4 doesntexist
1486 $ hg cat -r '.^' sub/large4 doesntexist
1487 large4-modified
1487 large4-modified
1488 doesntexist: no such file in rev a381d2c8c80e
1488 doesntexist: no such file in rev a381d2c8c80e
1489 [1]
1489 $ hg --cwd sub cat -r '.^' large4
1490 large4-modified
1491 $ hg --cwd sub cat -r '.^' ../normal3
1492 normal3-modified
1490
1493
1491 Test that renaming a largefile results in correct output for status
1494 Test that renaming a largefile results in correct output for status
1492
1495
General Comments 0
You need to be logged in to leave comments. Login now