Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
] settings: add 'Tools' panel
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  24 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Angel Ezquerra  
View profile  
 More options Apr 28 2012, 2:31 pm
From: Angel Ezquerra <angel.ezque...@gmail.com>
Date: Sat, 28 Apr 2012 20:31:33 +0200
Local: Sat, Apr 28 2012 2:31 pm
Subject: [PATCH [REBASED]] settings: add 'Tools' panel
# HG changeset patch
# User Angel Ezquerra <angel.ezque...@gmail.com>
# Date 1333456876 -7200
# Branch stable
# Node ID 0dd296db8c936a761206415b4c1c948e3a102d73
# Parent  cb6330ef213ae7671e806692f3dead760d1fb2a3
settings: add 'Tools' panel

Add a new panel to the settings dialog which allows configuring (adding,
editing, deleting and reordering) TortoiseHg custom tools.

diff --git a/tortoisehg/hgqt/customtoolconfig.py b/tortoisehg/hgqt/customtoolconfig.py
new file mode 100644
--- /dev/null
+++ b/tortoisehg/hgqt/customtoolconfig.py
@@ -0,0 +1,179 @@
+# customtoolconfig.py - Configuration dialog for TortoiseHg custom tools
+#
+# Copyright 2012 Angel Ezquerra <angel.ezque...@gmail.com>
+#
+# This software may be used and distributed according to the terms of the
+# GNU General Public License version 2, incorporated herein by reference.
+
+from tortoisehg.hgqt.i18n import _
+from tortoisehg.hgqt import qtlib
+
+from PyQt4.QtCore import *
+from PyQt4.QtGui import *
+
+class CustomToolConfigDialog(QDialog):
+    'Dialog for editing the a custom tool configuration'
+
+    _enablemappings = {'All items': 'istrue',
+                        'Working Directory': 'iswd',
+                        'All revisions': 'isrev',
+                        'All contexts': 'isctx',
+                        'Fixed revisions': 'fixed',
+                        'Applied patches': 'applied',
+                        'qgoto': 'qgoto'}
+
+    _locationmappings = {'Everywhere': 'workbench, repowidget',
+                        'Workbench Toolbar': 'workbench',
+                        'Selected Revision context menu': 'repowidget',}
+
+    def __init__(self, parent=None, toolname=None, toolconfig={}):
+        QDialog.__init__(self, parent)
+
+        self.setWindowIcon(qtlib.geticon('tools-spanner-hammer'))
+        self.setWindowTitle('Configure Custom Tool')
+        self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint)
+
+        self.hbox = QHBoxLayout()
+        vbox = QVBoxLayout()
+
+        command = toolconfig.get('command', '')
+        label = toolconfig.get('label', '')
+        tooltip = toolconfig.get('tooltip', '')
+        ico = toolconfig.get('icon', '')
+        location = toolconfig.get('location', 'workbench repowidget')
+        enable = toolconfig.get('enable', 'all')
+        outputlog = toolconfig.get('outputlog', 'False')
+
+        self.name = self._addConfigItem(vbox, _('Tool name'),
+            QLineEdit(toolname), _('The tool name. It cannot contain spaces.'))
+            # Execute a mercurial command. These _MUST_ start with "hg"
+        self.command = self._addConfigItem(vbox, _('Command'),
+            QLineEdit(command), _('The command that will be executed.\n'
+            'To execute a mercurial command use "hg" (rather than "hg.exe") '
+            'as the executable command.\n'
+            'You can use {ROOT} as an alias of the current repository root and\n'
+            '{REV} as an alias of the selected revision.'))
+        self.label = self._addConfigItem(vbox, _('Tool label'),
+            QLineEdit(label),
+            _('The tool label, which is what will be shown '
+            'on the repowidget context menu.\n'
+            'If no label is set, the tool name will be used as the tool label.\n'
+            'If no tooltip is set, the label will be used as the tooltip as well.'))
+        self.tooltip = self._addConfigItem(vbox, _('Tooltip'),
+            QLineEdit(tooltip),
+            _('The tooltip that will be shown on the tool button.\n'
+            'This is only shown when the tool button is shown on\n'
+            'the workbench toolbar.'))
+        self.icon = self._addConfigItem(vbox, _('Icon'),
+            QLineEdit(ico),
+            _('The tool icon.\n'
+            'You can use any built-in TortoiseHg icon\n'
+            'by setting this value to a vaild TortoiseHg icon name\n'
+            '(e.g. clone, add, remove, sync, thg-logo, hg-update, etc).\n'
+            'You can also set this value to the absoluate path to\n'
+            'any icon on your file system.'))
+
+        combo = self._genCombo(self._locationmappings.keys(),
+            self._location2label(location), 'Everywhere')
+        self.location = self._addConfigItem(vbox, _('Show command in'), combo,
+            _('The location where you want to show'
+            'the command icon or menu entry:\n'
+            '- Workbench: Show a button on the Workbench Custom toolbar.\n'
+            '- Repowidget: Show an entry on the selected revision context menu.'))
+
+        combo = self._genCombo(self._enablemappings.keys(),
+            self._enable2label(enable), 'All items')
+        self.enable = self._addConfigItem(vbox, _('On repowidget, show for'),
+            combo,  _('For which kinds of revisions the tool will be enabled\n'
+            'It is only taken into account when the tool is shown on the\n'
+            'selected revision context menu.'))
+
+        combo = self._genCombo(('True', 'False'), outputlog)
+        self.showoutput = self._addConfigItem(vbox, _('Show Output Log'),
+            combo, _('When enabled, automatically show the Output Log when the'
+            'command is run.\nDefault: False.'))
+
+        self.hbox.addLayout(vbox)
+        vbox = QVBoxLayout()
+        self.okbutton = QPushButton(_('OK'))
+        self.okbutton.clicked.connect(self.okClicked)
+        vbox.addWidget(self.okbutton)
+        self.cancelbutton = QPushButton(_('Cancel'))
+        self.cancelbutton.clicked.connect(self.reject)
+        vbox.addWidget(self.cancelbutton)
+        vbox.addStretch()
+        self.hbox.addLayout(vbox)
+        self.setLayout(self.hbox)
+
+    def value(self):
+        toolname = str(self.name.text()).strip()
+        toolconfig = {
+            'label': str(self.label.text()),
+            'command': str(self.command.text()),
+            'tooltip': str(self.tooltip.text()),
+            'icon': str(self.icon.text()),
+            'location': self._locationmappings[str(self.location.currentText())],
+            'enable': self._enablemappings[str(self.enable.currentText())],
+            'showoutput': str(self.showoutput.currentText()),
+        }
+        return toolname, toolconfig
+
+    def _genCombo(self, items, selecteditem=None, defaultitem=None):
+        print items
+        index = 0
+        if selecteditem:
+            print 'selecteditem: %s' % selecteditem
+            try:
+                index = items.index(selecteditem)
+                print index
+            except:
+                if defaultitem:
+                    try:
+                        print 'defaultitem: %s' % defaultitem
+                        index = items.index(defaultitem)
+                    except:
+                        print 'not found'
+                        pass
+        combo = QComboBox()
+        combo.addItems(items)
+        if index:
+            combo.setCurrentIndex(index)
+        return combo
+
+    def _addConfigItem(self, parent, label, configwidget, tooltip=None):
+        if tooltip:
+            configwidget.setToolTip(tooltip)
+        hbox = QHBoxLayout()
+        hbox.addWidget(QLabel(label))
+        hbox.addWidget(configwidget)
+        parent.addLayout(hbox)
+        return configwidget
+
+    def _enable2label(self, label):
+        return self._dictvalue2key(self._enablemappings, label)
+
+    def _location2label(self, label):
+        return self._dictvalue2key(self._locationmappings, label)
+
+    def _dictvalue2key(self, dictionary, value):
+        for key in dictionary:
+            if value == dictionary[key]:
+                return key
+        return None
+
+    def okClicked(self):
+        errormsg = self.validateForm()
+        if errormsg:
+            qtlib.WarningMsgBox(_('Missing information'), errormsg)
+            return
+        return self.accept()
+        
+    def validateForm(self):
+        name, config = self.value()
+        if not name:
+            return _('You must set a tool name.')
+        if name.find(' ') >= 0:
+            return _('The tool name cannot have any spaces in it.')
+        if not config['command']:
+            return _('You must set a command to run.')
+        return '' # No error
diff --git a/tortoisehg/hgqt/settings.py b/tortoisehg/hgqt/settings.py
--- a/tortoisehg/hgqt/settings.py
+++ b/tortoisehg/hgqt/settings.py
@@ -11,7 +11,7 @@

 from tortoisehg.util import hglib, settings, paths, wconfig, i18n, bugtraq
 from tortoisehg.hgqt.i18n import _
