Mercurial and Git clients can push and pull from this alias URL to interact with this repository. You can change to which repository an alias points by going to the Aliases link on the project page.
# manifestdialog.py - Dialog and widget for TortoiseHg manifest view## Copyright (C) 2003-2010 LOGILAB S.A. <http://www.logilab.fr/># Copyright (C) 2010 Yuya Nishihara <yuya@tcha.org>## This program is free software; you can redistribute it and/or modify it under# the terms of the GNU General Public License as published by the Free Software# Foundation; either version 2 of the License, or (at your option) any later# version.importosfrommercurialimportutilfromPyQt4.QtCoreimport*fromPyQt4.QtGuiimport*fromtortoisehg.utilimportpaths,hglibfromtortoisehg.hgqt.i18nimport_fromtortoisehg.hgqtimportqtlib,qscilib,annotate,status,thgrepofromtortoisehg.hgqtimportvisdiff,wctxactions,revertfromtortoisehg.hgqt.filedialogsimportFileLogDialog,FileDiffDialogfromtortoisehg.hgqt.manifestmodelimportManifestModelclassManifestDialog(QMainWindow):""" Qt4 dialog to display all files of a repo at a given revision """finished=pyqtSignal(int)def__init__(self,repo,rev=None,parent=None):QMainWindow.__init__(self,parent)self._repo=repoself.setWindowIcon(qtlib.geticon('hg-annotate'))self.resize(400,300)self._manifest_widget=ManifestWidget(repo,rev)self._manifest_widget.revChanged.connect(self._updatewindowtitle)self._manifest_widget.pathChanged.connect(self._updatewindowtitle)self._manifest_widget.editSelected.connect(self._openInEditor)self._manifest_widget.grepRequested.connect(self._openSearchWidget)self.setCentralWidget(self._manifest_widget)self.addToolBar(self._manifest_widget.toolbar)self._searchbar=qscilib.SearchToolBar()connectsearchbar(self._manifest_widget,self._searchbar)self.addToolBar(self._searchbar)QShortcut(QKeySequence.Find,self,lambda:self._searchbar.setFocus(Qt.OtherFocusReason))self.setStatusBar(QStatusBar())self._manifest_widget.revisionHint.connect(self.statusBar().showMessage)self._readsettings()self._updatewindowtitle()@pyqtSlot()def_updatewindowtitle(self):self.setWindowTitle(_('Manifest %s@%s')%(self._manifest_widget.path,self._manifest_widget.rev))defcloseEvent(self,event):self._writesettings()super(ManifestDialog,self).closeEvent(event)self.finished.emit(0)# mimic QDialog exitdef_readsettings(self):s=QSettings()self.restoreGeometry(s.value('manifest/geom').toByteArray())self._manifest_widget.loadSettings(s,'manifest')def_writesettings(self):s=QSettings()s.setValue('manifest/geom',self.saveGeometry())self._manifest_widget.saveSettings(s,'manifest')defsetSource(self,path,rev,line=None):self._manifest_widget.setSource(path,rev,line)defsetSearchPattern(self,text):"""Set search pattern [unicode]"""self._searchbar.setPattern(text)@pyqtSlot(unicode,dict)def_openSearchWidget(self,pattern,opts):opts=dict((str(k),str(v))fork,vinopts.iteritems())fromtortoisehg.hgqtimportrunrun.grep(self._repo.ui,hglib.fromunicode(pattern),**opts)@pyqtSlot(unicode,object,int)def_openInEditor(self,path,rev,line):"""Open editor to show the specified file"""_openineditor(self._repo,path,rev,line,pattern=self._searchbar.pattern(),parent=self)classManifestWidget(QWidget):"""Display file tree and contents at the specified revision"""revChanged=pyqtSignal(object)"""Emitted (rev) when the current revision changed"""pathChanged=pyqtSignal(unicode)"""Emitted (path) when the current file path changed"""revisionHint=pyqtSignal(unicode)"""Emitted when to show revision summary as a hint"""searchRequested=pyqtSignal(unicode)"""Emitted (pattern) when user request to search content"""editSelected=pyqtSignal(unicode,object,int)"""Emitted (path, rev, line) when user requests to open editor"""grepRequested=pyqtSignal(unicode,dict)"""Emitted (pattern, opts) when user request to search changelog"""contextmenu=Nonedef__init__(self,repo,rev=None,parent=None):super(ManifestWidget,self).__init__(parent)self._repo=repoself._rev=revself._diff_dialogs={}self._nav_dialogs={}self._initwidget()self._initactions()self._setupmodel()self._treeview.setCurrentIndex(self._treemodel.index(0,0))self.setRev(self._rev)def_initwidget(self):self.setLayout(QVBoxLayout())self._splitter=QSplitter()self.layout().addWidget(self._splitter)self.layout().setContentsMargins(2,2,2,2)navlayout=QVBoxLayout(spacing=0)navlayout.setContentsMargins(0,0,0,0)self._toolbar=QToolBar()self._toolbar.setIconSize(QSize(16,16))self._treeview=QTreeView(self,headerHidden=True,dragEnabled=True)self._treeview.setContextMenuPolicy(Qt.CustomContextMenu)self._treeview.customContextMenuRequested.connect(self.menuRequest)navlayout.addWidget(self._toolbar)navlayout.addWidget(self._treeview)navlayoutw=QWidget()navlayoutw.setLayout(navlayout)self._contentview=QStackedWidget()self._splitter.addWidget(navlayoutw)self._splitter.addWidget(self._contentview)self._splitter.setStretchFactor(0,1)self._splitter.setStretchFactor(1,3)self._nullcontent=QWidget()self._contentview.addWidget(self._nullcontent)self._fileview=annotate.AnnotateView(self._repo)self._fileview.sourceChanged.connect(self.setSource)self._contentview.addWidget(self._fileview)fornamein('revisionHint','searchRequested','editSelected','grepRequested'):getattr(self._fileview,name).connect(getattr(self,name))defloadSettings(self,qs,prefix):prefix+='/manifest'self._fileview.loadSettings(qs,prefix+'/fileview')self._splitter.restoreState(qs.value(prefix+'/splitter').toByteArray())defsaveSettings(self,qs,prefix):prefix+='/manifest'self._fileview.saveSettings(qs,prefix+'/fileview')qs.setValue(prefix+'/splitter',self._splitter.saveState())def_initactions(self):self._statusfilter=status.StatusFilterButton(statustext='MAC',text=_('Status'))self._toolbar.addWidget(self._statusfilter)self._action_annotate_mode=QAction(_('Annotate'),self,checkable=True)self._action_annotate_mode.toggled.connect(self._fileview.setAnnotationEnabled)self._action_annotate_mode.setEnabled(self.revisnotNone)self._toolbar.addAction(self._action_annotate_mode)ifhasattr(self,'_searchbar'):self._action_find=self._searchbar.toggleViewAction()self._action_find.setIcon(qtlib.geticon('edit-find'))self._action_find.setShortcut(QKeySequence.Find)self._toolbar.addAction(self._action_find)self._actions={}forname,desc,icon,key,tip,cbin[('navigate',_('File history'),'hg-log','Shift+Return',_('Show the history of the selected file'),self.navigate),('diffnavigate',_('Compare file revisions'),'compare-files',None,_('Compare revisions of the selected file'),self.diffNavigate),('diff',_('Visual Diff'),'visualdiff','Ctrl+D',_('View file changes in external diff tool'),self.vdiff),('ldiff',_('Visual Diff to Local'),'ldiff','Shift+Ctrl+D',_('View changes to current in external diff tool'),self.vdifflocal),('edit',_('View at Revision'),'view-at-revision','Alt+Ctrl+E',_('View file as it appeared at this revision'),self.editfile),('ledit',_('Edit Local'),'edit-file','Shift+Ctrl+E',_('Edit current file in working copy'),self.editlocal),('revert',_('Revert to Revision'),'hg-revert','Alt+Ctrl+T',_('Revert file(s) to contents at this revision'),self.revertfile),]:act=QAction(desc,self)ificon:act.setIcon(qtlib.getmenuicon(icon))ifkey:act.setShortcut(key)iftip:act.setStatusTip(tip)ifcb:act.triggered.connect(cb)self._actions[name]=actself.addAction(act)defnavigate(self,filename=None):self._navigate(filename,FileLogDialog,self._nav_dialogs)defdiffNavigate(self,filename=None):self._navigate(filename,FileDiffDialog,self._diff_dialogs)defvdiff(self):ifself.pathisNone:returnpats=[self.path]opts={'change':self.rev}dlg=visdiff.visualdiff(self._repo.ui,self._repo,pats,opts)ifdlg:dlg.exec_()defvdifflocal(self):ifself.pathisNone:returnpats=[self.path]asserttype(self.rev)isintopts={'rev':['rev(%d)'%self.rev]}dlg=visdiff.visualdiff(self._repo.ui,self._repo,pats,opts)ifdlg:dlg.exec_()defeditfile(self):ifself.pathisNone:returnifself.revisNone:files=[self._repo.wjoin(self.path)]wctxactions.edit(self,self._repo.ui,self._repo,files)else:base,_=visdiff.snapshot(self._repo,[self.path],self._repo[self.rev])files=[os.path.join(base,self.path)]wctxactions.edit(self,self._repo.ui,self._repo,files)defeditlocal(self):ifself.pathisNone:returnpath=self._repo.wjoin(self.path)wctxactions.edit(self,self._repo.ui,self._repo,[path])defrevertfile(self):ifself.pathisNone:returnifself.revisNone:rev=self._repo['.'].rev()dlg=revert.RevertDialog(self._repo,self.path,self.rev,self)dlg.exec_()def_navigate(self,filename,dlgclass,dlgdict):ifnotfilename:filename=self.pathiffilenamenotindlgdict:dlg=dlgclass(self._repo,filename,repoviewer=self.window())dlgdict[filename]=dlgufname=hglib.tounicode(filename)dlg.setWindowTitle(_('Hg file log viewer - %s')%ufname)dlg=dlgdict[filename]dlg.goto(self.rev)dlg.show()dlg.raise_() dlg.activateWindow()
def menuRequest(self, point):
+ selmodel = self._treeview.selectionModel()+ if not selmodel.selectedRows():+ return point = self.mapToGlobal(point)
if not self.contextmenu:
self.contextmenu = QMenu(self)
foractin['diff','ldiff','edit','ledit','revert','navigate','diffnavigate']:ifact:self.contextmenu.addAction(self._actions[act])else:self.contextmenu.addSeparator()self.contextmenu.exec_(point)@propertydeftoolbar(self):"""Return toolbar for manifest widget"""returnself._toolbar@pyqtSlot(unicode,bool,bool,bool)deffind(self,pattern,icase=False,wrap=False,forward=True):returnself._fileview.find(pattern,icase,wrap,forward)@pyqtSlot(unicode,bool)defhighlightText(self,pattern,icase=False):self._fileview.highlightText(pattern,icase)def_setupmodel(self):self._treemodel=ManifestModel(self._repo,self._rev,statusfilter=self._statusfilter.status(),parent=self)oldmodel=self._treeview.model()oldselmodel=self._treeview.selectionModel()self._treeview.setModel(self._treemodel)ifoldmodel:oldmodel.deleteLater()ifoldselmodel:oldselmodel.deleteLater()selmodel=self._treeview.selectionModel()selmodel.currentChanged.connect(self._updatecontent)selmodel.currentChanged.connect(self._emitPathChanged)self._statusfilter.statusChanged.connect(self._treemodel.setStatusFilter)self._statusfilter.statusChanged.connect(self._autoexpandtree)self._autoexpandtree()@pyqtSlot()def_autoexpandtree(self):"""expand file tree if the number of the items isn't large"""if'C'notinself._statusfilter.status():self._treeview.expandAll()defreload(self):# TODOpassdefsetRepo(self,repo):self._repo=repo#self._fileview.setRepo(repo)self._fileview.repo=repoiflen(repo)<=self._rev:self._rev=len(repo)-1self._setupmodel()@propertydefrev(self):"""Return current revision"""returnself._rev@pyqtSlot(object)defsetRev(self,rev):"""Change revision to show"""self.setSource(self.path,rev)real=type(rev)isintself._actions['ldiff'].setEnabled(real)foractin['diff','edit']:self._actions[act].setEnabled(realorrevisNone)self._actions['revert'].setEnabled(real)@pyqtSlot(unicode,object)@pyqtSlot(unicode,object,int)defsetSource(self,path,rev,line=None):"""Change path and revision to show at once"""revchanged=self._rev!=revifrevchanged:self._rev=revself._setupmodel()self.setPath(path)ifself.pathinself._repo[rev]:self._fileview.setSource(path,rev,line)ifrevchanged:# annotate working copy is not supportedself._action_annotate_mode.setEnabled(revisnotNone)self.revChanged.emit(rev)@propertydefpath(self):"""Return currently selected path"""returnself._treemodel.filePath(self._treeview.currentIndex())@pyqtSlot(unicode)defsetPath(self,path):"""Change path to show"""self._treeview.setCurrentIndex(self._treemodel.indexFromPath(path))@pyqtSlot()def_updatecontent(self):ifhglib.fromunicode(self.path)notinself._repo[self._rev]:self._contentview.setCurrentWidget(self._nullcontent)returnself._contentview.setCurrentWidget(self._fileview)self._fileview.setSource(self.path,self._rev)@pyqtSlot()def_emitPathChanged(self):self.pathChanged.emit(self.path)classManifestTaskWidget(ManifestWidget):"""Manifest widget designed for task tab"""def__init__(self,repo,rev,parent):super(ManifestTaskWidget,self).__init__(repo,rev,parent)self.editSelected.connect(self._openInEditor)@util.propertycachedef_searchbar(self):searchbar=qscilib.SearchToolBar(hidable=True)searchbar.hide()self.layout().addWidget(searchbar)connectsearchbar(self,searchbar)returnsearchbar@pyqtSlot(unicode,object,int)def_openInEditor(self,path,rev,line):"""Open editor to show the specified file"""_openineditor(self._repo,path,rev,line,pattern=self._searchbar.pattern(),parent=self)defconnectsearchbar(manifestwidget,searchbar):"""Connect searchbar to manifest widget"""searchbar.conditionChanged.connect(manifestwidget.highlightText)searchbar.searchRequested.connect(manifestwidget.find)manifestwidget.searchRequested.connect(searchbar.search)def_openineditor(repo,path,rev,line=None,pattern=None,parent=None):"""Open editor to show the specified file [unicode]"""path=hglib.fromunicode(path)pattern=hglib.fromunicode(pattern)base=visdiff.snapshot(repo,[path],repo[rev])[0]files=[os.path.join(base,path)]wctxactions.edit(parent,repo.ui,repo,files,line,pattern)defrun(ui,*pats,**opts):repo=opts.get('repo')orthgrepo.repository(ui,paths.find_root())dlg=ManifestDialog(repo,opts.get('rev'))# set initial state after dialog visibledefinit():try:path=hglib.canonpaths(pats)[0]line=opts.get('line')andint(opts['line'])orNonedlg.setSource(path,opts.get('rev'),line)exceptIndexError:passdlg.setSearchPattern(hglib.tounicode(opts.get('pattern'))or'')QTimer.singleShot(0,init)returndlg
Attach a Trello Card
Add a tag
Your session has expired
You are no longer logged in. Please log in and try your request again.
Filter RSS Feed
This RSS feed URL allows you to see the contents of your current filter using any feed reader.
This link includes a special authentication token. If you share the URL with anyone else, they can see this RSS feed's activity. You can disable these tokens when needed.
Your current filter is unsaved; changing it won't affect this RSS feed.