~ubuntu-branches/debian/sid/tortoisehg/sid

« back to all changes in this revision

Viewing changes to tortoisehg/hgqt/settings.py

  • Committer: Package Import Robot
  • Author(s): Ludovico Cavedon
  • Date: 2012-05-29 00:59:17 UTC
  • mfrom: (1.2.9)
  • Revision ID: package-import@ubuntu.com-20120529005917-ae1mdohuiimxxkc0
Tags: 2.4-1
* Imported Upstream version 2.4 (Closes: #671473).
* Re-add Nautilus extension (LP: #990527).
* Update Standards-Version to 3.9.3.
* Update copyright format.

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
 
8
8
import os
9
9
 
10
 
from mercurial import ui, util, error, extensions
 
10
from mercurial import ui, util, error, extensions, scmutil
11
11
 
12
12
from tortoisehg.util import hglib, settings, paths, wconfig, i18n, bugtraq
13
13
from tortoisehg.hgqt.i18n import _
151
151
    def isDirty(self):
152
152
        return self.value() != self.curvalue
153
153
 
154
 
class PasswordEntry(QLineEdit):
 
154
class LineEditBox(QLineEdit):
155
155
    def __init__(self, parent=None, **opts):
156
156
        QLineEdit.__init__(self, parent, toolTip=opts['tooltip'])
157
157
        self.opts = opts
158
158
        self.curvalue = None
159
 
        self.setEchoMode(QLineEdit.Password)
160
159
        self.setMinimumWidth(ENTRY_WIDTH)
161
160
 
162
161
    ## common APIs for all edit widgets
174
173
    def isDirty(self):
175
174
        return self.value() != self.curvalue
176
175
 
 
176
class PasswordEntry(LineEditBox):
 
177
    def __init__(self, parent=None, **opts):
 
178
        QLineEdit.__init__(self, parent, toolTip=opts['tooltip'])
 
179
        self.opts = opts
 
180
        self.curvalue = None
 
181
        self.setEchoMode(QLineEdit.Password)
 
182
        self.setMinimumWidth(ENTRY_WIDTH)
 
183
class TextEntry(QTextEdit):
 
184
    def __init__(self, parent=None, **opts):
 
185
        QTextEdit.__init__(self, parent, toolTip=opts['tooltip'])
 
186
        self.opts = opts
 
187
        self.curvalue = None
 
188
        self.setMinimumWidth(ENTRY_WIDTH)
 
189
 
 
190
    ## common APIs for all edit widgets
 
191
    def setValue(self, curvalue):
 
192
        self.curvalue = curvalue
 
193
        if curvalue:
 
194
            self.setPlainText(hglib.tounicode(curvalue))
 
195
        else:
 
196
            self.setPlainText('')
 
197
 
 
198
    def value(self):
 
199
        # It is not possible to set a multi-line value with an empty line
 
200
        utext = self.removeEmptyLines(self.toPlainText())
 
201
        return utext and hglib.fromunicode(utext) or None
 
202
 
 
203
    def isDirty(self):
 
204
        return self.value() != self.curvalue
 
205
 
 
206
    def removeEmptyLines(self, text):
 
207
        if not text:
 
208
            return text
 
209
        rawlines = hglib.fromunicode(text).splitlines()
 
210
        lines = []
 
211
        for line in rawlines:
 
212
            if not line.strip():
 
213
                continue
 
214
            lines.append(line)
 
215
        return os.linesep.join(lines)
 
216
 
 
217
 
177
218
class FontEntry(QWidget):
178
219
    def __init__(self, parent=None, **opts):
179
220
        QWidget.__init__(self, parent, toolTip=opts['tooltip'])
377
418
    opts['validator'] = QIntValidator()
378
419
    return SettingsCombo(**opts)
379
420
 
 
421
def genLineEditBox(opts):
 
422
    'Generate a single line text entry box'
 
423
    return LineEditBox(**opts)
 
424
 
380
425
def genPasswordEntry(opts):
381
426
    'Generate a password entry box'
382
427
    return PasswordEntry(**opts)
 
428
def genTextEntry(opts):
 
429
    'Generate a multi-line text input entry box'
 
430
    return TextEntry(**opts)
383
431
 
384
432
def genDefaultCombo(opts, defaults=[]):
385
433
    'user must select from a list'
464
512
        _('Graphical merge program for resolving merge conflicts.  If left '
465
513
        'unspecified, Mercurial will use the first applicable tool it finds '
466
514
        'on your system or use its internal merge tool that leaves conflict '
467
 
        'markers in place.  Chose internal:merge to force conflict markers ,'
 
515
        'markers in place.  Choose internal:merge to force conflict markers, '
468
516
        'internal:prompt to always select local or other, or internal:dump '
469
517
        'to leave files in the working directory for manual merging')),
470
518
    _fi(_('Visual Diff Tool'), 'tortoisehg.vdiff',
523
571
    )),
