##// 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 archiver.done()
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 if not repo._repo.lfstatus:
997 if not repo._repo.lfstatus:
998 return orig(repo, archiver, prefix, match)
998 return orig(repo, archiver, prefix, match, decode)
999
999
1000 repo._get(repo._state + ('hg',))
1000 repo._get(repo._state + ('hg',))
1001 rev = repo._state[1]
1001 rev = repo._state[1]
@@ -1010,6 +1010,8 b' def hgsubrepoarchive(orig, repo, archive'
1010 if match and not match(f):
1010 if match and not match(f):
1011 return
1011 return
1012 data = getdata()
1012 data = getdata()
1013 if decode:
1014 data = repo._repo.wwritedata(name, data)
1013
1015
1014 archiver.addfile(prefix + repo._path + '/' + name, mode, islink, data)
1016 archiver.addfile(prefix + repo._path + '/' + name, mode, islink, data)
1015
1017
@@ -1037,7 +1039,7 b' def hgsubrepoarchive(orig, repo, archive'
1037 sub = ctx.workingsub(subpath)
1039 sub = ctx.workingsub(subpath)
1038 submatch = matchmod.subdirmatcher(subpath, match)
1040 submatch = matchmod.subdirmatcher(subpath, match)
1039 sub._repo.lfstatus = True
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 # If a largefile is modified, the change is not reflected in its
1044 # If a largefile is modified, the change is not reflected in its
1043 # standin until a commit. cmdutil.bailifchanged() raises an exception
1045 # standin until a commit. cmdutil.bailifchanged() raises an exception
@@ -331,7 +331,7 b' def archive(repo, dest, node, kind, deco'
331 for subpath in sorted(ctx.substate):
331 for subpath in sorted(ctx.substate):
332 sub = ctx.workingsub(subpath)
332 sub = ctx.workingsub(subpath)
333 submatch = matchmod.subdirmatcher(subpath, matchfn)
333 submatch = matchmod.subdirmatcher(subpath, matchfn)
334 total += sub.archive(archiver, prefix, submatch)
334 total += sub.archive(archiver, prefix, submatch, decode)
335
335
336 if total == 0:
336 if total == 0:
337 raise error.Abort(_('no files match the archive pattern'))
337 raise error.Abort(_('no files match the archive pattern'))
@@ -542,8 +542,8 b' class abstractsubrepo(object):'
542 """return filename iterator"""
542 """return filename iterator"""
543 raise NotImplementedError
543 raise NotImplementedError
544
544
545 def filedata(self, name):
545 def filedata(self, name, decode):
546 """return file data"""
546 """return file data, optionally passed through repo decoders"""
547 raise NotImplementedError
547 raise NotImplementedError
548
548
549 def fileflags(self, name):
549 def fileflags(self, name):
@@ -558,7 +558,7 b' class abstractsubrepo(object):'
558 """handle the files command for this subrepo"""
558 """handle the files command for this subrepo"""
559 return 1
559 return 1
560
560
561 def archive(self, archiver, prefix, match=None):
561 def archive(self, archiver, prefix, match=None, decode=True):
562 if match is not None:
562 if match is not None:
563 files = [f for f in self.files() if match(f)]
563 files = [f for f in self.files() if match(f)]
564 else:
564 else:
@@ -572,7 +572,7 b' class abstractsubrepo(object):'
572 mode = 'x' in flags and 0o755 or 0o644
572 mode = 'x' in flags and 0o755 or 0o644
573 symlink = 'l' in flags
573 symlink = 'l' in flags
574 archiver.addfile(prefix + self._path + '/' + name,
574 archiver.addfile(prefix + self._path + '/' + name,
575 mode, symlink, self.filedata(name))
575 mode, symlink, self.filedata(name, decode))
576 self.ui.progress(_('archiving (%s)') % relpath, i + 1,
576 self.ui.progress(_('archiving (%s)') % relpath, i + 1,
577 unit=_('files'), total=total)
577 unit=_('files'), total=total)
578 self.ui.progress(_('archiving (%s)') % relpath, None)
578 self.ui.progress(_('archiving (%s)') % relpath, None)
@@ -782,7 +782,7 b' class hgsubrepo(abstractsubrepo):'
782 % (inst, subrelpath(self)))
782 % (inst, subrelpath(self)))
783
783
784 @annotatesubrepoerror
784 @annotatesubrepoerror
785 def archive(self, archiver, prefix, match=None):
785 def archive(self, archiver, prefix, match=None, decode=True):
786 self._get(self._state + ('hg',))
786 self._get(self._state + ('hg',))
787 total = abstractsubrepo.archive(self, archiver, prefix, match)
787 total = abstractsubrepo.archive(self, archiver, prefix, match)
788 rev = self._state[1]
788 rev = self._state[1]
@@ -790,7 +790,8 b' class hgsubrepo(abstractsubrepo):'
790 for subpath in ctx.substate:
790 for subpath in ctx.substate:
791 s = subrepo(ctx, subpath, True)
791 s = subrepo(ctx, subpath, True)
792 submatch = matchmod.subdirmatcher(subpath, match)
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 return total
795 return total
795
796
796 @annotatesubrepoerror
797 @annotatesubrepoerror
@@ -956,9 +957,12 b' class hgsubrepo(abstractsubrepo):'
956 ctx = self._repo[rev]
957 ctx = self._repo[rev]
957 return ctx.manifest().keys()
958 return ctx.manifest().keys()
958
959
959 def filedata(self, name):
960 def filedata(self, name, decode):
960 rev = self._state[1]
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 def fileflags(self, name):
967 def fileflags(self, name):
964 rev = self._state[1]
968 rev = self._state[1]
@@ -1292,7 +1296,7 b' class svnsubrepo(abstractsubrepo):'
1292 paths.append(name.encode('utf-8'))
1296 paths.append(name.encode('utf-8'))
1293 return paths
1297 return paths
1294
1298
1295 def filedata(self, name):
1299 def filedata(self, name, decode):
1296 return self._svncommand(['cat'], name)[0]
1300 return self._svncommand(['cat'], name)[0]
1297
1301
1298
1302
@@ -1772,7 +1776,7 b' class gitsubrepo(abstractsubrepo):'
1772 else:
1776 else:
1773 self.wvfs.unlink(f)
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 total = 0
1780 total = 0
1777 source, revision = self._state
1781 source, revision = self._state
1778 if not revision:
1782 if not revision:
@@ -470,6 +470,22 b' Test eol.only-consistent can be specifie'
470 > EOF
470 > EOF
471 $ hg commit -m 'consistent'
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 Test trailing newline
490 Test trailing newline
475
491
General Comments 0
You need to be logged in to leave comments. Login now