Edgewall Software
Modify

Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#12641 closed defect (fixed)

components section is not completed in "config set" of trac-admin

Reported by: Jun Omae Owned by: Ryan J Ollos
Priority: normal Milestone: 1.2.3
Component: admin/console Version:
Severity: normal Keywords:
Cc: Branch:
Release Notes:

Empty configuration sections are listed in command completion output of trac-admin interactive mode.

API Changes:
Internal Changes:

Description

In config subcommands, existent sections and options are only completed. Fresh trac.ini doesn't have [components] section. Then, the components section is not completed.

I think defined sections and options should be completed in config set command even if not existent.

Attachments (0)

Change History (7)

comment:1 by Ryan J Ollos, 7 years ago

Milestone: next-stable-1.2.x1.2.3
Owner: set to Ryan J Ollos
Status: newassigned

How about this fix?:

  • trac/config.py

    diff --git a/trac/config.py b/trac/config.py
    index bbc425784..dcccd63e5 100644
    a b class ConfigurationAdmin(Component):  
    953953               self._complete_config, self._do_set)
    954954
    955955    def _complete_config(self, args):
     956        sections = set(ConfigSection.get_registry(self.env.compmgr))
     957        options = set(Option.get_registry(self.env.compmgr))
    956958        if len(args) == 1:
    957             return self.config.sections()
     959            section_names = sections | set(i[0] for i in options)
     960            return section_names
    958961        elif len(args) == 2:
    959             return [name for (name, value) in self.config[args[0]].options()]
     962            option_names = set(i[1] for i in options if i[0] == args[0])
     963            return option_names
    960964
    961965    def _do_get(self, section, option):
    962966        if not self.config.has_option(section, option):
$ trac-admin t
Welcome to trac-admin 1.3.3.dev0
Interactive Trac administration console.
Copyright (C) 2003-2017 Edgewall Software

Type:  '?' or 'help' for help on commands.

Trac [/Users/rjollos/Documents/Workspace/trac-dev/teo-rjollos.git/t]> config set
attachment               milestone                roadmap
browser                  milestone-groups         search
changeset                mimeviewer               sqlite
components               notification             svn
header_logo              notification-subscriber  ticket
inherit                  project                  ticket-custom
intertrac                pygments-lexer           ticket-workflow
interwiki                query                    timeline
logging                  report                   trac
mainnav                  repositories             versioncontrol
metanav                  revisionlog              wiki
Trac [/Users/rjollos/Documents/Workspace/trac-dev/teo-rjollos.git/t]> config set project
admin           descr           icon            url
admin_trac_url  footer          name
Trac [/Users/rjollos/Documents/Workspace/trac-dev/teo-rjollos.git/t]> config set inter
intertrac  interwiki

comment:2 by Ryan J Ollos, 7 years ago

Proposed changes in [77cb74b9d/rjollos.git].

comment:3 by Jun Omae, 7 years ago

I tried. Sections and options which are not declared with ConfigSection and Option in trac.ini are not listed.

Trac [/var/trac/1.2-sqlite]> config set foo-section bar-option 42
Trac [/var/trac/1.2-sqlite]> config remove foo
                                              ^ Enter TAB key but none is completed

Also, svn:externals section is declared in svn_prop.py but not listed.

in reply to:  3 ; comment:4 by Ryan J Ollos, 7 years ago

Replying to Jun Omae:

Also, svn:externals section is declared in svn_prop.py but not listed.

I find that it is listed when the component is enabled. Is the component enabled in your environment?

Trac [/Users/rjollos/Documents/Workspace/trac-dev/teo-rjollos.git/env]> config get components tracopt.versioncontrol.*
enabled
Trac [/Users/rjollos/Documents/Workspace/trac-dev/teo-rjollos.git/env]> config get
attachment               metanav                  roadmap
browser                  milestone                search
changeset                milestone-groups         sqlite
components               mimeviewer               svn
git                      notification             svn:externals
gitweb-repositories      notification-subscriber  ticket
header_logo              project                  ticket-custom
inherit                  pygments-lexer           ticket-workflow
intertrac                query                    timeline
interwiki                report                   trac
logging                  repositories             versioncontrol
mainnav                  revisionlog              wiki

in reply to:  4 comment:5 by Jun Omae, 7 years ago

Replying to Ryan J Ollos:

Replying to Jun Omae:

Also, svn:externals section is declared in svn_prop.py but not listed.

I find that it is listed when the component is enabled. Is the component enabled in your environment?

Ah. Missing tracopt.versioncontrol.* = enabled in my environment. The svn:externals is listed after enabling the components. Thanks.

in reply to:  3 comment:6 by Ryan J Ollos, 7 years ago

Replying to Jun Omae:

I tried. Sections and options which are not declared with ConfigSection and Option in trac.ini are not listed.

Trac [/var/trac/1.2-sqlite]> config set foo-section bar-option 42
Trac [/var/trac/1.2-sqlite]> config remove foo
                                              ^ Enter TAB key but none is completed

I reconsidered how to solve the issue: [be1bf0044/rjollos.git].

In most cases we don't want the empty sections to be returned from Configuration.sections(). I added an optional parameter empty, which defaults to False and determines whether entries from the ConfigSection registry are included.

Last edited 7 years ago by Ryan J Ollos (previous) (diff)

comment:7 by Ryan J Ollos, 7 years ago

Release Notes: modified (diff)
Resolution: fixed
Status: assignedclosed

Committed to 1.2-stable in r16231, merged to trunk in r16232.

I noticed the output was unexpectedly sorted without an explicit sort action in console.py. I tried debugging in the code and could not see where the output was being formatted. My best guess is that it's happening in readline.

Trac [/Users/rjollos/Documents/Workspace/trac-dev/tracenvs/proj-1.2]> config get
account-manager            mainnav                    spam-filter
attachment                 metanav                    sqlite
authz_policy               milestone                  svn
autowikify                 milestone-groups           svn:externals
browser                    mimeviewer                 ticket
changeset                  multiselectfield           ticket-custom
childtickets               notification               ticket-workflow
components                 notification-subscriber    ticketstats
discussion                 plantuml                   timeline
extra-permissions          project                    trac
git                        pygments-lexer             versioncontrol
gitweb-repositories        query                      wiki
header_logo                report                     wiki-notification
hg                         repositories               wikiextras
inherit                    revisionlog                wikiextras-custom-phrases
intertrac                  roadmap                    wikiextras-smileys
interwiki                  search                     wikiextras-symbols
logging                    simple-multi-project

I noticed that the output is not sorted when using pypi:pyreadline:

Trac [C:\Users\Ryan Ollos\My Documents\Workspace\proj-1.2]> config set
wiki                    notification            search
changeset               gitweb-repositories     interwiki
sqlite                  attachment              logging
authz_policy            mimeviewer              ticket-custom
roadmap                 milestone-groups        trac
header_logo             mainnav                 repositories
intertrac               timeline                inherit
versioncontrol          extra-permissions       project
svn:externals           metanav                 pygments-lexer
query                   milestone               components
notification-subscriber report                  ticket-workflow
revisionlog             ticket                  browser
git                     svn

I tried sorting the values returned by ConfigurationAdmin._complete_config, but it didn't seem to make a difference.

Anyway, I don't think it's too important, but if anyone determines the cause we can handle it in a new ticket.

Version 0, edited 7 years ago by Ryan J Ollos (next)

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Ryan J Ollos.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Ryan J Ollos to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.