Details
Details
- Reviewers
- None
- Group Reviewers
hg-reviewers - Commits
- rHG83534c4ec58b: changegroup: use progress helper in apply() (API)
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
hg-reviewers |
Lint Skipped |
Unit Tests Skipped |
Path | Packages | |||
---|---|---|---|---|
M | mercurial/changegroup.py (34 lines) |
Commit | Parents | Author | Summary | Date |
---|---|---|---|---|
Martin von Zweigbergk | Jun 16 2018, 2:04 AM |
Status | Author | Revision | |
---|---|---|---|
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz |
yield chunkheader(len(chunk)) | yield chunkheader(len(chunk)) | ||||
pos = 0 | pos = 0 | ||||
while pos < len(chunk): | while pos < len(chunk): | ||||
next = pos + 2**20 | next = pos + 2**20 | ||||
yield chunk[pos:next] | yield chunk[pos:next] | ||||
pos = next | pos = next | ||||
yield closechunk() | yield closechunk() | ||||
def _unpackmanifests(self, repo, revmap, trp, prog, numchanges): | def _unpackmanifests(self, repo, revmap, trp, prog): | ||||
# We know that we'll never have more manifests than we had | self.callback = prog.increment | ||||
# changesets. | |||||
self.callback = prog(_('manifests'), numchanges) | |||||
# no need to check for empty manifest group here: | # no need to check for empty manifest group here: | ||||
# if the result of the merge of 1 and 2 is the same in 3 and 4, | # if the result of the merge of 1 and 2 is the same in 3 and 4, | ||||
# no new manifest will be created and the manifest group will | # no new manifest will be created and the manifest group will | ||||
# be empty during the pull | # be empty during the pull | ||||
self.manifestheader() | self.manifestheader() | ||||
deltas = self.deltaiter() | deltas = self.deltaiter() | ||||
repo.manifestlog._revlog.addgroup(deltas, revmap, trp) | repo.manifestlog._revlog.addgroup(deltas, revmap, trp) | ||||
repo.ui.progress(_('manifests'), None) | prog.update(None) | ||||
self.callback = None | self.callback = None | ||||
def apply(self, repo, tr, srctype, url, targetphase=phases.draft, | def apply(self, repo, tr, srctype, url, targetphase=phases.draft, | ||||
expectedtotal=None): | expectedtotal=None): | ||||
"""Add the changegroup returned by source.read() to this repo. | """Add the changegroup returned by source.read() to this repo. | ||||
srctype is a string like 'push', 'pull', or 'unbundle'. url is | srctype is a string like 'push', 'pull', or 'unbundle'. url is | ||||
the URL of the repo where this changegroup is coming from. | the URL of the repo where this changegroup is coming from. | ||||
cl = repo.changelog | cl = repo.changelog | ||||
cl.delayupdate(tr) | cl.delayupdate(tr) | ||||
oldheads = set(cl.heads()) | oldheads = set(cl.heads()) | ||||
trp = weakref.proxy(tr) | trp = weakref.proxy(tr) | ||||
# pull off the changeset group | # pull off the changeset group | ||||
repo.ui.status(_("adding changesets\n")) | repo.ui.status(_("adding changesets\n")) | ||||
clstart = len(cl) | clstart = len(cl) | ||||
class prog(object): | progress = repo.ui.makeprogress(_('changesets'), unit=_('chunks'), | ||||
def __init__(self, step, total): | total=expectedtotal) | ||||
self._step = step | self.callback = progress.increment | ||||
self._total = total | |||||
self._count = 1 | |||||
def __call__(self): | |||||
repo.ui.progress(self._step, self._count, unit=_('chunks'), | |||||
total=self._total) | |||||
self._count += 1 | |||||
self.callback = prog(_('changesets'), expectedtotal) | |||||
efiles = set() | efiles = set() | ||||
def onchangelog(cl, node): | def onchangelog(cl, node): | ||||
efiles.update(cl.readfiles(node)) | efiles.update(cl.readfiles(node)) | ||||
self.changelogheader() | self.changelogheader() | ||||
deltas = self.deltaiter() | deltas = self.deltaiter() | ||||
cgnodes = cl.addgroup(deltas, csmap, trp, addrevisioncb=onchangelog) | cgnodes = cl.addgroup(deltas, csmap, trp, addrevisioncb=onchangelog) | ||||
efiles = len(efiles) | efiles = len(efiles) | ||||
if not cgnodes: | if not cgnodes: | ||||
repo.ui.develwarn('applied empty changegroup', | repo.ui.develwarn('applied empty changegroup', | ||||
config='warn-empty-changegroup') | config='warn-empty-changegroup') | ||||
clend = len(cl) | clend = len(cl) | ||||
changesets = clend - clstart | changesets = clend - clstart | ||||
repo.ui.progress(_('changesets'), None) | progress.update(None) | ||||
self.callback = None | self.callback = None | ||||
# pull off the manifest group | # pull off the manifest group | ||||
repo.ui.status(_("adding manifests\n")) | repo.ui.status(_("adding manifests\n")) | ||||
self._unpackmanifests(repo, revmap, trp, prog, changesets) | # We know that we'll never have more manifests than we had | ||||
# changesets. | |||||
progress = repo.ui.makeprogress(_('manifests'), unit=_('chunks'), | |||||
total=changesets) | |||||
self._unpackmanifests(repo, revmap, trp, progress) | |||||
needfiles = {} | needfiles = {} | ||||
if repo.ui.configbool('server', 'validate'): | if repo.ui.configbool('server', 'validate'): | ||||
cl = repo.changelog | cl = repo.changelog | ||||
ml = repo.manifestlog | ml = repo.manifestlog | ||||
# validate incoming csets have their manifests | # validate incoming csets have their manifests | ||||
for cset in xrange(clstart, clend): | for cset in xrange(clstart, clend): | ||||
mfnode = cl.changelogrevision(cset).manifest | mfnode = cl.changelogrevision(cset).manifest | ||||
deltaheadersize = struct.calcsize(deltaheader) | deltaheadersize = struct.calcsize(deltaheader) | ||||
version = '03' | version = '03' | ||||
_grouplistcount = 2 # One list of manifests and one list of files | _grouplistcount = 2 # One list of manifests and one list of files | ||||
def _deltaheader(self, headertuple, prevnode): | def _deltaheader(self, headertuple, prevnode): | ||||
node, p1, p2, deltabase, cs, flags = headertuple | node, p1, p2, deltabase, cs, flags = headertuple | ||||
return node, p1, p2, deltabase, cs, flags | return node, p1, p2, deltabase, cs, flags | ||||
def _unpackmanifests(self, repo, revmap, trp, prog, numchanges): | def _unpackmanifests(self, repo, revmap, trp, prog): | ||||
super(cg3unpacker, self)._unpackmanifests(repo, revmap, trp, prog, | super(cg3unpacker, self)._unpackmanifests(repo, revmap, trp, prog) | ||||
numchanges) | |||||
for chunkdata in iter(self.filelogheader, {}): | for chunkdata in iter(self.filelogheader, {}): | ||||
# If we get here, there are directory manifests in the changegroup | # If we get here, there are directory manifests in the changegroup | ||||
d = chunkdata["filename"] | d = chunkdata["filename"] | ||||
repo.ui.debug("adding %s revisions\n" % d) | repo.ui.debug("adding %s revisions\n" % d) | ||||
dirlog = repo.manifestlog._revlog.dirlog(d) | dirlog = repo.manifestlog._revlog.dirlog(d) | ||||
deltas = self.deltaiter() | deltas = self.deltaiter() | ||||
if not dirlog.addgroup(deltas, revmap, trp): | if not dirlog.addgroup(deltas, revmap, trp): | ||||
raise error.Abort(_("received dir revlog group is empty")) | raise error.Abort(_("received dir revlog group is empty")) |