Patchwork [3,of,3] upgrade: simplify workaround for repo.ui.copy()

login
register
mail settings
Submitter Yuya Nishihara
Date Dec. 10, 2017, 10:58 a.m.
Message ID <d4a53118544e976ef380.1512903497@mimosa>
Download mbox | patch
Permalink /patch/26197/
State Accepted
Headers show

Comments

Yuya Nishihara - Dec. 10, 2017, 10:58 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@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.

Patch

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,