Commits

Yuya Nishihara committed c213f77

workbench: adapt to new repository access layer

  • Participants
  • Parent commits 6c3effc

Comments (0)

Files changed (2)

tortoisehg/hgqt/qtapp.py

 
     def createWorkbench(self):
         """Create Workbench window and keep single reference"""
-        assert self._ui and self._mainapp
+        assert self._ui and self._mainapp and self._repomanager
         assert not self._workbench
-        self._workbench = workbench.Workbench(self._ui)
+        self._workbench = workbench.Workbench(self._ui, self._repomanager)
         return self._workbench
 
     def showRepoInWorkbench(self, uroot, rev=-1):

tortoisehg/hgqt/workbench.py

 from mercurial.error import RepoError
 from tortoisehg.util import paths, hglib
 
-from tortoisehg.hgqt import thgrepo, cmdui, qtlib, mq, serve
+from tortoisehg.hgqt import cmdui, qtlib, mq, serve
 from tortoisehg.hgqt.i18n import _
 from tortoisehg.hgqt.repowidget import RepoWidget
 from tortoisehg.hgqt.reporegistry import RepoRegistryView
     """hg repository viewer/browser application"""
     finished = pyqtSignal(int)
 
-    def __init__(self, ui):
+    def __init__(self, ui, repomanager):
         QMainWindow.__init__(self)
         self.progressDialog = QProgressDialog(
             'TortoiseHg - Initializing Workbench', QString(), 0, 100)
         self.progressDialog.setAutoClose(False)
 
         self.ui = ui
+        self._repomanager = repomanager
 
         self.setupUi()
         self.setWindowTitle(_('TortoiseHg Workbench'))
                     self.repoTabsWidget.setCurrentWidget(rw)
                     return
             try:
-                repo = thgrepo.repository(path=hglib.fromunicode(root))
-                self.addRepoTab(repo, bundle)
+                repoagent = self._repomanager.openRepoAgent(root)
+                self.addRepoTab(repoagent, bundle)
             except RepoError, e:
                 qtlib.WarningMsgBox(_('Failed to open repository'),
                                     hglib.tounicode(str(e)), parent=self)
             if w.closeRepoWidget():
                 tw.removeTab(index)
                 w.deleteLater()
+                self._repomanager.releaseRepoAgent(reporoot)
                 self.updateMenu()
                 self.lastClosedRepoRootList = [reporoot]
 
         if index == self.repoTabsWidget.currentIndex():
             self._updateWindowTitle()
 
-    def addRepoTab(self, repo, bundle):
+    def addRepoTab(self, repoagent, bundle):
         '''opens the given repo in a new tab'''
+        repo = repoagent.rawRepo()  # TODO: pass repoagent to RepoWidget
         rw = RepoWidget(repo, self, bundle=bundle)
         rw.showMessageSignal.connect(self.showMessage)
         rw.closeSelfSignal.connect(self.repoTabCloseSelf)
                 tw.currentIndex()+1, rw, rw.title())
         else:
             index = self.repoTabsWidget.addTab(rw, rw.title())
-        tw.setTabToolTip(index, hglib.tounicode(repo.root))
+        tw.setTabToolTip(index, repoagent.rootPath())
         tw.setCurrentIndex(index)
         rw.titleChanged.connect(self._updateRepoTabTitle)
         rw.repoConfigChanged.connect(self._setupUrlComboIfCurrent)
         rw.showIcon.connect(
             lambda icon: tw.setTabIcon(tw.indexOf(rw), icon))
-        self.reporegistry.addRepo(hglib.tounicode(repo.root))
+        self.reporegistry.addRepo(repoagent.rootPath())
 
         self.updateMenu()
         return rw