Mercurial > hg-stable
diff mercurial/localrepo.py @ 19291:93635f69c93b
changegroup: move changegroup file adding to a separate function
Moving the logic that adds files to a changegroup to a different function
allows extensions to override it and customize the way filelogs are added
to changegroups.
No logic is changed.
author | Durham Goode <durham@fb.com> |
---|---|
date | Thu, 30 May 2013 19:26:56 -0700 |
parents | e9c5b1c246dc |
children | 14c91b18d798 |
line wrap: on
line diff
--- a/mercurial/localrepo.py Thu May 30 19:25:55 2013 -0700 +++ b/mercurial/localrepo.py Thu May 30 19:26:56 2013 -0700 @@ -2143,41 +2143,10 @@ pr.total = efiles source.callback = None - while True: - chunkdata = source.filelogheader() - if not chunkdata: - break - f = chunkdata["filename"] - self.ui.debug("adding %s revisions\n" % f) - pr() - fl = self.file(f) - o = len(fl) - if not fl.addgroup(source, revmap, trp): - raise util.Abort(_("received file revlog group is empty")) - revisions += len(fl) - o - files += 1 - if f in needfiles: - needs = needfiles[f] - for new in xrange(o, len(fl)): - n = fl.node(new) - if n in needs: - needs.remove(n) - else: - raise util.Abort( - _("received spurious file revlog entry")) - if not needs: - del needfiles[f] - self.ui.progress(_('files'), None) - - for f, needs in needfiles.iteritems(): - fl = self.file(f) - for n in needs: - try: - fl.rev(n) - except error.LookupError: - raise util.Abort( - _('missing file data for %s:%s - run hg verify') % - (f, hex(n))) + newrevs, newfiles = self.addchangegroupfiles(source, revmap, trp, + pr, needfiles) + revisions += newrevs + files += newfiles dh = 0 if oldheads: @@ -2257,6 +2226,47 @@ else: return dh + 1 + def addchangegroupfiles(self, source, revmap, trp, pr, needfiles): + revisions = 0 + files = 0 + while True: + chunkdata = source.filelogheader() + if not chunkdata: + break + f = chunkdata["filename"] + self.ui.debug("adding %s revisions\n" % f) + pr() + fl = self.file(f) + o = len(fl) + if not fl.addgroup(source, revmap, trp): + raise util.Abort(_("received file revlog group is empty")) + revisions += len(fl) - o + files += 1 + if f in needfiles: + needs = needfiles[f] + for new in xrange(o, len(fl)): + n = fl.node(new) + if n in needs: + needs.remove(n) + else: + raise util.Abort( + _("received spurious file revlog entry")) + if not needs: + del needfiles[f] + self.ui.progress(_('files'), None) + + for f, needs in needfiles.iteritems(): + fl = self.file(f) + for n in needs: + try: + fl.rev(n) + except error.LookupError: + raise util.Abort( + _('missing file data for %s:%s - run hg verify') % + (f, hex(n))) + + return revisions, files + def stream_in(self, remote, requirements): lock = self.lock() try: