subrepo: drop the 'ui' parameter to revert()
authorMatt Harbison <matt_harbison@yahoo.com>
Sat, 13 Dec 2014 19:44:55 -0500
changeset 23579 e1c39f207719
parent 23578 d0546e8e1def
child 23580 e20f36ad092e
subrepo: drop the 'ui' parameter to revert() This no longer needs to be explicitly passed because the subrepo object tracks the 'ui' reference since fcbc66b5da6a. See the change to 'archive' for details about the differences between the output level in the root repo and subrepo 'ui' object. The only use for 'ui' in revert is to emit status and warning messages, and to check the verbose flag prior to printing the action to be performed on a file. The local repo's ui was already being used to print a warning message in wctx.forget() and for 'ui.slash' when walking dirstate in the repo.status() call. Unlike other methods where the matcher is passed along and narrowed, a new matcher is created in each repo, and therefore the bad() method already used the local repo's ui.
mercurial/cmdutil.py
mercurial/subrepo.py
--- a/mercurial/cmdutil.py	Sat Dec 13 19:36:50 2014 -0500
+++ b/mercurial/cmdutil.py	Sat Dec 13 19:44:55 2014 -0500
@@ -2801,7 +2801,7 @@
             if targetsubs:
                 # Revert the subrepos on the revert list
                 for sub in targetsubs:
-                    ctx.sub(sub).revert(ui, ctx.substate[sub], *pats, **opts)
+                    ctx.sub(sub).revert(ctx.substate[sub], *pats, **opts)
     finally:
         wlock.release()
 
--- a/mercurial/subrepo.py	Sat Dec 13 19:36:50 2014 -0500
+++ b/mercurial/subrepo.py	Sat Dec 13 19:44:55 2014 -0500
@@ -506,8 +506,8 @@
         """
         return 1
 
-    def revert(self, ui, substate, *pats, **opts):
-        ui.warn('%s: reverting %s subrepos is unsupported\n' \
+    def revert(self, substate, *pats, **opts):
+        self.ui.warn('%s: reverting %s subrepos is unsupported\n' \
             % (substate[0], substate[2]))
         return []
 
@@ -861,13 +861,13 @@
                               subrepos)
 
     @annotatesubrepoerror
-    def revert(self, ui, substate, *pats, **opts):
+    def revert(self, substate, *pats, **opts):
         # reverting a subrepo is a 2 step process:
         # 1. if the no_backup is not set, revert all modified
         #    files inside the subrepo
         # 2. update the subrepo to the revision specified in
         #    the corresponding substate dictionary
-        ui.status(_('reverting subrepo %s\n') % substate[0])
+        self.ui.status(_('reverting subrepo %s\n') % substate[0])
         if not opts.get('no_backup'):
             # Revert all files on the subrepo, creating backups
             # Note that this will not recursively revert subrepos
@@ -879,19 +879,19 @@
             pats = []
             if not opts.get('all'):
                 pats = ['set:modified()']
-            self.filerevert(ui, *pats, **opts)
+            self.filerevert(*pats, **opts)
 
         # Update the repo to the revision specified in the given substate
         self.get(substate, overwrite=True)
 
-    def filerevert(self, ui, *pats, **opts):
+    def filerevert(self, *pats, **opts):
         ctx = self._repo[opts['rev']]
         parents = self._repo.dirstate.parents()
         if opts.get('all'):
             pats = ['set:modified()']
         else:
             pats = []
-        cmdutil.revert(ui, self._repo, ctx, parents, *pats, **opts)
+        cmdutil.revert(self.ui, self._repo, ctx, parents, *pats, **opts)
 
     def shortid(self, revid):
         return revid[:12]