upgrade: simplify workaround for repo.ui.copy()
authorYuya Nishihara <yuya@tcha.org>
Sun, 10 Dec 2017 19:43:35 +0900
changeset 35379 6c28956ba2d4
parent 35378 9144e898cad5
child 35380 acff41957b34
upgrade: simplify workaround for repo.ui.copy() Copied from commandserver.py.
mercurial/upgrade.py
--- a/mercurial/upgrade.py	Sun Dec 10 19:41:49 2017 +0900
+++ b/mercurial/upgrade.py	Sun Dec 10 19:43:35 2017 +0900
@@ -847,19 +847,9 @@
             ui.write(_('creating temporary repository to stage migrated '
                        'data: %s\n') % tmppath)
 
-            # repo.ui is protected against copy:
-            #
-            # running `repo.ui.copy` actually call `repo.baseui.copy`. Here, we
-            # -really- wants to copy the actual `repo.ui` object (since we
-            # create a copy of the repository).
-            #
-            # We have to work around the protection.
-            oldcopy = repo.ui.copy
-            try:
-                repo.ui.__dict__.pop('copy', None)
-                dstrepo = hg.repository(repo.ui, path=tmppath, create=True)
-            finally:
-                repo.ui.copy = oldcopy
+            # clone ui without using ui.copy because repo.ui is protected
+            repoui = repo.ui.__class__(repo.ui)
+            dstrepo = hg.repository(repoui, path=tmppath, create=True)
 
             with dstrepo.wlock(), dstrepo.lock():
                 backuppath = _upgraderepo(ui, repo, dstrepo, newreqs,