Mercurial > hg
comparison mercurial/localrepo.py @ 20932:0ac83e4e4f7c
localrepo: move the addchangegroupfiles method in changegroup module
This is a gratuitous code move aimed at reducing the localrepo bloatness.
The method had a single caller, far too few for being kept in local repo.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Tue, 01 Apr 2014 15:21:56 -0700 |
parents | de60ca3a390e |
children | d3775db748a0 |
comparison
equal
deleted
inserted
replaced
20931:de60ca3a390e | 20932:0ac83e4e4f7c |
---|---|
1773 pr.step = _('files') | 1773 pr.step = _('files') |
1774 pr.count = 1 | 1774 pr.count = 1 |
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 |
1783 dh = 0 | 1787 dh = 0 |
1784 if oldheads: | 1788 if oldheads: |
1862 if dh < 0: | 1866 if dh < 0: |
1863 return dh - 1 | 1867 return dh - 1 |
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() |
1910 try: | 1874 try: |
1911 # Save remote branchmap. We will use it later | 1875 # Save remote branchmap. We will use it later |