-from tortoisehg.hgqt import qtlib, qscilib, thgrepo
+from tortoisehg.hgqt import qtlib, qscilib, thgrepo, customtoolconfig

 from PyQt4.QtCore import *
 from PyQt4.QtGui import *
@@ -180,6 +180,7 @@
         self.curvalue = None
         self.setEchoMode(QLineEdit.Password)
         self.setMinimumWidth(ENTRY_WIDTH)
+
 class TextEntry(QTextEdit):
     def __init__(self, parent=None, **opts):
         QTextEdit.__init__(self, parent, toolTip=opts['tooltip'])
@@ -307,6 +308,103 @@
         return self.value() != self.curvalue

+class ListBox(QListWidget):
+    def __init__(self, parent=None, **opts):
+        QListWidget.__init__(self, parent, **opts)
+        self.opts = opts
+        self.curvalue = None
+        self.setMinimumWidth(ENTRY_WIDTH)
+
+    def values(self):
+        out = []
+        for row in range(self.count()):
+            out.append(self.item(row).text())
+        return out
+
+    ## common APIs for all edit widgets
+    def setValue(self, curvalue):
+        self.curvalue = curvalue
+
+    def value(self):
+        row = self.currentIndex().row()
+        if row < 0:
+            return None
+        else:
+            return self.item(row).text()
+
+    def
...

