##// END OF EJS Templates
changegroup: move generatefiles() from narrow...
Gregory Szorc -
r38925:a06aab27 default
parent child Browse files
Show More
@@ -10,47 +10,12 b' from __future__ import absolute_import'
10 from mercurial.i18n import _
10 from mercurial.i18n import _
11 from mercurial import (
11 from mercurial import (
12 changegroup,
12 changegroup,
13 error,
14 extensions,
13 extensions,
15 node,
14 node,
16 util,
15 util,
17 )
16 )
18
17
19 def setup():
18 def setup():
20 def generatefiles(orig, self, changedfiles, linknodes, commonrevs,
21 source):
22 changedfiles = list(filter(self._filematcher, changedfiles))
23
24 if getattr(self, 'is_shallow', False):
25 # See comment in generate() for why this sadness is a thing.
26 mfdicts = self._mfdicts
27 del self._mfdicts
28 # In a shallow clone, the linknodes callback needs to also include
29 # those file nodes that are in the manifests we sent but weren't
30 # introduced by those manifests.
31 commonctxs = [self._repo[c] for c in commonrevs]
32 oldlinknodes = linknodes
33 clrev = self._repo.changelog.rev
34 def linknodes(flog, fname):
35 for c in commonctxs:
36 try:
37 fnode = c.filenode(fname)
38 self.clrev_to_localrev[c.rev()] = flog.rev(fnode)
39 except error.ManifestLookupError:
40 pass
41 links = oldlinknodes(flog, fname)
42 if len(links) != len(mfdicts):
43 for mf, lr in mfdicts:
44 fnode = mf.get(fname, None)
45 if fnode in links:
46 links[fnode] = min(links[fnode], lr, key=clrev)
47 elif fnode:
48 links[fnode] = lr
49 return links
50 return orig(self, changedfiles, linknodes, commonrevs, source)
51 extensions.wrapfunction(
52 changegroup.cg1packer, 'generatefiles', generatefiles)
53
54 def generate(orig, self, commonrevs, clnodes, fastpathlinkrev, source):
19 def generate(orig, self, commonrevs, clnodes, fastpathlinkrev, source):
55 '''yield a sequence of changegroup chunks (strings)'''
20 '''yield a sequence of changegroup chunks (strings)'''
56 # Note: other than delegating to orig, the only deviation in
21 # Note: other than delegating to orig, the only deviation in
@@ -796,6 +796,42 b' class cg1packer(object):'
796
796
797 # The 'source' parameter is useful for extensions
797 # The 'source' parameter is useful for extensions
798 def generatefiles(self, changedfiles, linknodes, commonrevs, source):
798 def generatefiles(self, changedfiles, linknodes, commonrevs, source):
799 changedfiles = list(filter(self._filematcher, changedfiles))
800
801 if getattr(self, 'is_shallow', False):
802 # See comment in generate() for why this sadness is a thing.
803 mfdicts = self._mfdicts
804 del self._mfdicts
805 # In a shallow clone, the linknodes callback needs to also include
806 # those file nodes that are in the manifests we sent but weren't
807 # introduced by those manifests.
808 commonctxs = [self._repo[c] for c in commonrevs]
809 oldlinknodes = linknodes
810 clrev = self._repo.changelog.rev
811
812 # Defining this function has a side-effect of overriding the
813 # function of the same name that was passed in as an argument.
814 # TODO have caller pass in appropriate function.
815 def linknodes(flog, fname):
816 for c in commonctxs:
817 try:
818 fnode = c.filenode(fname)
819 self.clrev_to_localrev[c.rev()] = flog.rev(fnode)
820 except error.ManifestLookupError:
821 pass
822 links = oldlinknodes(flog, fname)
823 if len(links) != len(mfdicts):
824 for mf, lr in mfdicts:
825 fnode = mf.get(fname, None)
826 if fnode in links:
827 links[fnode] = min(links[fnode], lr, key=clrev)
828 elif fnode:
829 links[fnode] = lr
830 return links
831
832 return self._generatefiles(changedfiles, linknodes, commonrevs, source)
833
834 def _generatefiles(self, changedfiles, linknodes, commonrevs, source):
799 repo = self._repo
835 repo = self._repo
800 progress = repo.ui.makeprogress(_('bundling'), unit=_('files'),
836 progress = repo.ui.makeprogress(_('bundling'), unit=_('files'),
801 total=len(changedfiles))
837 total=len(changedfiles))
General Comments 0
You need to be logged in to leave comments. Login now