-
Notifications
You must be signed in to change notification settings - Fork 170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
handle when you combine increments without a base equals #177
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -227,6 +227,16 @@ def __init__(self, config_file, cloptions, | |
# apply command-line options | ||
_update(data, cloptions) | ||
|
||
# convert any remaining += to = | ||
for sectionname in data: | ||
section = data[sectionname] | ||
s2 = section.copy() | ||
for k, v in s2.items(): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would avoid the
|
||
if k.endswith('+'): | ||
key = k.rstrip(' +') | ||
section[key] = v | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it possible for a section to already have a I think these two examples should have the same effect:
and
i.e. latter option overrides the former one. The following config is subtly different:
and I would expect it to produce the same as
i.e. Do you agree? Does your PR implement this? |
||
del section[k] | ||
|
||
# Set up versions section, if necessary | ||
if 'versions' not in data['buildout']: | ||
data['buildout']['versions'] = ('versions', 'DEFAULT_VALUE') | ||
|
@@ -1651,11 +1661,20 @@ def _update_section(s1, s2): | |
if k.endswith('+'): | ||
key = k.rstrip(' +') | ||
# Find v1 in s2 first; it may have been defined locally too. | ||
v1, note1 = s2.get(key, s1.get(key, ("", ""))) | ||
v1, note1 = s2.get(key, s1.get(key, s1.get(k, ("", "")))) | ||
if v1 == '': | ||
# merging += in nothing. Keep as += | ||
key = key + " +" | ||
elif k in s1: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What if
should be handled the same way as
|
||
# merging += into +=. keep as += | ||
key = key + " +" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are key names normalized? If |
||
del s1[k] | ||
else: | ||
# merging += into =. convert to = | ||
del s2[k] | ||
newnote = ' [+] '.join((note1, note2)).strip() | ||
s2[key] = "\n".join((v1).split('\n') + | ||
v2.split('\n')), newnote | ||
del s2[k] | ||
elif k.endswith('-'): | ||
key = k.rstrip(' -') | ||
# Find v1 in s2 first; it may have been set by a += operation first | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2671,6 +2671,45 @@ def increment_buildout_with_multiple_extended_files_421022(): | |
recipe='zc.buildout:debug' | ||
""" | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. PEP-8 recommends two blank lines between top-level functions. |
||
def increment_buildout_with_multiple_extended_without_base_equals(): | ||
r""" | ||
|
||
>>> write('buildout.cfg', ''' | ||
... [buildout] | ||
... extends = base1.cfg base2.cfg | ||
... parts += foo | ||
... [foo] | ||
... recipe = zc.buildout:debug | ||
... [base1] | ||
... recipe = zc.buildout:debug | ||
... [base2] | ||
... recipe = zc.buildout:debug | ||
... ''') | ||
>>> write('base1.cfg', ''' | ||
... [buildout] | ||
... extends = base3.cfg | ||
... parts += base1 | ||
... ''') | ||
>>> write('base2.cfg', ''' | ||
... [buildout] | ||
... extends = base3.cfg | ||
... parts += base2 | ||
... ''') | ||
>>> write('base3.cfg', ''' | ||
... [buildout] | ||
... ''') | ||
|
||
>>> print_(system(buildout), end='') | ||
Installing base1. | ||
recipe='zc.buildout:debug' | ||
Installing base2. | ||
recipe='zc.buildout:debug' | ||
Installing foo. | ||
recipe='zc.buildout:debug' | ||
""" | ||
|
||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. PEP-8 recommends two blank lines between top-level functions. I don't believe a single test case is sufficient. I outlined some other possible test cases in my other comments. |
||
def increment_on_command_line(): | ||
r""" | ||
>>> write('buildout.cfg', ''' | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Edge case" is two words.
Other changelog entries end with a final period, perhaps it would be good to follow that convention.
It would also be good to link to a bug report.