read more »


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Discussion subject changed to "[PATCH [REBASED]] settings: add 'Tools' panel" by Yuya Nishihara
Yuya Nishihara  
View profile  
 More options Apr 30 2012, 6:41 am
From: Yuya Nishihara <y...@tcha.org>
Date: Mon, 30 Apr 2012 19:41:48 +0900
Local: Mon, Apr 30 2012 6:41 am
Subject: Re: [thg-dev] [PATCH [REBASED]] settings: add 'Tools' panel
On 04/29/2012 03:31 AM, Angel Ezquerra wrote:

missing _()

A small thing, "except ValueError" ?
(and debug prints)

...

read more »


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Angel Ezquerra  
View profile  
 More options Apr 30 2012, 7:13 am
From: Angel Ezquerra <ezque...@gmail.com>
Date: Mon, 30 Apr 2012 13:13:02 +0200
Local: Mon, Apr 30 2012 7:13 am
Subject: Re: [thg-dev] [PATCH [REBASED]] settings: add 'Tools' panel

On Apr 30, 2012 12:41 PM, "Yuya Nishihara" <y...@tcha.org> wrote:

> On 04/29/2012 03:31 AM, Angel Ezquerra wrote:

>> # HG changeset patch
>> # User Angel Ezquerra<angel.ezque...@gmail.com>
>> # Date 1333456876 -7200
>> # Branch stable
>> # Node ID 0dd296db8c936a761206415b4c1c948e3a102d73
>> # Parent  cb6330ef213ae7671e806692f3dead760d1fb2a3
>> settings: add 'Tools' panel

>> Add a new panel to the settings dialog which allows configuring (adding,
>> editing, deleting and reordering) TortoiseHg custom tools.

...

I I've got this bad habit of not specifying the exception type when I
believe its obvious that only one type of exception can be thrown. I must
stop doing that!

Also, I should create a commit hook that warns me about print statements
our something  :-P

I didn't know that. I just followed the examples on other parts of the code.

hglib.tortoisehgtools(ui.ui())

layer.

Ummm. What would be the best way to proceed here then? I want to update the
tortoisehgtools dict when an item is removed from the widget.

> (and extra debug print here :)

:-P

'hg-extensions'}, (
>>      )),

>> +({'name': 'tools', 'label': _('Tools'), 'icon':

'tools-spanner-hammer'}, (
>> +    )),
>> +
>>  ({'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.')),
>> @@ -1240,6 +1341,9 @@
>>                  # make sure widgets are shown properly,
>>                  # even when no extensions mentioned in the config file
>>                  self.validateextensions()
>> +        elif name == 'tools':
>> +            self.tortoisehgtools, self.toolnames =

hglib.tortoisehgtools(ui.ui())

>> +            widgets[0].setValue((self.tortoisehgtools, self.toolnames))

> ui.ui() returns merged values of both user and repository settings.
> So we cannot rely on it in settings dialog.

Actually I'm not too happy that I'm relaying on the ui.config methods at
all. They return dicts, which do not prevent the item order as you know. I
want the tools to appear on a predictable order. Using dicts makes this
hard to do. I wish I could use ordereddicts, but I don't think python 2.4
sports them.

Any suggestions?

> Also, it looks some variables of ToolListBox loaded separately:

>  - this setValue() updates only `curvalue`
>  - `tortoisehgtools`, `toolnames` are loaded at __init__()
>  - and value() returns `(tortoisehgtools, toolnames)`

> Isn't it a bit strange?

