[PATCH 2 of 5] hg: warn if repo.ui is passed to peer, mark repo.ui for doing this

Simon Heimberg simohe at besonet.ch
Thu Oct 4 22:02:59 CDT 2012


# HG changeset patch
# User Simon Heimberg <simohe at besonet.ch>
# Date 1349372803 -7200
# Node ID ff1415eadfcf9ac09ef2284c96ee634c8d026c7a
# Parent  6534875298b6bf8bd6f81ae641ae27e420814cb1
hg: warn if repo.ui is passed to peer, mark repo.ui for doing this

diff -r 6534875298b6 -r ff1415eadfcf mercurial/hg.py
--- a/mercurial/hg.py	Don Okt 04 19:46:42 2012 +0200
+++ b/mercurial/hg.py	Don Okt 04 19:46:43 2012 +0200
@@ -577,6 +577,9 @@
         src = src.ui # copy target options from repo
     else: # assume it's a global ui object
         dst = src.copy() # keep all global options
+        if src.isinrepo:
+            src.write_err(' PROGRAMMER WARNING: '
+                          'pass repo (not repo.ui) to hg.peer\n')
 
     # copy ssh-specific options
     for o in 'ssh', 'remotecmd':
diff -r 6534875298b6 -r ff1415eadfcf mercurial/localrepo.py
--- a/mercurial/localrepo.py	Don Okt 04 19:46:42 2012 +0200
+++ b/mercurial/localrepo.py	Don Okt 04 19:46:43 2012 +0200
@@ -127,6 +127,7 @@
         self.opener = self.vfs
         self.baseui = baseui
         self.ui = baseui.copy()
+        self.ui.isinrepo = True
         # A list of callback to shape the phase if no data were found.
         # Callback are in the form: func(repo, roots) --> processed root.
         # This list it to be filled by extension during repo setup
diff -r 6534875298b6 -r ff1415eadfcf mercurial/ui.py
--- a/mercurial/ui.py	Don Okt 04 19:46:42 2012 +0200
+++ b/mercurial/ui.py	Don Okt 04 19:46:43 2012 +0200
@@ -10,6 +10,7 @@
 import config, scmutil, util, error, formatter
 
 class ui(object):
+    isinrepo = False
     def __init__(self, src=None):
         self._buffers = []
         self.quiet = self.verbose = self.debugflag = self.tracebackflag = False


More information about the Mercurial-devel mailing list