diff --git a/mercurial/upgrade_utils/engine.py b/mercurial/upgrade_utils/engine.py --- a/mercurial/upgrade_utils/engine.py +++ b/mercurial/upgrade_utils/engine.py @@ -212,6 +212,34 @@ sidedatacompanion = getsidedatacompanion(srcrepo, dstrepo) + def _perform_clone( + old_revlog, + unencoded, + ): + """ returns the new revlog object created""" + newrl = None + if matchrevlog(revlogs, unencoded): + ui.note( + _(b'cloning %d revisions from %s\n') + % (len(old_revlog), unencoded) + ) + newrl = _revlogfrompath(dstrepo, unencoded) + oldrl.clone( + tr, + newrl, + addrevisioncb=oncopiedrevision, + deltareuse=deltareuse, + forcedeltabothparents=forcedeltabothparents, + sidedatacompanion=sidedatacompanion, + ) + else: + msg = _(b'blindly copying %s containing %i revisions\n') + ui.note(msg % (unencoded, len(old_revlog))) + _copyrevlog(tr, dstrepo, old_revlog, unencoded) + + newrl = _revlogfrompath(dstrepo, unencoded) + return newrl + # Do the actual copying. # FUTURE this operation can be farmed off to worker processes. seen = set() @@ -292,26 +320,7 @@ _(b'file revisions'), total=frevcount ) - if matchrevlog(revlogs, unencoded): - ui.note( - _(b'cloning %d revisions from %s\n') % (len(oldrl), unencoded) - ) - newrl = _revlogfrompath(dstrepo, unencoded) - oldrl.clone( - tr, - newrl, - addrevisioncb=oncopiedrevision, - deltareuse=deltareuse, - forcedeltabothparents=forcedeltabothparents, - sidedatacompanion=sidedatacompanion, - ) - else: - msg = _(b'blindly copying %s containing %i revisions\n') - ui.note(msg % (unencoded, len(oldrl))) - _copyrevlog(tr, dstrepo, oldrl, unencoded) - - newrl = _revlogfrompath(dstrepo, unencoded) - + newrl = _perform_clone(oldrl, unencoded) info = newrl.storageinfo(storedsize=True) datasize = info[b'storedsize'] or 0