Mercurial > public > mercurial-scm > hg
comparison mercurial/changegroup.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 |
---|---|
7 | 7 |
8 from i18n import _ | 8 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 |
16 def readexactly(stream, n): | 16 def readexactly(stream, n): |
17 '''read n bytes from stream.read and abort if less was available''' | 17 '''read n bytes from stream.read and abort if less was available''' |
512 | 512 |
513 def changegroup(repo, basenodes, source): | 513 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 |