pulkit created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  The `for ...` under which this cloning code exists is too complicated and 
based
  on certain assumptions. I am going to refactor it in next patches and make it
  bit saner.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D9579

AFFECTED FILES
  mercurial/upgrade_utils/engine.py

CHANGE DETAILS

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
 



To: pulkit, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to