##// END OF EJS Templates
subrepo: run the repo decoders when archiving...
Matt Harbison -
r31099:b44ab288 default
parent child Browse files
Show More
@@ -993,9 +993,9 b' def overridearchive(orig, repo, dest, no'
993 993
994 994 archiver.done()
995 995
996 def hgsubrepoarchive(orig, repo, archiver, prefix, match=None):
996 def hgsubrepoarchive(orig, repo, archiver, prefix, match=None, decode=True):
997 997 if not repo._repo.lfstatus:
998 return orig(repo, archiver, prefix, match)
998 return orig(repo, archiver, prefix, match, decode)
999 999
1000 1000 repo._get(repo._state + ('hg',))
1001 1001 rev = repo._state[1]
@@ -1010,6 +1010,8 b' def hgsubrepoarchive(orig, repo, archive'
1010 1010 if match and not match(f):
1011 1011 return
1012 1012 data = getdata()
1013 if decode:
1014 data = repo._repo.wwritedata(name, data)
1013 1015
1014 1016 archiver.addfile(prefix + repo._path + '/' + name, mode, islink, data)
1015 1017
@@ -1037,7 +1039,7 b' def hgsubrepoarchive(orig, repo, archive'
1037 1039 sub = ctx.workingsub(subpath)
1038 1040 submatch = matchmod.subdirmatcher(subpath, match)
1039 1041 sub._repo.lfstatus = True
1040 sub.archive(archiver, prefix + repo._path + '/', submatch)
1042 sub.archive(archiver, prefix + repo._path + '/', submatch, decode)
1041 1043
1042 1044 # If a largefile is modified, the change is not reflected in its
1043 1045 # standin until a commit. cmdutil.bailifchanged() raises an exception
@@ -331,7 +331,7 b' def archive(repo, dest, node, kind, deco'
331 331 for subpath in sorted(ctx.substate):
332 332 sub = ctx.workingsub(subpath)
333 333 submatch = matchmod.subdirmatcher(subpath, matchfn)
334 total += sub.archive(archiver, prefix, submatch)
334 total += sub.archive(archiver, prefix, submatch, decode)
335 335
336 336 if total == 0:
337 337 raise error.Abort(_('no files match the archive pattern'))
@@ -542,8 +542,8 b' class abstractsubrepo(object):'
542 542 """return filename iterator"""
543 543 raise NotImplementedError
544 544
545 def filedata(self, name):
546 """return file data"""
545 def filedata(self, name, decode):
546 """return file data, optionally passed through repo decoders"""
547 547 raise NotImplementedError
548 548
549 549 def fileflags(self, name):
@@ -558,7 +558,7 b' class abstractsubrepo(object):'
558 558 """handle the files command for this subrepo"""
559 559 return 1
560 560
561 def archive(self, archiver, prefix, match=None):
561 def archive(self, archiver, prefix, match=None, decode=True):
562 562 if match is not None:
563 563 files = [f for f in self.files() if match(f)]
564 564 else:
@@ -572,7 +572,7 b' class abstractsubrepo(object):'
572 572 mode = 'x' in flags and 0o755 or 0o644
573 573 symlink = 'l' in flags
574 574 archiver.addfile(prefix + self._path + '/' + name,
575 mode, symlink, self.filedata(name))
575 mode, symlink, self.filedata(name, decode))
576 576 self.ui.progress(_('archiving (%s)') % relpath, i + 1,
577 577 unit=_('files'), total=total)
578 578 self.ui.progress(_('archiving (%s)') % relpath, None)
@@ -782,7 +782,7 b' class hgsubrepo(abstractsubrepo):'
782 782 % (inst, subrelpath(self)))
783 783
784 784 @annotatesubrepoerror
785 def archive(self, archiver, prefix, match=None):
785 def archive(self, archiver, prefix, match=None, decode=True):
786 786 self._get(self._state + ('hg',))
787 787 total = abstractsubrepo.archive(self, archiver, prefix, match)
788 788 rev = self._state[1]
@@ -790,7 +790,8 b' class hgsubrepo(abstractsubrepo):'
790 790 for subpath in ctx.substate:
791 791 s = subrepo(ctx, subpath, True)
792 792 submatch = matchmod.subdirmatcher(subpath, match)
793 total += s.archive(archiver, prefix + self._path + '/', submatch)
793 total += s.archive(archiver, prefix + self._path + '/', submatch,
794 decode)
794 795 return total
795 796
796 797 @annotatesubrepoerror
@@ -956,9 +957,12 b' class hgsubrepo(abstractsubrepo):'
956 957 ctx = self._repo[rev]
957 958 return ctx.manifest().keys()
958 959
959 def filedata(self, name):
960 def filedata(self, name, decode):
960 961 rev = self._state[1]
961 return self._repo[rev][name].data()
962 data = self._repo[rev][name].data()
963 if decode:
964 data = self._repo.wwritedata(name, data)
965 return data
962 966
963 967 def fileflags(self, name):
964 968 rev = self._state[1]
@@ -1292,7 +1296,7 b' class svnsubrepo(abstractsubrepo):'
1292 1296 paths.append(name.encode('utf-8'))
1293 1297 return paths
1294 1298
1295 def filedata(self, name):
1299 def filedata(self, name, decode):
1296 1300 return self._svncommand(['cat'], name)[0]
1297 1301
1298 1302
@@ -1772,7 +1776,7 b' class gitsubrepo(abstractsubrepo):'
1772 1776 else:
1773 1777 self.wvfs.unlink(f)
1774 1778
1775 def archive(self, archiver, prefix, match=None):
1779 def archive(self, archiver, prefix, match=None, decode=True):
1776 1780 total = 0
1777 1781 source, revision = self._state
1778 1782 if not revision:
@@ -470,6 +470,22 b' Test eol.only-consistent can be specifie'
470 470 > EOF
471 471 $ hg commit -m 'consistent'
472 472
473 $ hg init subrepo
474 $ hg -R subrepo pull -qu .
475 $ echo "subrepo = subrepo" > .hgsub
476 $ hg ci -Am "add subrepo"
477 adding .hgeol
478 adding .hgsub
479 $ hg archive -S ../archive
480 $ find ../archive/* | sort
481 ../archive/a.txt
482 ../archive/subrepo
483 ../archive/subrepo/a.txt
484 $ cat ../archive/a.txt ../archive/subrepo/a.txt
485 first\r (esc)
486 second\r (esc)
487 first\r (esc)
488 second\r (esc)
473 489
474 490 Test trailing newline
475 491
General Comments 0
You need to be logged in to leave comments. Login now