##// END OF EJS Templates
localrepo: move the addchangegroupfiles method in changegroup module...
Pierre-Yves David -
r20932:0ac83e4e default
parent child Browse files
Show More
@@ -9,7 +9,7 b' from i18n import _'
9 from node import nullrev, nullid, hex
9 from node import nullrev, nullid, hex
10 import mdiff, util, dagutil
10 import mdiff, util, dagutil
11 import struct, os, bz2, zlib, tempfile
11 import struct, os, bz2, zlib, tempfile
12 import discovery
12 import discovery, error
13
13
14 _BUNDLE10_DELTA_HEADER = "20s20s20s20s"
14 _BUNDLE10_DELTA_HEADER = "20s20s20s20s"
15
15
@@ -514,3 +514,43 b' def changegroup(repo, basenodes, source)'
514 # to avoid a race we use changegroupsubset() (issue1320)
514 # to avoid a race we use changegroupsubset() (issue1320)
515 return changegroupsubset(repo, basenodes, repo.heads(), source)
515 return changegroupsubset(repo, basenodes, repo.heads(), source)
516
516
517 def addchangegroupfiles(repo, source, revmap, trp, pr, needfiles):
518 revisions = 0
519 files = 0
520 while True:
521 chunkdata = source.filelogheader()
522 if not chunkdata:
523 break
524 f = chunkdata["filename"]
525 repo.ui.debug("adding %s revisions\n" % f)
526 pr()
527 fl = repo.file(f)
528 o = len(fl)
529 if not fl.addgroup(source, revmap, trp):
530 raise util.Abort(_("received file revlog group is empty"))
531 revisions += len(fl) - o
532 files += 1
533 if f in needfiles:
534 needs = needfiles[f]
535 for new in xrange(o, len(fl)):
536 n = fl.node(new)
537 if n in needs:
538 needs.remove(n)
539 else:
540 raise util.Abort(
541 _("received spurious file revlog entry"))
542 if not needs:
543 del needfiles[f]
544 repo.ui.progress(_('files'), None)
545
546 for f, needs in needfiles.iteritems():
547 fl = repo.file(f)
548 for n in needs:
549 try:
550 fl.rev(n)
551 except error.LookupError:
552 raise util.Abort(
553 _('missing file data for %s:%s - run hg verify') %
554 (f, hex(n)))
555
556 return revisions, files
@@ -1775,8 +1775,12 b' class localrepository(object):'
1775 pr.total = efiles
1775 pr.total = efiles
1776 source.callback = None
1776 source.callback = None
1777
1777
1778 newrevs, newfiles = self.addchangegroupfiles(source, revmap, trp,
1778 newrevs, newfiles = changegroup.addchangegroupfiles(self,
1779 pr, needfiles)
1779 source,
1780 revmap,
1781 trp,
1782 pr,
1783 needfiles)
1780 revisions += newrevs
1784 revisions += newrevs
1781 files += newfiles
1785 files += newfiles
1782
1786
@@ -1864,46 +1868,6 b' class localrepository(object):'
1864 else:
1868 else:
1865 return dh + 1
1869 return dh + 1
1866
1870
1867 def addchangegroupfiles(self, source, revmap, trp, pr, needfiles):
1868 revisions = 0
1869 files = 0
1870 while True:
1871 chunkdata = source.filelogheader()
1872 if not chunkdata:
1873 break
1874 f = chunkdata["filename"]
1875 self.ui.debug("adding %s revisions\n" % f)
1876 pr()
1877 fl = self.file(f)
1878 o = len(fl)
1879 if not fl.addgroup(source, revmap, trp):
1880 raise util.Abort(_("received file revlog group is empty"))
1881 revisions += len(fl) - o
1882 files += 1
1883 if f in needfiles:
1884 needs = needfiles[f]
1885 for new in xrange(o, len(fl)):
1886 n = fl.node(new)
1887 if n in needs:
1888 needs.remove(n)
1889 else:
1890 raise util.Abort(
1891 _("received spurious file revlog entry"))
1892 if not needs:
1893 del needfiles[f]
1894 self.ui.progress(_('files'), None)
1895
1896 for f, needs in needfiles.iteritems():
1897 fl = self.file(f)
1898 for n in needs:
1899 try:
1900 fl.rev(n)
1901 except error.LookupError:
1902 raise util.Abort(
1903 _('missing file data for %s:%s - run hg verify') %
1904 (f, hex(n)))
1905
1906 return revisions, files
1907
1871
1908 def stream_in(self, remote, requirements):
1872 def stream_in(self, remote, requirements):
1909 lock = self.lock()
1873 lock = self.lock()
General Comments 0
You need to be logged in to leave comments. Login now