# HG changeset patch
# User Yuya Nishihara <y...@tcha.org>
# Date 1512902615 -32400
#      Sun Dec 10 19:43:35 2017 +0900
# Node ID d4a53118544e976ef3809e6e2fda77e39034da8d
# Parent  9766da17d816b8c919fc6df2ea6a493f533b615f
upgrade: simplify workaround for repo.ui.copy()

Copied from commandserver.py.

diff --git a/mercurial/upgrade.py b/mercurial/upgrade.py
--- a/mercurial/upgrade.py
+++ b/mercurial/upgrade.py
@@ -847,19 +847,9 @@ def upgraderepo(ui, repo, run=False, opt
             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,
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to