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.
# settings.py - Configuration dialog for TortoiseHg and Mercurial## Copyright 2010 Steve Borho <steve@borho.org>## This software may be used and distributed according to the terms of the# GNU General Public License version 2, incorporated herein by reference.import os
-from mercurial import ui, util, error
+from mercurial import ui, util, error, extensionsfrom tortoisehg.util import hglib, settings, paths, wconfig, i18n, bugtraq
from tortoisehg.hgqt.i18n import _
fromtortoisehg.hgqtimportqtlib,qscilib,thgrepofromPyQt4.QtCoreimport*fromPyQt4.QtGuiimport*# Technical Debt# stacked widget or pages need to be scrollable# we need a consistent icon set# connect to thgrepo.configChanged signal and refresh_unspecstr = _('<unspecified>')
ENTRY_WIDTH = 300
+def hasExtension(extname):+ for name, module in extensions.extensions():+ if name == extname:+ return True+ return False+class SettingsCombo(QComboBox):
def __init__(self, parent=None, **opts):
QComboBox.__init__(self, parent, toolTip=opts['tooltip'])
self.opts=optsself.setEditable(opts.get('canedit',False))self.setValidator(opts.get('validator',None))self.defaults=opts.get('defaults',[])ifself.defaultsandself.isEditable():self.setCompleter(QCompleter(self.defaults,self))self.curvalue=Noneself.loaded=Falseif'nohist'inopts:self.previous=[]else:settings=opts['settings']slist=settings.value('settings/'+opts['cpath']).toStringList()self.previous=[sforsinslistifs]self.setMinimumWidth(ENTRY_WIDTH)defresetList(self):self.clear()ucur=hglib.tounicode(self.curvalue)ifself.opts.get('defer')andnotself.loaded:ifself.curvalue==None:# unspecifiedself.addItem(_unspecstr)else:self.addItem(ucuror'...')returnself.addItem(_unspecstr)curindex=Noneforsinself.defaults:ifucur==s:curindex=self.count()self.addItem(s)ifself.defaultsandself.previous:self.insertSeparator(len(self.defaults)+1)forminself.previous:ifucur==mandnotcurindex:curindex=self.count()self.addItem(m)ifcurindexisnotNone:self.setCurrentIndex(curindex)elifself.curvalueisNone:self.setCurrentIndex(0)elifself.curvalue:self.addItem(ucur)self.setCurrentIndex(self.count()-1)else:# empty stringself.setEditText(ucur)defshowPopup(self):ifself.opts.get('defer')andnotself.loaded:self.defaults=self.opts['defer']()self.loaded=Trueself.resetList()QComboBox.showPopup(self)## common APIs for all edit widgetsdefsetValue(self,curvalue):self.curvalue=curvalueself.resetList()defvalue(self):utext=self.currentText()ifutext==_unspecstr:returnNoneif'nohist'inself.optsorutextinself.defaults+self.previousornotutext:returnhglib.fromunicode(utext)self.previous.insert(0,utext)self.previous=self.previous[:10]settings=QSettings()settings.setValue('settings/'+self.opts['cpath'],self.previous)returnhglib.fromunicode(utext)defisDirty(self):returnself.value()!=self.curvalueclassPasswordEntry(QLineEdit):def__init__(self,parent=None,**opts):QLineEdit.__init__(self,parent,toolTip=opts['tooltip'])self.opts=optsself.curvalue=Noneself.setEchoMode(QLineEdit.Password)self.setMinimumWidth(ENTRY_WIDTH)## common APIs for all edit widgetsdefsetValue(self,curvalue):self.curvalue=curvalueifcurvalue:self.setText(hglib.tounicode(curvalue))else:self.setText('')defvalue(self):utext=self.text()returnutextandhglib.fromunicode(utext)orNonedefisDirty(self):returnself.value()!=self.curvalueclassFontEntry(QPushButton):def__init__(self,parent=None,**opts):QPushButton.__init__(self,parent,toolTip=opts['tooltip'])self.opts=optsself.curvalue=Noneself.clicked.connect(self.on_clicked)cpath=self.opts['cpath']assertcpath.startswith('tortoisehg.')self.fname=cpath[11:]self.setMinimumWidth(ENTRY_WIDTH)defon_clicked(self,checked):defnewFont(font):self.setText(font.toString())thgf.setFont(font)thgf=qtlib.getfont(self.fname)origfont=self.currentFont()orthgf.font()dlg=QFontDialog(self)dlg.currentFontChanged.connect(newFont)font,isok=dlg.getFont(origfont,self)self.setText(font.toString())thgf.setFont(font)defcurrentFont(self):"""currently selected QFont if specified"""ifnotself.value():returnNonef=QFont()f.fromString(self.value())returnf## common APIs for all edit widgetsdefsetValue(self,curvalue):self.curvalue=curvalueifcurvalue:self.setText(hglib.tounicode(curvalue))else:self.setText(_unspecstr)defvalue(self):utext=self.text()ifutext==_unspecstr:returnNoneelse:returnhglib.fromunicode(utext)defisDirty(self):returnself.value()!=self.curvalueclassSettingsCheckBox(QCheckBox):def__init__(self,parent=None,**opts):QCheckBox.__init__(self,parent,toolTip=opts['tooltip'])self.opts=optsself.curvalue=Noneself.setText(opts['label'])self.valfunc=self.opts['valfunc']self.toggled.connect(self.valfunc)defsetValue(self,curvalue):ifself.curvalue==None:self.curvalue=curvalueself.setChecked(curvalue)defvalue(self):returnself.isChecked()defisDirty(self):returnself.value()!=self.curvalueclassBugTraqConfigureEntry(QPushButton):def__init__(self,parent=None,**opts):QPushButton.__init__(self,parent,toolTip=opts['tooltip'])self.opts=optsself.curvalue=Noneself.options=Noneself.tracker=Noneself.master=Noneself.setText(opts['label'])self.clicked.connect(self.on_clicked)defon_clicked(self,checked):parameters=self.optionsself.options=self.tracker.show_options_dialog(parameters)defmaster_updated(self):self.setEnabled(False)ifself.master==None:returnifself.master.value()==None:returniflen(self.master.value())==0:returntry:setting=self.master.value().split(' ',1)trackerid=setting[0]name=setting[1]self.tracker=bugtraq.BugTraq(trackerid)except:# failed to load bugtraq module or parse the setting:# swallow the error and leave the widget disabledreturntry:self.setEnabled(self.tracker.has_options())exceptException,e:qtlib.ErrorMsgBox(_('Issue Tracker'),_('Failed to load issue tracker: \'%s\': %s. '%(name,e)),parent=self)## common APIs for all edit widgetsdefsetValue(self,curvalue):ifself.master==None:self.master=self.opts['master']self.master.currentIndexChanged.connect(self.master_updated)self.master_updated()self.curvalue=curvalueself.options=curvaluedefvalue(self):returnself.optionsdefisDirty(self):returnself.value()!=self.curvaluedefgenEditCombo(opts,defaults=[]):opts['canedit']=Trueopts['defaults']=defaultsreturnSettingsCombo(**opts)defgenIntEditCombo(opts):'EditCombo, only allows integer values'opts['canedit']=Trueopts['validator']=QIntValidator()returnSettingsCombo(**opts)defgenPasswordEntry(opts):'Generate a password entry box'returnPasswordEntry(**opts)defgenDefaultCombo(opts,defaults=[]):'user must select from a list'opts['defaults']=defaultsopts['nohist']=TruereturnSettingsCombo(**opts)defgenBoolCombo(opts):'true, false, unspecified'opts['defaults']=['True','False']opts['nohist']=TruereturnSettingsCombo(**opts)defgenDeferredCombo(opts,func):'Values retrieved from a function at popup time'opts['defer']=funcopts['nohist']=TruereturnSettingsCombo(**opts)defgenFontEdit(opts):returnFontEntry(**opts)defgenBugTraqEdit(opts):returnBugTraqConfigureEntry(**opts)deffindIssueTrackerPlugins():plugins=bugtraq.get_issue_plugins_with_names()names=[("%s%s"%(key[0],key[1]))forkeyinplugins]returnnamesdefissuePluginVisible():try:# quick test to see if we're able to load the bugtraq moduletest=bugtraq.BugTraq('')returnTrueexcept:returnFalsedeffindDiffTools():returnhglib.difftools(ui.ui())deffindMergeTools():returnhglib.mergetools(ui.ui())defgenCheckBox(opts):opts['nohist']=TruereturnSettingsCheckBox(**opts)class_fi(object):"""Information of each field"""__slots__=('label','cpath','values','tooltip','restartneeded','globalonly','master','visible')def__init__(self,label,cpath,values,tooltip,restartneeded=False,globalonly=False,master=None,visible=None):self.label=labelself.cpath=cpathself.values=valuesself.tooltip=tooltipself.restartneeded=restartneededself.globalonly=globalonlyself.master=masterself.visible=visibledefisVisible(self):ifself.visible==None:returnTrueelse:returnself.visible()INFO=(({'name':'general','label':'TortoiseHg','icon':'thg_logo'},(_fi(_('UI Language'),'tortoisehg.ui.language',(genDeferredCombo,i18n.availablelanguages),_('Specify your preferred user interface language (restart needed)'),restartneeded=True,globalonly=True),_fi(_('Three-way Merge Tool'),'ui.merge',(genDeferredCombo,findMergeTools),_('Graphical merge program for resolving merge conflicts. If left ''unspecified, Mercurial will use the first applicable tool it finds ''on your system or use its internal merge tool that leaves conflict ''markers in place. Chose internal:merge to force conflict markers ,''internal:prompt to always select local or other, or internal:dump ''to leave files in the working directory for manual merging')),_fi(_('Visual Diff Tool'),'tortoisehg.vdiff',(genDeferredCombo,findDiffTools),_('Specify visual diff tool, as described in the [merge-tools] ''section of your Mercurial configuration files. If left ''unspecified, TortoiseHg will use the selected merge tool. ''Failing that it uses the first applicable tool it finds.')),_fi(_('Visual Editor'),'tortoisehg.editor',genEditCombo,_('Specify the visual editor used to view files. Format:<br>''myeditor -flags [$FILE --num=$LINENUM][--search $SEARCH]<br><br>''See <a href="%s">OpenAtLine</a>'%'http://bitbucket.org/tortoisehg/thg/wiki/OpenAtLine')),_fi(_('Shell'),'tortoisehg.shell',genEditCombo,_('Specify the command to launch your preferred terminal shell ''application. If the value includes the string %(reponame)s, the ''name of the repository will be substituted in place of ''%(reponame)s. (restart needed)<br>''Default, Windows: cmd.exe /K title %(reponame)s<br>''Default, OS X: not set<br>''Default, other: xterm -T "%(reponame)s"'),globalonly=True),_fi(_('Immediate Operations'),'tortoisehg.immediate',genEditCombo,_('Space separated list of shell operations you would like ''to be performed immediately, without user interaction. ''Commands are "add remove revert forget". ''Default: None (leave blank)')),_fi(_('Tab Width'),'tortoisehg.tabwidth',genIntEditCombo,_('Specify the number of spaces that tabs expand to in various ''TortoiseHg windows. ''Default: 0, Not expanded')),_fi(_('Force Repo Tab'),'tortoisehg.forcerepotab',genBoolCombo,_('Always show repo tabs, even for a single repo. Default: False')),_fi(_('Max Diff Size'),'tortoisehg.maxdiff',genIntEditCombo,_('The maximum size file (in KB) that TortoiseHg will ''show changes for in the changelog, status, and commit windows. ''A value of zero implies no limit. Default: 1024 (1MB)')),_fi(_('Fork GUI'),'tortoisehg.guifork',genBoolCombo,_('When running from the command line, fork a background ''process to run graphical dialogs. Default: True')),_fi(_('Full Path Title'),'tortoisehg.fullpath',genBoolCombo,_('Show a full directory path of the repository in the dialog title ''instead of just the root directory name. Default: False')),_fi(_('Auto-resolve merges'),'tortoisehg.autoresolve',genBoolCombo,_('Indicates whether TortoiseHg should attempt to automatically ''resolve changes from both sides to the same file, and only report ''merge conflicts when this is not possible. When False, all files ''with changes on both sides of the merge will report as conflicting, ''even if the edits are to different parts of the file. In either ''case, when conflicts occur, the user will be invited to review and ''resolve changes manually. Default: False.')),)),({'name':'log','label':_('Workbench'),'icon':'menulog'},(_fi(_('Default widget'),'tortoisehg.defaultwidget',(genDefaultCombo,['revdetails','commit','mq','sync','manifest','search']),_('Select the initial widget that will be shown when opening a ''repository. ''Default: revdetails')),_fi(_('Initial revision'),'tortoisehg.initialrevision',(genDefaultCombo,['current','tip','workingdir']),_('Select the initial revision that will be selected when opening a ''repository. You can select the "current" (i.e. the working directory ''parent), the current "tip" or the working directory ("workingdir"). ''Default: current')),_fi(_('Author Coloring'),'tortoisehg.authorcolor',genBoolCombo,_('Color changesets by author name. If not enabled, ''the changes are colored green for merge, red for ''non-trivial parents, black for normal. ''Default: False')),_fi(_('Task Tabs'),'tortoisehg.tasktabs',(genDefaultCombo,['east','west','off']),_('Show tabs along the side of the bottom half of each repo ''widget allowing one to switch task tabs without using the toolbar. ''Default: off')),_fi(_('Long Summary'),'tortoisehg.longsummary',genBoolCombo,_('If true, concatenate multiple lines of changeset summary ''until they reach 80 characters. ''Default: False')),_fi(_('Log Batch Size'),'tortoisehg.graphlimit',genIntEditCombo,_('The number of revisions to read and display in the ''changelog viewer in a single batch. ''Default: 500')),_fi(_('Dead Branches'),'tortoisehg.deadbranch',genEditCombo,_('Comma separated list of branch names that should be ignored ''when building a list of branch names for a repository. ''Default: None (leave blank)')),_fi(_('Branch Colors'),'tortoisehg.branchcolors',genEditCombo,_('Space separated list of branch names and colors of the form ''branch:#XXXXXX. Spaces and colons in the branch name must be ''escaped using a backslash (\\). Likewise some other characters ''can be escaped in this way, e.g. \\u0040 will be decoded to the ''@ character, and \\n to a linefeed. ''Default: None (leave blank)')),_fi(_('Hide Tags'),'tortoisehg.hidetags',genEditCombo,_('Space separated list of tags that will not be shown.''Useful example: Specify "qbase qparent qtip" to hide the ''standard tags inserted by the Mercurial Queues Extension. ''Default: None (leave blank)')),_fi(_('After Pull Operation'),'tortoisehg.postpull',(genDefaultCombo,['none','update','fetch','rebase']),_('Operation which is performed directly after a successful pull. ''update equates to pull --update, fetch equates to the fetch ''extension, rebase equates to pull --rebase. Default: none')),)),({'name':'commit','label':_('Commit','config item'),'icon':'menucommit'},(_fi(_('Username'),'ui.username',genEditCombo,_('Name associated with commits. The common format is:<br>''Full Name <email@example.com>')),_fi(_('Summary Line Length'),'tortoisehg.summarylen',genIntEditCombo,_('Suggested length of commit message lines. A red vertical ''line will mark this length. CTRL-E will reflow the current ''paragraph to the specified line length. Default: 80')),_fi(_('Close After Commit'),'tortoisehg.closeci',genBoolCombo,_('Close the commit tool after every successful ''commit. Default: False')),_fi(_('Push After Commit'),'tortoisehg.cipushafter',(genEditCombo,['default-push','default']),_('Attempt to push to specified URL or alias after each successful ''commit. Default: No push')),_fi(_('Auto Commit List'),'tortoisehg.autoinc',genEditCombo,_('Comma separated list of files that are automatically included ''in every commit. Intended for use only as a repository setting. ''Default: None (leave blank)')),_fi(_('Auto Exclude List'),'tortoisehg.ciexclude',genEditCombo,_('Comma separated list of files that are automatically unchecked ''when the status, and commit dialogs are opened. ''Default: None (leave blank)')),_fi(_('English Messages'),'tortoisehg.engmsg',genBoolCombo,_('Generate English commit messages even if LANGUAGE or LANG ''environment variables are set to a non-English language. ''This setting is used by the Merge, Tag and Backout dialogs. ''Default: False')),)),({'name':'web','label':_('Web Server'),'icon':'proxy'},(_fi(_('Name'),'web.name',genEditCombo,_('Repository name to use in the web interface, and by TortoiseHg ''as a shorthand name. Default is the working directory.')),_fi(_('Description'),'web.description',genEditCombo,_("Textual description of the repository's purpose or "'contents.')),_fi(_('Contact'),'web.contact',genEditCombo,_('Name or email address of the person in charge of the ''repository.')),_fi(_('Style'),'web.style',(genDefaultCombo,['paper','monoblue','coal','spartan','gitweb','old']),_('Which template map style to use')),_fi(_('Archive Formats'),'web.allow_archive',(genEditCombo,['bz2','gz','zip']),_('Comma separated list of archive formats allowed for ''downloading')),_fi(_('Port'),'web.port',genIntEditCombo,_('Port to listen on')),_fi(_('Push Requires SSL'),'web.push_ssl',genBoolCombo,_('Whether to require that inbound pushes be transported ''over SSL to prevent password sniffing.')),_fi(_('Stripes'),'web.stripes',genIntEditCombo,_('How many lines a "zebra stripe" should span in multiline output. ''Default is 1; set to 0 to disable.')),_fi(_('Max Files'),'web.maxfiles',genIntEditCombo,_('Maximum number of files to list per changeset. Default: 10')),_fi(_('Max Changes'),'web.maxchanges',genIntEditCombo,_('Maximum number of changes to list on the changelog. ''Default: 10')),_fi(_('Allow Push'),'web.allow_push',(genEditCombo,['*']),_('Whether to allow pushing to the repository. If empty or not ''set, push is not allowed. If the special value "*", any remote ''user can push, including unauthenticated users. Otherwise, the ''remote user must have been authenticated, and the authenticated ''user name must be present in this list (separated by whitespace ''or ","). The contents of the allow_push list are examined after ''the deny_push list.')),_fi(_('Deny Push'),'web.deny_push',(genEditCombo,['*']),_('Whether to deny pushing to the repository. If empty or not set, ''push is not denied. If the special value "*", all remote users ''are denied push. Otherwise, unauthenticated users are all ''denied, and any authenticated user name present in this list ''(separated by whitespace or ",") is also denied. The contents ''of the deny_push list are examined before the allow_push list.')),_fi(_('Encoding'),'web.encoding',(genEditCombo,['UTF-8']),_('Character encoding name')),)),({'name':'proxy','label':_('Proxy'),'icon':QStyle.SP_DriveNetIcon},(_fi(_('Host'),'http_proxy.host',genEditCombo,_('Host name and (optional) port of proxy server, for ''example "myproxy:8000"')),_fi(_('Bypass List'),'http_proxy.no',genEditCombo,_('Optional. Comma-separated list of host names that ''should bypass the proxy')),_fi(_('User'),'http_proxy.user',genEditCombo,_('Optional. User name to authenticate with at the proxy server')),_fi(_('Password'),'http_proxy.passwd',genPasswordEntry,_('Optional. Password to authenticate with at the proxy server')),)),({'name':'email','label':_('Email'),'icon':'mail-forward'},(_fi(_('From'),'email.from',genEditCombo,_('Email address to use in the "From" header and for ''the SMTP envelope')),_fi(_('To'),'email.to',genEditCombo,_('Comma-separated list of recipient email addresses')),_fi(_('Cc'),'email.cc',genEditCombo,_('Comma-separated list of carbon copy recipient email addresses')),_fi(_('Bcc'),'email.bcc',genEditCombo,_('Comma-separated list of blind carbon copy recipient ''email addresses')),_fi(_('method'),'email.method',(genEditCombo,['smtp']),_('Optional. Method to use to send email messages. If value is ''"smtp" (default), use SMTP (configured below). Otherwise, use as ''name of program to run that acts like sendmail (takes "-f" option ''for sender, list of recipients on command line, message on stdin). ''Normally, setting this to "sendmail" or "/usr/sbin/sendmail" ''is enough to use sendmail to send messages.')),_fi(_('SMTP Host'),'smtp.host',genEditCombo,_('Host name of mail server')),_fi(_('SMTP Port'),'smtp.port',genIntEditCombo,_('Port to connect to on mail server. ''Default: 25')),_fi(_('SMTP TLS'),'smtp.tls',genBoolCombo,_('Connect to mail server using TLS. ''Default: False')),_fi(_('SMTP Username'),'smtp.username',genEditCombo,_('Username to authenticate to mail server with')),_fi(_('SMTP Password'),'smtp.password',genPasswordEntry,_('Password to authenticate to mail server with')),_fi(_('Local Hostname'),'smtp.local_hostname',genEditCombo,_('Hostname the sender can use to identify itself to the ''mail server.')),)),({'name':'diff','label':_('Diff'),'icon':QStyle.SP_FileDialogContentsView},(_fi(_('Patch EOL'),'patch.eol',(genDefaultCombo,['auto','strict','crlf','lf']),_('Normalize file line endings during and after patch to lf or ''crlf. Strict does no normalization. Auto does per-file ''detection, and is the recommended setting. ''Default: strict')),_fi(_('Git Format'),'diff.git',genBoolCombo,_('Use git extended diff header format. ''Default: False')),_fi(_('MQ Git Format'),'mq.git',(genDefaultCombo,['auto','keep','yes','no']),_("If set to 'keep', mq will obey the [diff] section configuration while"" preserving existing git patches upon qrefresh. If set to 'yes' or"" 'no', mq will override the [diff] section and always generate git or"" regular patches, possibly losing data in the second case.")),_fi(_('No Dates'),'diff.nodates',genBoolCombo,_('Do not include modification dates in diff headers. ''Default: False')),_fi(_('Show Function'),'diff.showfunc',genBoolCombo,_('Show which function each change is in. ''Default: False')),_fi(_('Ignore White Space'),'diff.ignorews',genBoolCombo,_('Ignore white space when comparing lines. ''Default: False')),_fi(_('Ignore WS Amount'),'diff.ignorewsamount',genBoolCombo,_('Ignore changes in the amount of white space. ''Default: False')),_fi(_('Ignore Blank Lines'),'diff.ignoreblanklines',genBoolCombo,_('Ignore changes whose lines are all blank. ''Default: False')),)),({'name':'fonts','label':_('Fonts'),'icon':'preferences-desktop-font'},(_fi(_('Message Font'),'tortoisehg.fontcomment',genFontEdit,_('Font used to display commit messages. Default: monospace 10'),globalonly=True),_fi(_('Diff Font'),'tortoisehg.fontdiff',genFontEdit,_('Font used to display text differences. Default: monospace 10'),globalonly=True),_fi(_('List Font'),'tortoisehg.fontlist',genFontEdit,_('Font used to display file lists. Default: sans 9'),globalonly=True),_fi(_('ChangeLog Font'),'tortoisehg.fontlog',genFontEdit,_('Font used to display changelog data. Default: monospace 10'),globalonly=True),_fi(_('Output Font'),'tortoisehg.fontoutputlog',genFontEdit,_('Font used to display output messages. Default: sans 8'),globalonly=True),)),({'name':'extensions','label':_('Extensions'),'icon':'hg-extensions'},()),({'name':'issue','label':_('Issue Tracking'),'icon':'edit-file'},(_fi(_('Issue Regex'),'tortoisehg.issue.regex',genEditCombo,_('Defines the regex to match when picking up issue numbers.')),_fi(_('Issue Link'),'tortoisehg.issue.link',genEditCombo,_('Defines the command to run when an issue number is recognized. ''You may include groups in issue.regex, and corresponding {n} ''tokens in issue.link (where n is a non-negative integer). ''{0} refers to the entire string matched by issue.regex, ''while {1} refers to the first group and so on. If no {n} tokens''are found in issue.link, the entire matched string is appended ''instead.')),_fi(_('Issue Tracker Plugin'),'tortoisehg.issue.bugtraqplugin',(genDeferredCombo,findIssueTrackerPlugins),_('Configures a COM IBugTraqProvider or IBugTrackProvider2 issue ''tracking plugin.'),visible=issuePluginVisible),_fi(_('Configure Issue Tracker'),'tortoisehg.issue.bugtraqparameters',genBugTraqEdit,_('Configure the selected COM Bug Tracker plugin.'),master='tortoisehg.issue.bugtraqplugin',visible=issuePluginVisible),)),({'name':'reviewboard','label':_('Review Board'),'icon':'reviewboard'},(_fi(_('Server'),'reviewboard.server',genEditCombo,_('Path to review board ''example "http://demo.reviewboard.org"')),_fi(_('User'),'reviewboard.user',genEditCombo,_('User name to authenticate with review board')),_fi(_('Password'),'reviewboard.password',genPasswordEntry,_('Password to authenticate with review board')),_fi(_('Server Repository ID'),'reviewboard.repoid',genEditCombo,_('The default repository id for this repo on the review board server')),_fi(_('Target Groups'),'reviewboard.target_groups',genEditCombo,_('A comma separated list of target groups')), _fi(_('Target People'), 'reviewboard.target_people', genEditCombo,
_('A comma separated list of target people')),
)),
++({'name': 'kbfiles', 'label': _('Kiln Bfiles'), 'icon': 'kiln', 'extension': 'kbfiles'}, (+ _fi(_('Patterns'), 'kilnbfiles.patterns', genEditCombo,+ _('Files with names meeting the specified patterns will be automatically '+ 'added as bfiles')),+ _fi(_('Size'), 'kilnbfiles.size', genEditCombo,+ _('Files of at least the specified size (in megabytes) will be added as bfiles')),+ _fi(_('System Cache'), 'kilnbfiles.systemcache', genEditCombo,+ _('Path to the directory where a system-wide cache of bfiles will be stored')),+ )),)
CONF_GLOBAL=0CONF_REPO=1classSettingsDialog(QDialog):'Dialog for editing Mercurial.ini or hgrc'def__init__(self,configrepo=False,focus=None,parent=None,root=None):QDialog.__init__(self,parent)self.setWindowTitle(_('TortoiseHg Settings'))self.setWindowFlags(self.windowFlags()&~Qt.WindowContextHelpButtonHint)self.setWindowIcon(qtlib.geticon('settings_repo'))ifnothasattr(wconfig.config(),'write'):qtlib.ErrorMsgBox(_('Iniparse package not found'),_("Can't change settings without iniparse package - "'view is readonly.'),parent=self)print'Please install http://code.google.com/p/iniparse/'layout=QVBoxLayout()self.setLayout(layout)s=QSettings()self.settings=sself.restoreGeometry(s.value('settings/geom').toByteArray())defusername():name=util.username()ifname:returnhglib.tounicode(name)name=os.environ.get('USERNAME')ifname:returnhglib.tounicode(name)return_('User')self.conftabs=QTabWidget()layout.addWidget(self.conftabs)utab=SettingsForm(rcpath=hglib.user_rcpath(),focus=focus)self.conftabs.addTab(utab,qtlib.geticon('settings_user'),_("%s's global settings")%username())utab.restartRequested.connect(self._pushRestartRequest)try:ifrootisNone:root=paths.find_root()ifroot:repo=thgrepo.repository(ui.ui(),root)else:repo=Noneexcepterror.RepoError:repo=Noneifconfigrepo:uroot=hglib.tounicode(root)qtlib.ErrorMsgBox(_('No repository found'),_('no repo at ')+uroot,parent=self)ifrepo:reporcpath=os.sep.join([repo.root,'.hg','hgrc'])rtab=SettingsForm(rcpath=reporcpath,focus=focus)self.conftabs.addTab(rtab,qtlib.geticon('settings_repo'),_('%s repository settings')%repo.displayname)rtab.restartRequested.connect(self._pushRestartRequest)BB=QDialogButtonBoxbb=QDialogButtonBox(BB.Ok|BB.Cancel)bb.accepted.connect(self.accept)bb.rejected.connect(self.reject)layout.addWidget(bb)self.bb=bbself._restartreqs=set()self.conftabs.setCurrentIndex(configrepoandCONF_REPOorCONF_GLOBAL)defisDirty(self):returnutil.any(self.conftabs.widget(i).isDirty()foriinxrange(self.conftabs.count()))@pyqtSlot(unicode)def_pushRestartRequest(self,key):self._restartreqs.add(unicode(key))defapplyChanges(self):foriinxrange(self.conftabs.count()):self.conftabs.widget(i).applyChanges()ifself._restartreqs:qtlib.InfoMsgBox(_('Settings'),_('Restart all TortoiseHg applications ''for the following changes to take effect:'),', '.join(sorted(self._restartreqs)))self._restartreqs.clear()defcanExit(self):ifself.isDirty():ret=qtlib.CustomPrompt(_('Confirm Exit'),_('Apply changes before exit?'),self,(_('&Yes'),_('&No (discard changes)'),_('Cancel')),default=2,esc=2).run()ifret==2:returnFalseelifret==0:self.applyChanges()returnTruereturnTruedefaccept(self):self.applyChanges()s=self.settingss.setValue('settings/geom',self.saveGeometry())s.sync()QDialog.accept(self)defreject(self):ifnotself.canExit():returns=self.settingss.setValue('settings/geom',self.saveGeometry())s.sync()QDialog.reject(self)classSettingsForm(QWidget):"""Widget for each settings file"""restartRequested=pyqtSignal(unicode)def__init__(self,rcpath,focus=None,parent=None):super(SettingsForm,self).__init__(parent)ifisinstance(rcpath,(list,tuple)):self.rcpath=rcpathelse:self.rcpath=[rcpath]layout=QVBoxLayout()self.setLayout(layout)tophbox=QHBoxLayout()layout.addLayout(tophbox)self.fnedit=QLineEdit()self.fnedit.setReadOnly(True)self.fnedit.setFrame(False)self.fnedit.setFocusPolicy(Qt.NoFocus)self.fnedit.setStyleSheet('QLineEdit { background: transparent; }')edit=QPushButton(_('Edit File'))edit.clicked.connect(self.editClicked)self.editbtn=editreload=QPushButton(_('Reload'))reload.clicked.connect(self.reloadClicked)self.reloadbtn=reloadtophbox.addWidget(QLabel(_('Settings File:')))tophbox.addWidget(self.fnedit)tophbox.addWidget(edit)tophbox.addWidget(reload)bothbox=QHBoxLayout()layout.addLayout(bothbox,stretch=8)pageList=QListWidget()pageList.setResizeMode(QListView.Fixed)stack=QStackedWidget()bothbox.addWidget(pageList,0)bothbox.addWidget(stack,1)pageList.currentRowChanged.connect(self.activatePage)self.pages={}self.stack=stackself.pageList=pageListdesctext=QTextBrowser()desctext.setOpenExternalLinks(True)layout.addWidget(desctext,stretch=2)self.desctext=desctextself.settings=QSettings() # add page items to treeview
for meta, info in INFO:
+ if 'extension' in meta and not hasExtension(meta['extension']):+ continue if isinstance(meta['icon'], str):
icon = qtlib.geticon(meta['icon'])
else:
style=QApplication.style()icon=QIcon()icon.addPixmap(style.standardPixmap(meta['icon']))item=QListWidgetItem(icon,meta['label'])pageList.addItem(item)self.refresh()self.focusField(focusor'ui.merge')defactivatePage(self,index):item=self.pageList.currentItem()fordatainINFO:ifitem.text()==data[0]['label']:meta,info=databreakpagename=meta['name']ifself.pages.has_key(pagename):page=self.pages[pagename]else:page=self.createPage(pagename,info)self.refreshPage(page)frame=page[2][0].parentWidget()self.stack.setCurrentWidget(frame)defeditClicked(self):'Open internal editor in stacked widget'ifself.isDirty():ret=qtlib.CustomPrompt(_('Confirm Save'),_('Save changes before editing?'),self,(_('&Save'),_('&Discard'),_('Cancel')),default=2,esc=2).run()ifret==0:self.applyChanges()elifret==2:returnifqscilib.fileEditor(self.fn,foldable=True)==QDialog.Accepted:self.refresh()defrefresh(self,*args):# refresh config valuesself.ini=self.loadIniFile(self.rcpath)self.readonly=not(hasattr(self.ini,'write')andos.access(self.fn,os.W_OK))self.stack.setDisabled(self.readonly)self.fnedit.setText(hglib.tounicode(self.fn))forpageinself.pages.values():self.refreshPage(page)defrefreshPage(self,page):name,info,widgets=pageifname=='extensions':extsmentioned=Falseforrow,winenumerate(widgets):key=w.opts['label']forfullkeyin(key,'hgext.%s'%key,'hgext/%s'%key):val=self.readCPath('extensions.'+fullkey)ifval!=None:breakifval==None:curvalue=Falseeliflen(val)andval[0]=='!':curvalue=Falseextsmentioned=Trueelse:curvalue=Trueextsmentioned=Truew.setValue(curvalue)ifval==None:w.opts['cpath']='extensions.'+keyelse:w.opts['cpath']='extensions.'+fullkeyifnotextsmentioned:# make sure widgets are shown properly,# even when no extensions mentioned in the config fileself.validateextensions()else:forrow,einenumerate(info):curvalue=self.readCPath(e.cpath)widgets[row].setValue(curvalue)defisDirty(self):ifself.readonly:returnFalseforname,info,widgetsinself.pages.values():forwinwidgets:ifw.isDirty():returnTruereturnFalsedefreloadClicked(self):ifself.isDirty():d=QMessageBox.question(self,_('Confirm Reload'),_('Unsaved changes will be lost.\n''Do you want to reload?'),QMessageBox.Ok|QMessageBox.Cancel)ifd!=QMessageBox.Ok:returnself.refresh()deffocusField(self,focusfield):'Set page and focus to requested datum'fori,(meta,info)inenumerate(INFO):forn,einenumerate(info):ife.cpath==focusfield:self.pageList.setCurrentRow(i)QTimer.singleShot(0,lambda:self.pages[meta['name']][2][n].setFocus())returndeffillFrame(self,info):widgets=[]frame=QFrame()form=QFormLayout()frame.setLayout(form)self.stack.addWidget(frame)foreininfo:opts={'label':e.label,'cpath':e.cpath,'tooltip':e.tooltip,'master':e.master,'settings':self.settings}ifisinstance(e.values,tuple):func=e.values[0]w=func(opts,e.values[1])else:func=e.valuesw=func(opts)w.installEventFilter(self)ife.globalonly:w.setEnabled(self.rcpath==hglib.user_rcpath())lbl=QLabel(e.label)lbl.installEventFilter(self)lbl.setToolTip(e.tooltip)widgets.append(w)ife.isVisible():form.addRow(lbl,w)# assign the master to widgets that have a masterforwinwidgets:ifw.opts['master']!=None:fordepinwidgets:ifdep.opts['cpath']==w.opts['master']:w.opts['master']=depreturnwidgetsdeffillExtensionsFrame(self):widgets=[]frame=QFrame()grid=QGridLayout()frame.setLayout(grid)self.stack.addWidget(frame)allexts=hglib.allextensions()allextslist=list(allexts)MAXCOLUMNS=3maxrows=(len(allextslist)+MAXCOLUMNS-1)/MAXCOLUMNSi=0extsinfo=()fori,nameinenumerate(sorted(allexts)):tt=hglib.tounicode(allexts[name])opts={'label':name,'cpath':'extensions.'+name,'tooltip':tt,'valfunc':self.validateextensions}w=genCheckBox(opts)w.installEventFilter(self)row,col=i/maxrows,i%maxrowsgrid.addWidget(w,col,row)widgets.append(w)returnextsinfo,widgetsdefeventFilter(self,obj,event):ifevent.type()in(QEvent.Enter,QEvent.FocusIn):self.desctext.setHtml(obj.toolTip())ifevent.type()==QEvent.ToolTip:returnTrue# tooltip is shown in self.desctextreturnFalsedefcreatePage(self,name,info):ifname=='extensions':extsinfo,widgets=self.fillExtensionsFrame()self.pages[name]=name,extsinfo,widgetselse:widgets=self.fillFrame(info)self.pages[name]=name,info,widgetsreturnself.pages[name]defreadCPath(self,cpath):'Retrieve a value from the parsed config file'# Presumes single section/key level depthsection,key=cpath.split('.',1)returnself.ini.get(section,key)defloadIniFile(self,rcpath):forfninrcpath:ifos.path.exists(fn):breakelse:forfninrcpath:# Try to create a file from rcpathtry:f=open(fn,'w')f.write('# Generated by TortoiseHg settings dialog\n')f.close()breakexcept(IOError,OSError):passelse:qtlib.WarningMsgBox(_('Unable to create a Mercurial.ini file'),_('Insufficient access rights, reverting to read-only ''mode.'),parent=self)frommercurialimportconfigself.fn=rcpath[0]returnconfig.config()self.fn=fnreturnwconfig.readfile(self.fn)defrecordNewValue(self,cpath,newvalue):"""Set the given value to ini; returns True if changed"""# 'newvalue' is in local encodingsection,key=cpath.split('.',1)ifnewvalue==self.ini.get(section,key):returnFalseifnewvalue==None:try:delself.ini[section][key]exceptKeyError:passelse:self.ini.set(section,key,newvalue)returnTruedefapplyChanges(self):ifself.readonly:returnforname,info,widgetsinself.pages.values():ifname=='extensions':self.applyChangesForExtensions()else:forrow,einenumerate(info):newvalue=widgets[row].value()changed=self.recordNewValue(e.cpath,newvalue)ifchangedande.restartneeded:self.restartRequested.emit(e.label)try:wconfig.writefile(self.ini,self.fn)exceptIOError,e:qtlib.WarningMsgBox(_('Unable to write configuration file'),str(e),parent=self)defapplyChangesForExtensions(self):emitChanged=Falsesection='extensions'enabledexts=hglib.enabledextensions()forchkinself.pages['extensions'][2]:if(notemitChanged)andchk.isDirty():self.restartRequested.emit(_('Extensions'))emitChanged=Truename=chk.opts['label']section,key=chk.opts['cpath'].split('.',1)newvalue=chk.value()ifnewvalueand(nameinenabledexts):continue# unchangedifnewvalue:self.ini.set(section,key,'')else:try:delself.ini[section][key]exceptKeyError:pass@pyqtSlot()defvalidateextensions(self):section='extensions'enabledexts=hglib.enabledextensions()selectedexts=set(chk.opts['label']forchkinself.pages['extensions'][2]ifchk.isChecked())invalidexts=hglib.validateextensions(selectedexts)defgetinival(cpath):ifsectionnotinself.ini:returnNonesect,key=cpath.split('.',1)try:returnself.ini[sect][key]exceptKeyError:passdefchangable(name,cpath):curval=getinival(cpath)ifcurvalnotin('',None):# enabled or unspecified, official extensions onlyreturnFalseelifnameinenabledextsandcurvalisNone:# re-disabling ext is not supportedreturnFalseelifnameininvalidextsandnamenotinselectedexts:# disallow to enable bad exts, but allow to disable itreturnFalseelse:returnTrueallexts=hglib.allextensions()forchkinself.pages['extensions'][2]:name=chk.opts['label']chk.setEnabled(changable(name,chk.opts['cpath']))invalmsg=invalidexts.get(name)ifinvalmsg:invalmsg=invalmsg.decode('utf-8')chk.setToolTip(invalmsgorhglib.tounicode(allexts[name]))defrun(ui,*pats,**opts):returnSettingsDialog(opts.get('alias')=='repoconfig',focus=opts.get('focus'))
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.