Commits

Graham Helliwell committed 128d09d Merge

Merge with TortoiseHg compatibility

  • Participants
  • Parent commits e1f3cc6, 00ac047
  • Branches Download

Comments (0)

Files changed (3)

guestrepo/__init__.py

          ],
          "hg grconvert [--branch]")
    }
-
-# hook run at mercurial startup just after ui object is created
-def uisetup(ui):
-    # from hgext/color.py
-    # make ui's class be lockedui a subclass of the current ui class
-    # think of it as inserting at the head of a linked list...
-    # TODO: do this on dispatch so we can only use it for gr* commands
-    if not issubclass(ui.__class__, lockedui.lockedui):
-        lockedui.lockedui.__bases__ = (ui.__class__,)
-        ui.__class__ = lockedui.lockedui

guestrepo/guestrepo.py

 import itertools
 import os
 
+import lockedui
 import mercurial.ui
 from mercurial import util, config, hg, commands, \
                       error, node, scmutil, bookmarks, localrepo
     if mapping:
         resolvemapping(guests, getmapping(repo, mapping == 'local'))
     for guest in guests:
-        newui = ui.copy()
-        newui.associate_guest(guest)
+        newui = lockedui.lockedui(ui)
         if guest.isrepo():
             def work(guest=guest,newui=newui):
                 checkcycles(guest.uri, bannedlocs)

guestrepo/lockedui.py

 
 import threading
 
-import mercurial.ui
+import mercurial.ui.ui as ui
 
 uilock = threading.RLock()
 
-class lockedui(mercurial.ui.ui):
+class lockedui(object):
     ''' A very quick and dirty way of keeping the user's terminal in a sane
         state
 
         threads may be contending for the lock.
     '''
     def __init__(self, src=None):
-        super(lockedui, self).__init__(src)
-        if src and hasattr(src, 'guest'):
-            self.guest = src.guest
+        super(lockedui, self).__init__()
+        if src:
+           if hasattr(src, 'guest'):
+              self.associate_guest(src.guest)
+           else:
+              self.associate_guest(src)
         else:
-            self.guest = None
+           self.guest = None
 
     # Each lockedui object MUST be associated with the correct guest to avoid
     # sending passwords to the wrong place.
     def associate_guest(self, guest):
         self.guest = guest
 
+    #Proxy the source object for everything else. This allows a single ui object to be used for all guest repos
+    def __getattr__(self, attrib):
+       return getattr(self.guest, attrib)
+
     # When multiple threads are used the prompts for usernames and passwords
     # may become unordered.
     # We can't stop that, but we can make the prompts unambiguous whenever they
         uilock.acquire()
         try:
             if self.guest:
-                return super(lockedui, self).prompt(
+                return self.guest.prompt(
                                         "%s::%s: %s" % (self.guest.configpath,
                                                         self.guest.uri, msg),
                                          *args, **opts)
             else:
-                return super(lockedui, self).prompt(msg, *args, **opts)
+                return self.guest.prompt(msg, *args, **opts)
         finally:
             uilock.release()
 
     def getpass(self, *args, **opts):
         uilock.acquire()
         if self.guest:
-                super(lockedui, self).write("%s::%s:\n" %
-                                                        (self.guest.configpath, 
+                self.guest.write("%s::%s:\n" %
+                                                        (self.guest.configpath,
                                                          self.guest.uri))
         try:
-            return super(lockedui, self).getpass(*args, **opts)
+            return self.guest.getpass(*args, **opts)
         finally:
             uilock.release()
 
     def write(self, *args, **opts):
         uilock.acquire()
         try:
-            return super(lockedui, self).write(*args, **opts)
+            return self.guest.write(*args, **opts)
         finally:
             uilock.release()
 
     def write_err(self, *args, **opts):
         uilock.acquire()
         try:
-            super(lockedui, self).write_err(*args, **opts)
+            self.guest.write_err(*args, **opts)
         finally:
             uilock.release()