524
572
 
525
573
({'name': 'log', 'label': _('Workbench'), 'icon': 'menulog'}, (
 
574
    _fi(_('Single Workbench Window'), 'tortoisehg.workbench.single', genBoolRBGroup,
 
575
        _('Select whether you want to have a single workbench window. '
 
576
        'If you disable this setting you will get a new workbench window everytime that you use the "Hg Workbench"'
 
577
        'command on the explorer context menu. Default: True'),
 
578
        restartneeded=True, globalonly=True),
526
579
    _fi(_('Default widget'), 'tortoisehg.defaultwidget', (genDefaultCombo,
527
580
        ['revdetails', 'commit', 'mq', 'sync', 'manifest', 'search']),
528
581
        _('Select the initial widget that will be shown when opening a '
587
640
        '<li><b>revision</b>: Push the changes in the current branch '
588
641
        '<i><u>up to</u> the current revision</i>.</ul><p>'
589
642
        'Default: all')),
 
643
    _fi(_('Activate Bookmarks'), 'tortoisehg.activatebookmarks', (genDefaultCombo,
 
644
        ['auto', 'prompt', 'never']),
 
645
        _('Select when TortoiseHg will show a prompt to activate a bookmark '
 
646
        'when updating to a revision that has one or more bookmarks.'
 
647
        '<ul><li><b>auto</b>: Try to automatically activate bookmarks. When '
 
648
        'updating to a revision that has a single bookmark it will be activated '
 
649
        'automatically. Show a prompt if there is more than one bookmark on the '
 
650
        'revision that is being updated to.'
 
651
        '<li><b>prompt</b>: The default. Show a prompt when updating to a '
 
652
        'revision that has one or more bookmarks.'
 
653
        '<li><b>never</b>: Never show any prompt to activate any bookmarks.'
 
654
        '</ul><p>'
 
655
        'Default: prompt')),
590
656
    )),
591
657
({'name': 'commit', 'label': _('Commit', 'config item'), 'icon': 'menucommit'}, (
592
658
    _fi(_('Username'), 'ui.username', genEditCombo,
635
701
        '- <b>alwayslocal</b>: same as "<b>always</b>" but restricts forced '
636
702
        'refreshes to <i>local repos</i>.<br>'
637
703
        'Default: auto')),
 
704
    _fi(_('Confirm adding unknown files'), 'tortoisehg.confirmaddfiles', genBoolRBGroup,
 
705
        _('Determines if TortoiseHg should show a confirmation dialog '
 
706
        'before adding new files in a commit. '
 
707
        'If True, a confirmation dialog will be showed. '
 
708
        'If False, selected new files will be included in the '
 
709
        'commit with no confirmation dialog.  Default: True')),
 
710
    _fi(_('Confirm deleting files'), 'tortoisehg.confirmdeletefiles', genBoolRBGroup,
 
711
        _('Determines if TortoiseHg should show a confirmation dialog '
 
712
        'before removing files in a commit. '
 
713
        'If True, a confirmation dialog will be showed. '
 
714
        'If False, selected deleted files will be included in the '
 
715
        'commit with no confirmation dialog.  Default: True')),
638
716
    )),
639
717
 
640
718
({'name': 'web', 'label': _('Web Server'), 'icon': 'proxy'}, (
799
877
          'while {1} refers to the first group and so on. If no {n} tokens'
800
878
          'are found in issue.link, the entire matched string is appended '
801
879
          'instead.')),
 
880
    _fi(_('Inline Tags'), 'tortoisehg.issue.inlinetags', genBoolRBGroup,
 
881
        _('Show tags at start of commit message.')),
802
882
    _fi(_('Mandatory Issue Reference'), 'tortoisehg.issue.linkmandatory', genBoolRBGroup,
803
883
        _('When committing, require that a reference to an issue be specified.  '
804
884
          'If enabled, the regex configured in \'Issue Regex\' must find a match '
813
893
    _fi(_('Issue Tracker Trigger'), 'tortoisehg.issue.bugtraqtrigger', (genDefaultCombo,
814
894
        ['never', 'commit']),
815
895
        _('Determines when the issue tracker state will be updated by TortoiseHg. Valid settings values are:'
816
 
        '<ul><li><b>never</b>: Do not update the Issue Tracker state automaticaly.'
817
 
        '<li><b>commit</b>: Update the Issue Tracker state after a successful commit.</ol><p>'
 
896
        '<ul><li><b>never</b>: Do not update the Issue Tracker state automatically.'
 
897
        '<li><b>commit</b>: Update the Issue Tracker state after a successful commit.</ul><p>'
818
898
        'Default: never'),
819
899
        master='tortoisehg.issue.bugtraqplugin', visible=issuePluginVisible),
820
900
    )),