when I originally wrote this code it made sense to me, but I'll look into
that again (I'm replying from my phone)

Cheers, and thanks for the thorough review!

Angel


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Yuya Nishihara  
View profile  
 More options Apr 30 2012, 11:11 am
From: Yuya Nishihara <y...@tcha.org>
Date: Tue, 01 May 2012 00:11:39 +0900
Local: Mon, Apr 30 2012 11:11 am
Subject: Re: [thg-dev] [PATCH [REBASED]] settings: add 'Tools' panel
On 04/30/2012 08:13 PM, Angel Ezquerra wrote:
...

For example, have ListBox manage only list of tool names, and keep
tools dict separately?

Hmm, Mercurial's config object (and our wconfig) tries to keep definition
order:

   http://selenic.com/repo/hg/file/be786c5ac0a8/mercurial/config.py#l12

If not, possibly you found a bug.

And yes, ordereddict is only available on Python 2.6 or later.

Regards,


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Angel Ezquerra  
View profile  
 More options Apr 30 2012, 12:00 pm
From: Angel Ezquerra <ezque...@gmail.com>
Date: Mon, 30 Apr 2012 18:00:19 +0200
Local: Mon, Apr 30 2012 12:00 pm
Subject: Re: [thg-dev] [PATCH [REBASED]] settings: add 'Tools' panel

On Apr 30, 2012 5:11 PM, "Yuya Nishihara" <y...@tcha.org> wrote:

These methods ensure that the last value that is set for a given
configuration key is the one that is taken into account. But they work with
dicts. As far as I know there is no way to retrieve different keys in the
order they were set, is there?

Angel


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Yuya Nishihara  
View profile  
 More options May 2 2012, 3:58 am
From: Yuya Nishihara <y...@tcha.org>
Date: Wed, 02 May 2012 16:58:56 +0900
Local: Wed, May 2 2012 3:58 am
Subject: Re: [thg-dev] [PATCH [REBASED]] settings: add 'Tools' panel
On 05/01/2012 01:00 AM, Angel Ezquerra wrote:

> On Apr 30, 2012 5:11 PM, "Yuya Nishihara"<y...@tcha.org>  wrote:
>> Hmm, Mercurial's config object (and our wconfig) tries to keep definition
>> order:

>>   http://selenic.com/repo/hg/file/be786c5ac0a8/mercurial/config.py#l12

>> If not, possibly you found a bug.

> These methods ensure that the last value that is set for a given
> configuration key is the one that is taken into account. But they work with
> dicts. As far as I know there is no way to retrieve different keys in the
> order they were set, is there?

.items() or iterator should preserve the order. Isn't it sufficient?

In [2]: cfg = config.config()
In [3]: cfg.read('.hgrc')
In [16]: cfg['tortoisehg-tools'].items()
Out[16]:
[('update_to_tip.command', 'hg update tip'),
  ('update_to_tip.icon', 'hg-update'),
  ('update_to_tip.showoutput', 'True'),
  ('update_to_tip.tooltip', 'Update to tip'),
  ('update_to_nil.command', 'hg update null'),
  ('update_to_nil.enable', 'istrue'),
  ('update_to_nil.icon', 'hg-update'),
  ('update_to_nil.location', 'workbench repowidget'),
  ('update_to_nil.showoutput', 'False'),
  ('update_to_nil.tooltip', 'Update to null')]
In [18]: list(cfg['tortoisehg-tools'])  # calls __iter__()
Out[18]:
['update_to_tip.command',
  'update_to_tip.icon',
  'update_to_tip.showoutput',
  'update_to_tip.tooltip',
  'update_to_nil.command',
  'update_to_nil.enable',
  'update_to_nil.icon',
  'update_to_nil.location',
  'update_to_nil.showoutput',
  'update_to_nil.tooltip']


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Angel Ezquerra  
View profile  
 More options May 2 2012, 4:05 am
From: Angel Ezquerra <angel.ezque...@gmail.com>
Date: Wed, 2 May 2012 10:05:32 +0200
Local: Wed, May 2 2012 4:05 am
Subject: Re: [thg-dev] [PATCH [REBASED]] settings: add 'Tools' panel

Yuya, cfg is a regular python dictionary in this example, is it not?

In that case, this is what Python's 2.7.2 documention has to say about
its items() method
(http://docs.python.org/library/stdtypes.html#dictionary-view-objects):

<quote>
items()

    Return a copy of the dictionary’s list of (key, value) pairs.

    CPython implementation detail: Keys and values are listed in an
arbitrary order which is non-random, varies across Python
implementations, and depends on the dictionary’s history of insertions
and deletions.
</quote>

So I think it is unwise to rely on the item order to correspond to the
order in which items were added to the dict.

Cheers,

Angel

P.S.- Did you get a chance to have a look at the couple of small
changes to the repowidget context menu that I sent a few days ago?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Yuya Nishihara  
View profile  
 More options May 2 2012, 4:31 am
From: Yuya Nishihara <y...@tcha.org>
Date: Wed, 02 May 2012 17:31:56 +0900
Local: Wed, May 2 2012 4:31 am
Subject: Re: [thg-dev] [PATCH [REBASED]] settings: add 'Tools' panel
On 05/02/2012 05:05 PM, Angel Ezquerra wrote:

It's a sortdict object:

In [7]: type(cfg)
Out[7]: mercurial.config.config

In [8]: type(cfg['tortoisehg-tools'])
Out[8]: mercurial.config.sortdict

And some methods of sortdict keeps insertion order by using extra _list attribute:

In [9]: cfg['tortoisehg-tools']._list
Out[9]:
['update_to_tip.command',
...

Sorry, I did't read these mails yet. I'll check them later.

Regards,


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Angel Ezquerra  
View profile  
 More options May 2 2012, 4:39 am
From: Angel Ezquerra <angel.ezque...@gmail.com>
Date: Wed, 2 May 2012 10:39:26 +0200
Local: Wed, May 2 2012 4:39 am
Subject: Re: [thg-dev] [PATCH [REBASED]] settings: add 'Tools' panel

That is awesome. It will make things much simpler then! :-D

Thanks for the info,

Angel


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Angel Ezquerra  
View profile  
 More options May 6 2012, 1:02 pm
From: Angel Ezquerra <angel.ezque...@gmail.com>
Date: Sun, 6 May 2012 19:02:09 +0200
Local: Sun, May 6 2012 1:02 pm
Subject: Re: [thg-dev] [PATCH [REBASED]] settings: add 'Tools' panel
On Wed, May 2, 2012 at 10:39 AM, Angel Ezquerra

Yuya,

I've been looking into your suggestion but I am unsure how can I use
it. I have several problems:

1. ui.configitems() returns a list of tuples, with every tuple
representing an entry on the section being read. The order of the list
items is random (i.e. it does not follow the order in which each item
was declared on the hgrc files). This makes me believe that a regular
python dictionary is being used internally by ui.configitems.

2. Even if I use a mercurial.confing.config object, when I do:

type(cfg['tortoisehg-tools'])

I get:

<type 'dict'>

rather than:

mercurial.config.sortdict()

What is going on?

Angel


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Yuya Nishihara  
View profile  
 More options May 7 2012, 10:26 am
From: Yuya Nishihara <y...@tcha.org>
Date: Mon, 07 May 2012 23:26:12 +0900
Local: Mon, May 7 2012 10:26 am
Subject: Re: [thg-dev] [PATCH [REBASED]] settings: add 'Tools' panel
On 05/07/2012 02:02 AM, Angel Ezquerra wrote:

If it's a normal dict, ui.configitems() won't preserve the original order.
Could you send me a patch to reproduce the problem? I cannot find the culprit.

Regards,


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Angel Ezquerra  
View profile  
 More options May 7 2012, 10:29 am
From: Angel Ezquerra <angel.ezque...@gmail.com>
Date: Mon, 7 May 2012 16:29:07 +0200
Local: Mon, May 7 2012 10:29 am
Subject: Re: [thg-dev] [PATCH [REBASED]] settings: add 'Tools' panel

Yuya, what do you mean? do you want me to resend the "settings: add
tools panel" patch again?

Cheers,

Angel


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Yuya Nishihara  
View profile  
 More options May 7 2012, 10:34 am
From: Yuya Nishihara <y...@tcha.org>
Date: Mon, 07 May 2012 23:34:58 +0900
Local: Mon, May 7 2012 10:34 am
Subject: Re: [thg-dev] [PATCH [REBASED]] settings: add 'Tools' panel
On 05/07/2012 11:29 PM, Angel Ezquerra wrote:

No, I want your test code, in which config dict is a dict.

There may be some code path to change sortdict to dict, but I cannot find
where it is.

Regards,


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Angel Ezquerra  
View profile  
 More options May 7 2012, 10:43 am
From: Angel Ezquerra <angel.ezque...@gmail.com>
Date: Mon, 7 May 2012 16:43:11 +0200
Local: Mon, May 7 2012 10:43 am
Subject: Re: [thg-dev] [PATCH [REBASED]] settings: add 'Tools' panel

I believe I simply added the following to hglib.tortoisehgtools():

    from mercurial import config
    cfg = config.config()
    cfg.read('.hg/hgrc')
    print type(cfg)
    print type(cfg['tortoieshg-tools'])

to the top of the function.

The result printed:

<class 'mercurial.config.config'>
<type 'dict'>

while I expected it to print:
<class 'mercurial.config.config'>
<type 'mercurial.config.sortdict'>

Cheers,

Angel


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Yuya Nishihara  
View profile  
 More options May 7 2012, 11:12 am
From: Yuya Nishihara <you...@gmail.com>
Date: Tue, 08 May 2012 00:12:35 +0900
Local: Mon, May 7 2012 11:12 am
Subject: Re: [thg-dev] [PATCH [REBASED]] settings: add 'Tools' panel
On 05/07/2012 11:43 PM, Angel Ezquerra wrote:

Does '.hg/hgrc' contain [tortoisehg-tools] section?
If not, cfg['tortoisehg-tools'] will return empty dict.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Angel Ezquerra  
View profile  
 More options May 7 2012, 11:31 am
From: Angel Ezquerra <angel.ezque...@gmail.com>
Date: Mon, 7 May 2012 17:31:03 +0200
Local: Mon, May 7 2012 11:31 am
Subject: Re: [thg-dev] [PATCH [REBASED]] settings: add 'Tools' panel

You are right. That does work. As you said it returns a regular python
dict if the section is not found.

Is there a way to do something akin to ui.configitems, but which
returns a sortdict instead?

Using mecurial.config.config() requires knowing the path of the hgrc
file that you want to read, and instead I'd like to read all the hgrc
files as mercurial does, in the order that mercurial follows, but get
a sortdict...

Angel


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Yuya Nishihara  
View profile  
 More options May 7 2012, 12:27 pm
From: Yuya Nishihara <y...@tcha.org>
Date: Tue, 08 May 2012 01:27:46 +0900
Local: Mon, May 7 2012 12:27 pm
Subject: Re: [thg-dev] [PATCH [REBASED]] settings: add 'Tools' panel
On 05/08/2012 12:31 AM, Angel Ezquerra wrote:

Are you trying to use sortdict out of config or ui module?
I think sortdict is designed for internal use, as it lacks keys() or iteritems().

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Angel Ezquerra  
View profile  
 More options May 7 2012, 6:04 pm
From: Angel Ezquerra <angel.ezque...@gmail.com>
Date: Tue, 8 May 2012 00:04:08 +0200
Local: Mon, May 7 2012 6:04 pm
Subject: Re: [thg-dev] [PATCH [REBASED]] settings: add 'Tools' panel

What I want is to get the tools defined in the tortoisehg-tools
section in the order in which they are set in that section. The
ui.config methods do not let you do that because they return regular
python objects. I did not know about the mercurial.config.sortdict or
the mercurial.config.config. When you mentioned it it seemed to me
that I may use those for my purpose?

Angel


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Yuya Nishihara  
View profile  
 More options May 8 2012, 8:18 am
From: Yuya Nishihara <you...@gmail.com>
Date: Tue, 08 May 2012 21:18:45 +0900
Local: Tues, May 8 2012 8:18 am
Subject: Re: [thg-dev] [PATCH [REBASED]] settings: add 'Tools' panel
On 05/08/2012 07:04 AM, Angel Ezquerra wrote:

ui.configitems() should preserve the order. Doesn't it work?

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Angel Ezquerra  
View profile  
 More options May 11 2012, 5:10 pm
From: Angel Ezquerra <angel.ezque...@gmail.com>
Date: Fri, 11 May 2012 23:10:55 +0200
Local: Fri, May 11 2012 5:10 pm
Subject: Re: [thg-dev] [PATCH [REBASED]] settings: add 'Tools' panel

This is very weird. If I run:

ui.configitems('tortoisehg-tools')

from mercurial itself (by running hg --debugger and then executing the
command at the debug prompt) I get the list of config items in the
same order that they are on my config file.

However, if I put:

print ui.configitems('tortoisehg-tools')

inside hglib.tortoisehgtools(), I get them in a different order!

I get a list of items which are not in the same order I put them on my
mercurial.ini file.

I am a bit stuck with this patch. I'd like to be able to preserve the
tool ordering. Otherwise each time you edit the tool list you may end
up with a different tool order...

Angel


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Yuya Nishihara  
View profile  
 More options May 12 2012, 7:44 am
From: Yuya Nishihara <y...@tcha.org>
Date: Sat, 12 May 2012 20:44:26 +0900
Local: Sat, May 12 2012 7:44 am
Subject: Re: [thg-dev] [PATCH [REBASED]] settings: add 'Tools' panel
On 05/12/2012 06:10 AM, Angel Ezquerra wrote:

um, very strange. Just in case, could you test it in fresh environment?
You can switch profile by HGRCPATH and APPDATA environment variable.

If any repository's .hgrc defines [tortoisehg-tools] section and if it's
listed in thg-reporegistry.xml, it may happen to override user config.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Angel Ezquerra  
View profile  
 More options May 12 2012, 8:47 pm
From: Angel Ezquerra <angel.ezque...@gmail.com>
Date: Sun, 13 May 2012 02:47:10 +0200
Local: Sat, May 12 2012 8:47 pm
Subject: Re: [thg-dev] [PATCH [REBASED]] settings: add 'Tools' panel

I don't think that is the problem.

I did the following:

1. add the following code to the top of hglib.tortoisehgtools():

    print '-'
    print type(ui)
    print ui.configitems('tortoisehg-tools')
    print '-'

2. Remove the tortoisehg-tools section from my mercurial.ini file
(located on my windows profile folder)

3. Run thg with: C:\Python26\python.exe thg --nofork --newworkbench

I got the following output:

-
<class 'mercurial.ui.ui'>
[]
-
-
<class 'mercurial.ui.ui'>
[]
-
-
<class 'mercurial.ui.ui'>
[]
-
-
<class 'mercurial.ui.ui'>
[]
-
-
<class 'mercurial.ui.ui'>
[]
-

This means that there is no other tortoisehg-tools section on any
other hgrc file (which I also verified anyway).

I then added the tortoisehg-tools section back. Its contents are:

[tortoisehg-tools]
# Execute a mercurial command. These _MUST_ start with "hg"
# Note that we can use any built-in TortoiseHg icon
update_to_tip.command = hg update -r tip
update_to_tip.enable = istrue
update_to_tip.location = repowidget
update_to_tip.showoutput = False
explore_wd.command = explorer.exe /e,{ROOT}
explore_wd.enable = iswd
explore_wd.label = Open in explorer
explore_wd.location = repowidget
explore_wd.showoutput = True
update_to_1.command = hg update 1
update_to_1.icon = hg-update
update_to_1.location = repowidget
update_to_1.showoutput = True
update_to_1.tooltip = Update to 1
name.command = command
name.enable = istrue
name.label = label
name.location = workbench repowidget
name.showoutput = True
name.tooltip = tooltip

Finally I ran thg again:

C:\Users\Angel\Documents\Repositories\thg>C:\Python26\python.exe thg --nofork --
newworkbench
QWindowsFileSystemWatcherEngine: unknown message '
-
<class 'mercurial.ui.ui'>
[('update_to_tip.command', 'hg update -r tip'), ('update_to_tip.enable', 'istrue
'), ('update_to_tip.location', 'repowidget'), ('update_to_tip.showoutput', 'Fals
e'), ('explore_wd.command', 'explorer.exe /e,{ROOT}'), ('explore_wd.enable', 'is
wd'), ('explore_wd.label', 'Open in explorer'), ('explore_wd.location', 'repowid
get'), ('explore_wd.showoutput', 'True'), ('update_to_1.command', 'hg update 1')
, ('update_to_1.icon', 'hg-update'), ('update_to_1.location', 'repowidget'), ('u
pdate_to_1.showoutput', 'True'), ('update_to_1.tooltip', 'Update to 1'), ('name.
command', 'command'), ('name.enable', 'istrue'), ('name.label', 'label'), ('name
.location', 'workbench repowidget'), ('name.showoutput', 'True'), ('name.tooltip
', 'tooltip')]
-
-
<class 'mercurial.ui.ui'>
[('explore_wd.command', 'explorer.exe /e,{ROOT}'), ('explore_wd.enable', 'iswd')
, ('explore_wd.label', 'Open in explorer'), ('explore_wd.location', 'repowidget'
), ('explore_wd.showoutput', 'True'), ('name.command', 'command'), ('name.enable
', 'istrue'), ('name.label', 'label'), ('name.location', 'workbench repowidget')
, ('name.showoutput', 'True'), ('name.tooltip', 'tooltip'), ('update_to_1.comman
d', 'hg update 1'), ('update_to_1.icon', 'hg-update'), ('update_to_1.location',
'repowidget'), ('update_to_1.showoutput', 'True'), ('update_to_1.tooltip', 'Upda
te to 1'), ('update_to_tip.command', 'hg update -r tip'), ('update_to_tip.enable
', 'istrue'), ('update_to_tip.location', 'repowidget'), ('update_to_tip.showoutp
ut', 'False')]
-
-
<class 'mercurial.ui.ui'>
[('explore_wd.command', 'explorer.exe /e,{ROOT}'), ('explore_wd.enable', 'iswd')
, ('explore_wd.label', 'Open in explorer'), ('explore_wd.location', 'repowidget'
), ('explore_wd.showoutput', 'True'), ('name.command', 'command'), ('name.enable
', 'istrue'), ('name.label', 'label'), ('name.location', 'workbench repowidget')
, ('name.showoutput', 'True'), ('name.tooltip', 'tooltip'), ('update_to_1.comman
d', 'hg update 1'), ('update_to_1.icon', 'hg-update'), ('update_to_1.location',
'repowidget'), ('update_to_1.showoutput', 'True'), ('update_to_1.tooltip', 'Upda
te to 1'), ('update_to_tip.command', 'hg update -r tip'), ('update_to_tip.enable
', 'istrue'), ('update_to_tip.location', 'repowidget'), ('update_to_tip.showoutp
ut', 'False')]
-
QWindowsFileSystemWatcherEngine: unknown message '
-
<class 'mercurial.ui.ui'>
[('explore_wd.command', 'explorer.exe /e,{ROOT}'), ('explore_wd.enable', 'iswd')
, ('explore_wd.label', 'Open in explorer'), ('explore_wd.location', 'repowidget'
), ('explore_wd.showoutput', 'True'), ('name.command', 'command'), ('name.enable
', 'istrue'), ('name.label', 'label'), ('name.location', 'workbench repowidget')
, ('name.showoutput', 'True'), ('name.tooltip', 'tooltip'), ('update_to_1.comman
d', 'hg update 1'), ('update_to_1.icon', 'hg-update'), ('update_to_1.location',
'repowidget'), ('update_to_1.showoutput', 'True'), ('update_to_1.tooltip', 'Upda
te to 1'), ('update_to_tip.command', 'hg update -r tip'), ('update_to_tip.enable
', 'istrue'), ('update_to_tip.location', 'repowidget'), ('update_to_tip.showoutp
ut', 'False')]
-
-
<class 'mercurial.ui.ui'>
[('explore_wd.command', 'explorer.exe /e,{ROOT}'), ('explore_wd.enable', 'iswd')
, ('explore_wd.label', 'Open in explorer'), ('explore_wd.location', 'repowidget'
), ('explore_wd.showoutput', 'True'), ('name.command', 'command'), ('name.enable
', 'istrue'), ('name.label', 'label'), ('name.location', 'workbench repowidget')
, ('name.showoutput', 'True'), ('name.tooltip', 'tooltip'), ('update_to_1.comman
d', 'hg update 1'), ('update_to_1.icon', 'hg-update'), ('update_to_1.location',
'repowidget'), ('update_to_1.showoutput', 'True'), ('update_to_1.tooltip', 'Upda
te to 1'), ('update_to_tip.command', 'hg update -r tip'), ('update_to_tip.enable
', 'istrue'), ('update_to_tip.location', 'repowidget'), ('update_to_tip.showoutp
ut', 'False')]
-

As you can see hglib.tortoisehgtools is called multiple times during
the TortoiseHg startup. The first time the order is correct! However
the second time the function is called (and all the other times) the
order is wrong!

Looking at the hglib.tortoisehgtools() method there seems to be no
catching which could explain the problem. It is probably something
really simple, but it is quite late here and I faile to see it now :-)

Cheers,

Angel


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Yuya Nishihara  
View profile  
 More options May 13 2012, 1:19 am
From: Yuya Nishihara <y...@tcha.org>
Date: Sun, 13 May 2012 14:19:00 +0900
Subject: Re: [thg-dev] [PATCH [REBASED]] settings: add 'Tools' panel
On 05/13/2012 09:47 AM, Angel Ezquerra wrote:

[...]

[...]

Got it. Maybe you are using projrc extension?
It reorders items alphabetically:
https://bitbucket.org/aragost/projrc/src/a9ccbead5335/projrc.py#cl-286

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Angel Ezquerra  
View profile  
 More options May 13 2012, 2:32 am
From: Angel Ezquerra <angel.ezque...@gmail.com>
Date: Sun, 13 May 2012 08:32:08 +0200
Local: Sun, May 13 2012 2:32 am
Subject: Re: [thg-dev] [PATCH [REBASED]] settings: add 'Tools' panel

Yes I am. Good catch!

I got write rights on the projrc repo, so I may even push the fix that
you proposed to Martin :-)

In the meantime I can disable the extension and use the
ui.configitems() as it was intended. I thought that ui.configitems()
returned the items in random order because behind the scenes mercurial
was using dicts. In retrospects it makes sense that mercurial would
preserve the order. It seems that the projrc extension was messing
with me the whole time! :-P

Now I can try to finish this patch once and for all! :-D

Angel


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »