Skip to content
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

Merge filters #39

Merged
merged 18 commits into from
Jan 11, 2013
Merged

Merge filters #39

merged 18 commits into from
Jan 11, 2013

Conversation

sbesson
Copy link
Member

@sbesson sbesson commented Dec 21, 2012

This PR enhances the include/exclude filters used in the Merge command by allowing key:value filters to be passed. Three keys are currently defined: label, pr, user. pr filters are not propagated across submodules.

This allows to use the following syntax

scc merge develop --include user:ext_user pr:24 --exclude broken pr:45 user:session

Couple of questions:

  • currently the first condition for inclusion is a test that the PR owner belongs to the organisation which is almost always true. To be able to merge isolated PRs e.g. by number, we need to modify/disable this inclusion condition.
  • Josh suggested not to pass filters as series of arguments but instead individually. In this case, it would be nice to define a one character long option for include/exclude e.g.
scc merge develop -Iuser:ext_user -Ipr:24 -Ebroken -Epr:45 -Euser:session
  • do we want granularity for the order of precedence? currently PRs are first tested for inclusion using all filters then for exclusion using all filters

/cc @manics for discussion

The include and exclude filter are now parsed and stored in a dictionary
with 3 keys: label (default), pr & user. Each filter can be attributed to the
corresponding key using the key:value syntax in the command line.
For each filter (include or exclude), labels, user and pull request number
are successively tested against the values of the filter dictionary. If the
intersection is not null, it is logged in DEBUG.
@joshmoore
Copy link
Member

@sbesson: see b62f51ed6777661ea328d for the beginnings of unit tests.

@manics
Copy link
Member

manics commented Dec 21, 2012

currently the first condition for inclusion is a test that the PR owner belongs to the organisation which is almost always true. To be able to merge isolated PRs e.g. by number, we need to modify/disable this inclusion condition.

If a specific PR is given I think it's reasonable to automatically add the user, though we're not exactly snowed under by external PRs so a warning message would also do.

do we want granularity for the order of precedence? currently PRs are first tested for inclusion using all filters then for exclusion using all filters

Granularity would be nice but I don't think it's necessary for now, especially if the defaults are reasonable, e.g. scc merge develop --include pr:24 only includes PR24, scc merge develop --exclude pr:24 includes everything except PR24.... but that leaves the problem of whether external PRs should be automatically included.

@sbesson
Copy link
Member Author

sbesson commented Dec 21, 2012

On 21 Dec 2012, at 17:15, Simon Li wrote:

currently the first condition for inclusion is a test that the PR owner belongs to the organisation which is almost always true. To be able to merge isolated PRs e.g. by number, we need to modify/disable this inclusion condition.

If a specific PR is given I think it's reasonable to automatically add the user, though we're not exactly snowed under by external PRs so a warning message would also do.

Agreed and that's how the current set of filters should be working. I'll work on test cases for this scenario.
do we want granularity for the order of precedence? currently PRs are first tested for inclusion using all filters then for exclusion using all filters

Granularity would be nice but I don't think it's necessary for now, especially if the defaults are reasonable, e.g. scc merge develop --include pr:24 only includes PR24, scc merge develop --exclude pr:24 includes everything except PR24.... but that leaves the problem of whether external PRs should be automatically included.

So this is the default behaviour that I'd like us to agree about.
Currently, on ome.git

scc merge develop

will merge any PR opened against develop by a member of openmicroscopy.

Having

 scc merge develop --include pr:24

merge only PR 24 would imply changing this default behaviour to merging no PR (for consistency else specifying an include filter would effectively decrease the number of merged PRs).
I do not mind implementing this change at all if we all agree but we need to take into account the impact on all the jobs using scc merge.


Reply to this email directly or view it on GitHub.

joshmoore and others added 7 commits January 2, 2013 13:14
With @sbesson's changes, it now should be
fairly straight-forward to write mocked
tests. This is currently done using mox.
Like Sandbox.py, Mocks.py provides a base
class which should be used by all mocked
tests.
These overloaded functions (for mox testins) do break the instantiation of
real repositories.
Example of filter that was not working properly with lstrip(): "user:sbesson".
In this case, s.lstrip(key + ":") will also strip the first "s" character.
Define 4 default modes: none, mine, org and alls. Allow better granularity and
potentially any possibility when combined with include/exclude filters.
@sbesson
Copy link
Member Author

