##// END OF EJS Templates
archive: support 'wdir()'...
Matt Harbison -
r25601:3ec8351f default
parent child Browse files
Show More
@@ -882,7 +882,8 b' def overridearchive(orig, repo, dest, no'
882 prefix='', mtime=None, subrepos=None):
882 prefix='', mtime=None, subrepos=None):
883 # No need to lock because we are only reading history and
883 # No need to lock because we are only reading history and
884 # largefile caches, neither of which are modified.
884 # largefile caches, neither of which are modified.
885 lfcommands.cachelfiles(repo.ui, repo, node)
885 if node is not None:
886 lfcommands.cachelfiles(repo.ui, repo, node)
886
887
887 if kind not in archival.archivers:
888 if kind not in archival.archivers:
888 raise util.Abort(_("unknown archive type '%s'") % kind)
889 raise util.Abort(_("unknown archive type '%s'") % kind)
@@ -914,11 +915,16 b' def overridearchive(orig, repo, dest, no'
914 ff = ctx.flags(f)
915 ff = ctx.flags(f)
915 getdata = ctx[f].data
916 getdata = ctx[f].data
916 if lfutil.isstandin(f):
917 if lfutil.isstandin(f):
917 path = lfutil.findfile(repo, getdata().strip())
918 if node is not None:
918 if path is None:
919 path = lfutil.findfile(repo, getdata().strip())
919 raise util.Abort(
920
920 _('largefile %s not found in repo store or system cache')
921 if path is None:
921 % lfutil.splitstandin(f))
922 raise util.Abort(
923 _('largefile %s not found in repo store or system cache')
924 % lfutil.splitstandin(f))
925 else:
926 path = lfutil.splitstandin(f)
927
922 f = lfutil.splitstandin(f)
928 f = lfutil.splitstandin(f)
923
929
924 def getdatafn():
930 def getdatafn():
@@ -935,7 +941,7 b' def overridearchive(orig, repo, dest, no'
935
941
936 if subrepos:
942 if subrepos:
937 for subpath in sorted(ctx.substate):
943 for subpath in sorted(ctx.substate):
938 sub = ctx.sub(subpath)
944 sub = ctx.workingsub(subpath)
939 submatch = match_.narrowmatcher(subpath, matchfn)
945 submatch = match_.narrowmatcher(subpath, matchfn)
940 sub.archive(archiver, prefix, submatch)
946 sub.archive(archiver, prefix, submatch)
941
947
@@ -946,7 +952,8 b' def hgsubrepoarchive(orig, repo, archive'
946 rev = repo._state[1]
952 rev = repo._state[1]
947 ctx = repo._repo[rev]
953 ctx = repo._repo[rev]
948
954
949 lfcommands.cachelfiles(repo.ui, repo._repo, ctx.node())
955 if ctx.node() is not None:
956 lfcommands.cachelfiles(repo.ui, repo._repo, ctx.node())
950
957
951 def write(name, mode, islink, getdata):
958 def write(name, mode, islink, getdata):
952 # At this point, the standin has been replaced with the largefile name,
959 # At this point, the standin has been replaced with the largefile name,
@@ -961,11 +968,16 b' def hgsubrepoarchive(orig, repo, archive'
961 ff = ctx.flags(f)
968 ff = ctx.flags(f)
962 getdata = ctx[f].data
969 getdata = ctx[f].data
963 if lfutil.isstandin(f):
970 if lfutil.isstandin(f):
964 path = lfutil.findfile(repo._repo, getdata().strip())
971 if ctx.node() is not None:
965 if path is None:
972 path = lfutil.findfile(repo._repo, getdata().strip())
966 raise util.Abort(
973
967 _('largefile %s not found in repo store or system cache')
974 if path is None:
968 % lfutil.splitstandin(f))
975 raise util.Abort(
976 _('largefile %s not found in repo store or system cache')
977 % lfutil.splitstandin(f))
978 else:
979 path = lfutil.splitstandin(f)
980
969 f = lfutil.splitstandin(f)
981 f = lfutil.splitstandin(f)
970
982
971 def getdatafn():
983 def getdatafn():
@@ -982,7 +994,7 b' def hgsubrepoarchive(orig, repo, archive'
982 write(f, 'x' in ff and 0755 or 0644, 'l' in ff, getdata)
994 write(f, 'x' in ff and 0755 or 0644, 'l' in ff, getdata)
983
995
984 for subpath in sorted(ctx.substate):
996 for subpath in sorted(ctx.substate):
985 sub = ctx.sub(subpath)
997 sub = ctx.workingsub(subpath)
986 submatch = match_.narrowmatcher(subpath, match)
998 submatch = match_.narrowmatcher(subpath, match)
987 sub.archive(archiver, prefix + repo._path + '/', submatch)
999 sub.archive(archiver, prefix + repo._path + '/', submatch)
988
1000
@@ -315,7 +315,7 b' def archive(repo, dest, node, kind, deco'
315
315
316 if subrepos:
316 if subrepos:
317 for subpath in sorted(ctx.substate):
317 for subpath in sorted(ctx.substate):
318 sub = ctx.sub(subpath)
318 sub = ctx.workingsub(subpath)
319 submatch = matchmod.narrowmatcher(subpath, matchfn)
319 submatch = matchmod.narrowmatcher(subpath, matchfn)
320 total += sub.archive(archiver, prefix, submatch)
320 total += sub.archive(archiver, prefix, submatch)
321
321
@@ -762,7 +762,7 b' class hgsubrepo(abstractsubrepo):'
762 rev = self._state[1]
762 rev = self._state[1]
763 ctx = self._repo[rev]
763 ctx = self._repo[rev]
764 for subpath in ctx.substate:
764 for subpath in ctx.substate:
765 s = subrepo(ctx, subpath)
765 s = subrepo(ctx, subpath, True)
766 submatch = matchmod.narrowmatcher(subpath, match)
766 submatch = matchmod.narrowmatcher(subpath, match)
767 total += s.archive(archiver, prefix + self._path + '/', submatch)
767 total += s.archive(archiver, prefix + self._path + '/', submatch)
768 return total
768 return total
@@ -168,6 +168,41 b' Test relative path printing + subrepos'
168 A foo/bar/abc
168 A foo/bar/abc
169 A sub1/foo
169 A sub1/foo
170 R sub1/sub2/test.txt
170 R sub1/sub2/test.txt
171
172 Archive wdir() with subrepos
173 $ hg rm main
174 $ hg archive -S -r 'wdir()' ../wdir
175 $ diff -r . ../wdir | grep -v '\.hg$'
176 Only in ../wdir: .hg_archival.txt
177
178 $ find ../wdir -type f | sort
179 ../wdir/.hg_archival.txt
180 ../wdir/.hgsub
181 ../wdir/.hgsubstate
182 ../wdir/foo/bar/abc
183 ../wdir/sub1/.hgsub
184 ../wdir/sub1/.hgsubstate
185 ../wdir/sub1/foo
186 ../wdir/sub1/sub1
187 ../wdir/sub1/sub2/folder/test.txt
188 ../wdir/sub1/sub2/sub2
189
190 Attempting to archive 'wdir()' with a missing file is handled gracefully
191 $ rm sub1/sub1
192 $ rm -r ../wdir
193 $ hg archive -v -S -r 'wdir()' ../wdir
194 $ find ../wdir -type f | sort
195 ../wdir/.hg_archival.txt
196 ../wdir/.hgsub
197 ../wdir/.hgsubstate
198 ../wdir/foo/bar/abc
199 ../wdir/sub1/.hgsub
200 ../wdir/sub1/.hgsubstate
201 ../wdir/sub1/foo
202 ../wdir/sub1/sub2/folder/test.txt
203 ../wdir/sub1/sub2/sub2
204
205 Continue relative path printing + subrepos
171 $ hg update -Cq
206 $ hg update -Cq
172 $ touch sub1/sub2/folder/bar
207 $ touch sub1/sub2/folder/bar
173 $ hg addremove sub1/sub2
208 $ hg addremove sub1/sub2
@@ -469,8 +504,69 b' largefile and a normal file. Then a lar'
469 ? sub1/sub2/untracked.txt
504 ? sub1/sub2/untracked.txt
470 ? sub1/sub2/x.txt
505 ? sub1/sub2/x.txt
471 $ hg add sub1/sub2
506 $ hg add sub1/sub2
507
508 $ hg archive -S -r 'wdir()' ../wdir2
509 $ diff -r . ../wdir2 | grep -v '\.hg$'
510 Only in ../wdir2: .hg_archival.txt
511 Only in .: .hglf
512 Only in .: foo
513 Only in ./sub1/sub2: large.bin
514 Only in ./sub1/sub2: test.txt
515 Only in ./sub1/sub2: untracked.txt
516 Only in ./sub1/sub2: x.txt
517 $ find ../wdir2 -type f | sort
518 ../wdir2/.hg_archival.txt
519 ../wdir2/.hgsub
520 ../wdir2/.hgsubstate
521 ../wdir2/large.bin
522 ../wdir2/main
523 ../wdir2/sub1/.hgsub
524 ../wdir2/sub1/.hgsubstate
525 ../wdir2/sub1/sub1
526 ../wdir2/sub1/sub2/folder/test.txt
527 ../wdir2/sub1/sub2/large.dat
528 ../wdir2/sub1/sub2/sub2
529 $ hg status -S -mac -n | sort
530 .hgsub
531 .hgsubstate
532 large.bin
533 main
534 sub1/.hgsub
535 sub1/.hgsubstate
536 sub1/sub1
537 sub1/sub2/folder/test.txt
538 sub1/sub2/large.dat
539 sub1/sub2/sub2
540
472 $ hg ci -Sqm 'forget testing'
541 $ hg ci -Sqm 'forget testing'
473
542
543 Test 'wdir()' modified file archiving with largefiles
544 $ echo 'mod' > main
545 $ echo 'mod' > large.bin
546 $ echo 'mod' > sub1/sub2/large.dat
547 $ hg archive -S -r 'wdir()' ../wdir3
548 $ diff -r . ../wdir3 | grep -v '\.hg$'
549 Only in ../wdir3: .hg_archival.txt
550 Only in .: .hglf
551 Only in .: foo
552 Only in ./sub1/sub2: large.bin
553 Only in ./sub1/sub2: test.txt
554 Only in ./sub1/sub2: untracked.txt
555 Only in ./sub1/sub2: x.txt
556 $ find ../wdir3 -type f | sort
557 ../wdir3/.hg_archival.txt
558 ../wdir3/.hgsub
559 ../wdir3/.hgsubstate
560 ../wdir3/large.bin
561 ../wdir3/main
562 ../wdir3/sub1/.hgsub
563 ../wdir3/sub1/.hgsubstate
564 ../wdir3/sub1/sub1
565 ../wdir3/sub1/sub2/folder/test.txt
566 ../wdir3/sub1/sub2/large.dat
567 ../wdir3/sub1/sub2/sub2
568 $ hg up -Cq
569
474 Test issue4330: commit a directory where only normal files have changed
570 Test issue4330: commit a directory where only normal files have changed
475 $ touch foo/bar/large.dat
571 $ touch foo/bar/large.dat
476 $ hg add --large foo/bar/large.dat
572 $ hg add --large foo/bar/large.dat
General Comments 0
You need to be logged in to leave comments. Login now