You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by bu...@apache.org on 2006/04/02 18:52:03 UTC
DO NOT REPLY [Bug 39182] New: - Preserve file structure (line comments) when re-saving properties file
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=39182>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=39182
Summary: Preserve file structure (line comments) when re-saving
properties file
Product: Commons
Version: unspecified
Platform: Other
OS/Version: other
Status: NEW
Severity: normal
Priority: P2
Component: Configuration
AssignedTo: commons-dev@jakarta.apache.org
ReportedBy: oded.noam@adamind.com
This bug applies when an application allows both manual editing of its
configuration files, and manipulation of the configuration via software. When
saving the configuration file after changing, its file structure - file,
section and line comments - will all be lost. Next time a human tries to edit
the configuration file, all property documentation will be lost.
I have created a fix for this problem, applicable to PropertiesConfiguration
and XMLPropertiesConfiguration. The fix allows these classes to preserve a
list of comment lines preceding each property line. By default, comments are
not preserved; in case the comment preservation is required, it should be
enabled prior to loading the configuration file using:
AbstractFileConfiguration.setDefaultPreserveComments(true);
The fix is implemented and tested, attached as a patch file to this bug.
--
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
DO NOT REPLY [Bug 39182] - [configuration] Preserve file structure (line comments) when re-saving properties file
Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=39182>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=39182
oded.noam@adamind.com changed:
What |Removed |Added
----------------------------------------------------------------------------
Attachment #18018|0 |1
is obsolete| |
------- Additional Comments From oded.noam@adamind.com 2006-04-11 18:23 -------
Created an attachment (id=18067)
--> (http://issues.apache.org/bugzilla/attachment.cgi?id=18067&action=view)
Revised - java1.3 version of the patch
You are right about the Java1.3 compliance issue. I fixed it.
Of course, this is not exactly what Emmanuel Bourg dreamt about... But it could
be expanded to be good enough 90% of the times. Emmanuel Bourg's idea seems
nice, but I don't think it can be achieved without requiring the user to create
a formatting definitions file for each properties file. Maybe some enhancement
of my mechanism would be easier to use.
--
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
DO NOT REPLY [Bug 39182] - Preserve file structure (line comments) when re-saving properties file
Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=39182>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=39182
------- Additional Comments From oded.noam@adamind.com 2006-04-02 17:53 -------
Created an attachment (id=18018)
--> (http://issues.apache.org/bugzilla/attachment.cgi?id=18018&action=view)
Comment preservation mechanism for AbstractFileConfiguration and its
descendants
--
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
DO NOT REPLY [Bug 39182] - [configuration] Preserve file structure (line comments) when re-saving properties file
Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=39182>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=39182
------- Additional Comments From oded.noam@adamind.com 2006-04-12 07:16 -------
I like the idea for the Layout class. But I see two problems with the fact
that the Layout object is initialized from a configuration file.
First, it requires the application developer to create a layout configuration
file, in addition to default properties file (and, of course, to make sure the
two are compliant with each other). This is a small issue but I suspect that
this requirement might discourage 99% of the potential users of this feature.
Second, since the layout of the file is not derived from the layout it had
before being parsed, re-saving it may result in re-ordering of the lines in
the file, thus making it harder to review the changes using diff (or CVS, for
that matter).
On the other hand, using a layout configuration file will enable formatting of
properties added by the user, and accurate formatting of complex properties
(lists, multi-lines etc). Perhaps you know of applications that make a more
sophisticated use of properties files than I do, but in the applications I've
seen, it is rare for an end user to make a big change to the properties file.
Usually an end user would only modify a couple of properties that are
specified in the file (or commented out). Same goes for configuration changes
made via software.
Maybe the way to go is to create the Layout class, and have it initialized
from analyzing the parsed properties file. Such layout class would not be
complete, but in time we can add all kinds of heuristics for it to detect
things like multiline layout configuration, property groups etc.
--
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
DO NOT REPLY [Bug 39182] - [configuration] Preserve file structure (line comments) when re-saving properties file
Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=39182>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=39182
phil@steitz.com changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|Preserve file structure |[configuration] Preserve
|(line comments) when re- |file structure (line
|saving properties file |comments) when re-saving
| |properties file
--
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
DO NOT REPLY [Bug 39182] - [configuration] Preserve file structure (line comments) when re-saving properties file
Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=39182>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=39182
------- Additional Comments From ebourg@apache.org 2006-04-11 18:27 -------
Thanks for the patch !
There are several aspects to consider in order to preserve completly the file
structure:
- the comments (property or section comments)
- the blank lines
- the order of the properties
- the proper insertion of the new properties next to the similar properties
- the format of the properties:
* multiline or single line lists
* decimal or hexadecimal numbers
* text wrapped on multiple lines
* etc
To handle this I'd like to introduce a Layout class attached to the
configuration rather than overloading the class with more methods. This class
will maintain a List of the elements of the file. This list would look like this:
<comment: Configuration file for the Foo application>
<blank line>
<comment: Main properties>
property: foo.key.a
property: foo.key.b
property: foo.key.bar.a
<blank line>
<comment: Secondary properties>
property: bar.key.a
property: bar.key.b
property: bar.key.c
Every time a property is added or removed from the configuration, the layout
will be notified and it will update the list accordingly. It will attempt to
group the properties by prefix. For example, if the foo.key.bar.b property is
added, it will look for the last property sharing the same prefix, that's
foo.key.bar.a, and insert it after:
...
property: foo.key.a
property: foo.key.b
property: foo.key.bar.a
property: foo.key.bar.b
...
If no similar property is found the property is added at the end of the list.
For every property a format is attached, that's what specifies the property
specific details like the list format or the number format.
It'll be possible to disable this feature if performance is more important than
the correctness of the file. Either by adding a flag to the layout, or by using
a NullLayout that would produce the same result we have today.
--
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
DO NOT REPLY [Bug 39182] - [configuration] Preserve file structure (line comments) when re-saving properties file
Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=39182>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=39182
------- Additional Comments From oliver.heger@t-online.de 2006-04-11 16:46 -------
Looks interesting. Thank you for your work!
I think, Emmanuel Bourg also has some ideas in this area (see
http://issues.apache.org/bugzilla/show_bug.cgi?id=38285#c3). Maybe he can chime
in and comment about how your approach fits with his ideas?
However there is one thing I noticed, which is problematic: Our target
environment is still JDK 1.3. You use some of the new regex facilities that are
not available in this JDK. So either the affected parts have to be re-written or
this patch cannot be applied before we drop support for JDK 1.3.
--
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org