849
929
    _fi(_('Patterns'), 'largefiles.patterns', genEditCombo,
850
930
        _('Files with names meeting the specified patterns will be automatically '
851
931
          'added as largefiles')),
852
 
    _fi(_('Size'), 'largefiles.size', genEditCombo,
 
932
    _fi(_('Minimum Size'), 'largefiles.minsize', genEditCombo,
853
933
        _('Files of at least the specified size (in megabytes) will be added as largefiles')),
854
 
    _fi(_('System Cache'), 'largefiles.systemcache', genPathBrowser,
855
 
        _('Path to the directory where a system-wide cache of largefiles will be stored')),
 
934
    _fi(_('User Cache'), 'largefiles.usercache', genPathBrowser,
 
935
        _('Path to the directory where a user\'s cache of largefiles will be stored')),
856
936
    )),
857
937
 
858
938
({'name': 'projrc', 'label': _('Projrc'), 'icon': 'settings_projrc', 'extension': 'projrc'}, (
859
 
    _fi(_('Require confirmation'), 'projrc.confirm', genBoolRBGroup,
860
 
        _('Ask the user to confirm the update of the local "projrc" configuration file '
861
 
        'when the remote projrc file changes. Default is "True".')),
 
939
    _fi(_('Require confirmation'), 'projrc.confirm', (genDefaultCombo, ['always', 'first', 'never']),
 
940
        _('When to ask the user to confirm the update of the local "projrc" configuration file '
 
941
        'when the remote projrc file changes. Possible values are:'
 
942
        '<ul><li><b>always</b>: [<i>default</i>] '
 
943
        'Always show a confirmation prompt before updating the local .hg/projrc file.'
 
944
        '<li><b>first</b>: Show a confirmation dialog when the repository is cloned '
 
945
        'or when a remote projrc file is found for the first time.'
 
946
        '<li><b>never</b>: Update the local .hg/projrc file automatically, '
 
947
        'without requiring any user confirmation.</ul>')),
862
948
    _fi(_('Servers'), 'projrc.servers', genEditCombo,
863
949
        _('List of Servers from which "projrc" configuration files must be pulled. '
864
950
        'Set it to "*" to pull from all servers. Set it to "default" to pull from the default sync path.'
868
954
    _fi(_('Exclude'), 'projrc.exclude', genEditCombo,
869
955
        _('List of settings that will NOT be pulled form the project configuration file. '
870
956
        'Default is exclude none of the included settings.')),
 
957
    _fi(_('Update on incoming'), 'projrc.updateonincoming', (genDefaultCombo, ['never', 'prompt', 'auto']),
 
958
        _('Let the user update the projrc on incoming:'
 
959
        '<ul><li><b>never</b>: [<i>default</i>] '
 
960
        'Show whether the remote projrc file has changed, '
 
961
        'but do not update (nor ask to update) the local projrc file.'
 
962
        '<li><b>prompt</b>: Look for changes to the projrc file. '
 
963
        'If there are changes _always_ show a confirmation prompt, '
 
964
        'asking the user if it wants to update its local projrc file.'
 
965
        '<li><b>auto</b>: Look for changes to the projrc file. '
 
966
        'Use the value of the "projrc.confirm" configuration key to '
 
967
        'determine whether to show a confirmation dialog or not '
 
968
        'before updating the local projrc file.</ul><p>'
 
969
        'Default: never')),
 
970
 
871
971
    )),
872
 
 
873
972
)
874
973
 
875
974
CONF_GLOBAL = 0
908
1007
 
909
1008
        self.conftabs = QTabWidget()
910
1009
        layout.addWidget(self.conftabs)
911
 
        utab = SettingsForm(rcpath=hglib.user_rcpath(), focus=focus)
 
1010
        utab = SettingsForm(rcpath=scmutil.userrcpath(), focus=focus)
912
1011
        self.conftabs.addTab(utab, qtlib.geticon('settings_user'),
913
1012
                             _("%s's global settings") % username())
914
1013
        utab.restartRequested.connect(self._pushRestartRequest)
1194
1293
                w = func(opts)
1195
1294
            w.installEventFilter(self)
1196
1295
            if e.globalonly:
1197
 
                w.setEnabled(self.rcpath == hglib.user_rcpath())
 
1296
                w.setEnabled(self.rcpath == scmutil.userrcpath())
1198
1297
            lbl = QLabel(e.label)
1199
1298
            lbl.installEventFilter(self)
1200
1299
            lbl.setToolTip(e.tooltip)