sbesson commented Jan 2, 2013

@manics, @joshmoore: the last commit should add an optional parameter to control the default PRs to include.
Merge filters tests can be performed with the --info mode toggled on.

Thus,
scc.py merge --info --default mine --include user:joshmoore
will list all my PRs + all of Josh's

while
scc.py merge --info --default none --include pr:39
will only list PR 39.

Default mode is currently set to org (only PRs opened by public members of the organisation) for consistency with existing behavior until now.

@joshmoore joshmoore mentioned this pull request Jan 3, 2013
@sbesson
Copy link
Member Author

sbesson commented Jan 3, 2013

@joshmoore: the last commit should allow to renable the mox tests without breaking existing behaviour. Can be tested with:

python test/TestMerge.py

@manics
Copy link
Member

manics commented Jan 3, 2013

@sbesson +1 --default is a nice way of handling things.

@sbesson
Copy link
Member Author

sbesson commented Jan 8, 2013

@joshmoore: fixed the Travis build

@joshmoore
Copy link
Member

Looks quite nice. I can imagine us wanted to add more defaults, but I can't think of any off-hand. ("followers", etc.) And eventually having a shortcut (e.g. -D) would probably be worth it, since using just the defaults might suffice in many cases. (In fact, one of my next TODOs is a way to update the submodules daily. I think scc merge -Dnone should suffice, but I need to test it.)

Otherwise, if this has been tested in a job, I think we should get it merged and configure it across the board.

Improve INFO log message to specify default mode
@sbesson
Copy link
Member Author

sbesson commented Jan 9, 2013

@joshmoore: added the -D shortcut.
See https://github.com/snoopycrimecop/openmicroscopy/tree/snoopy/test for the latest push of SCC-merge

@joshmoore
Copy link
Member

The one last thing ( 😇 ) I remember us discussing is whether to have "-E a b c" or "-E a -E b -E c". Since that's a fairly substantial departure, I'd say let's make a choice and stick with it (and I'll promise to never bring it up again, etc.)

self.filters["base"] = args.base
self.filters["default"] = args.default
if args.default == "org":
default_user = "any public member of the organgization"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: organgization

Command for including/excluding multiple filters should be now formatted as:
scc merge master -Dnone -Iuser:user1 -Iuser:user2 -Itest -Ilabel:test2 -Ipr:42 -Ipr:23 -Epr:39
@manics
Copy link
Member

manics commented Jan 9, 2013

The one last thing ( 😇 ) I remember us discussing is whether to have "-E a b c" or "-E a -E b -E c". Since that's a fairly substantial departure, I'd say let's make a choice and stick with it (and I'll promise to never bring it up again, etc.)

Are you referring to:

do we want granularity for the order of precedence? currently PRs are first tested for inclusion using all filters then for exclusion using all filters

Individual arguments means you can mix up the order of -Is and -Es implying ordering matters (rightmost is the final determinant?), whereas only allowing one -I and/or one -E argument doesn't, and there should be a warning if multiple are passed.

@joshmoore
Copy link
Member

There definitely shouldn't be a warning if multiple are passed, that's the point (as I understand it). But I can see how having -I a -E a -I b implies something about the ordering. Similar to -I for gcc, I think having them individual is sensible enough, but we can certainly mention something about the ordering being undefined (or similar).

@manics
Copy link
Member

manics commented Jan 9, 2013

I meant there should be a warning if we stayed with the -I a b c case.

@sbesson
Copy link
Member Author

sbesson commented Jan 9, 2013

After reflexion, I don't think we should be too concerned about my comment above until we reach a concrete situation where having the filters applied in the input order is critical. That being said, the current selection order (1- default, 2- include, 3- exclude) with the extra filtering options (label, user, pr number, default types) of this PR should already give us a lot of flexibility.

The last 2 commits implemented the switch to -I a -I b -Ic. See SCC-merge#100 for the application of these changes.

@joshmoore
Copy link
Member

Merging for now. @manics, if in practice any of the choices causes a problem, another PR will certainly be called for.

joshmoore added a commit that referenced this pull request Jan 11, 2013
@joshmoore joshmoore merged commit f1f0044 into ome:master Jan 11, 2013
@sbesson sbesson deleted the merge_filters branch January 11, 2013 09:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants