GNOME Bugzilla – Bug 602406
Basic support for editing attachment flags
Last modified: 2015-03-01 09:49:41 UTC
With git-bz attach -e it would be nice to be able to edit attachment flags ;) Patches are following.
Created attachment 148116 [details] [review] added support to edit attachment flags
Created attachment 148117 [details] [review] new tracker option to specify attachment flags
Created attachment 148118 [details] [review] example use of attachment-flags
Created attachment 148119 [details] [review] documentation for attachment-flags config option
Thanks for the patches! I'm sorry it took me so long to get to looking at them. This is a bit too raw to land exactly like this. There doesn't seem to be any easy way to avoid someone having to look at HTML source to figure out flag names. But I think once it's been configured for a tracker once, you shouldn't have to deal with: Flags: flag_type-607 in git bz attach -e. Bobby Holley has a patches where he's added handling of the Reviewer:, Super-Reviewer flags, hardcoding how they work on bugzilla.mozilla.org http://github.com/bholley/git-bz-moz/ The way that Bobby's code works, if I'm reading it right is that you can have multiple: Review: joe@example.com Review: :jane.doe (I'm not really sure where the ':' is handled in :jane.doe - it looks like the server code always does substring matches, though they can obviously fail from not matching or matching multiply. But maybe I'm misreading the server code or the git-bz patches.) And those turn into ? flag requests with the requestee or requestees. You can also add a self-review to a patch you are filing with: '[Super-]Review: :me+ I think what I'd like to see is that flags can be defined for a tracker: bz.config bz.bugzilla.mozilla.org.attachment-flag.Review.id 4 bz.config bz.bugzilla.mozilla.org.attachment-flag.Review.requesteeable true (Note that there are no sub-subsections, so this actually is creating a section called "bugzilla.mozilla.org.attachment-flag.Review".) We'd also want to be able to specify these in the git-bz script so we could ship with the most important flags for the most popular bug trackers pre-defined. requesteeable is a horrible word, but sticking to what the bugzilla sources use. (The user docs have "Specifically Requestable") The schema for flags includes also requestable and multiplicable. See http://www.bugzilla.org/docs/tip/en/html/api/Bugzilla/FlagType.html Then if flags have been defined the edit buffer would contain: # Uncomment to set flags for the attachment; flags can be set to +,- , or ?. # When setting a flag to ? you can specify individuals as, for example: # Review: ? joe@example.com #Review: ? #Super-Review: ? self-review would be: Review: + Multiple review requests: Review: ? joe@example.com, jane.doe (Or :jane.doe if you explain that to me a bit more)
Created attachment 176653 [details] [review] Updated patch
Thanks Owen for the guidance on this patch and sorry for the delay ;)
Hi Owen, Any chance of having a new review of this patch soon? :)
Ping Owen?
Review of attachment 176653 [details] [review]: Sorry to be even slower getting back to this. The patch is definitely along the lines of what I was thinking of. In addition to the comments below, I'd definitely like to see some documentation of this in the man page. ::: git-bz @@ +287,3 @@ result = {} + def split_in_dicts(parts, option_value): I find the config handling here a bit difficult to read - you define two abstract operations, then they magically combine together to do the right thing. The way I'd do it is something like: param_parts = param.split(".") param_parts.reverse() param_dict = result while len(param_parts) > 1: part = param_parts.pop() if not part in param_dict or not isinstance(param_dict[part], dict): param_dict[part] = {} param_dict = param_dict[part] param_dict[param_parts[0]] = value You should be able to put that into a function and reuse between this and get_git_config(). I think the best way then to handle combining results from multiple sources (DEFAULT_CONFIG, CONFIG, git_config), is to change get_git_config() to add_config_from_git() and split_local_config() to add_config_from_string() and pass a dict in, so each one can just add options/overwrite. @@ +1301,3 @@ + pat = re.compile(r"(?<!\d)%d(?!\d)" % bug_id) + return (pat.search(commit.subject) is None and + pat.search(get_body(commit)) is None) I'd prefer not to have unrelated white space fixage in the patch even if it is correct fixage @@ +1575,3 @@ + for flag_name in flag_names: + if not line.startswith(flag_name): + continue Compare for obsoletes: m = re.match("^\s*Obsoletes\s*:\s*([\d]+)", line) where we accept leading whitespace, I think you want something like: m = re.match(r'^\s*([^ ,]+)\s*:\s*([+-?].*?)\s*$', line) if not m: continue possible_flag = m.group[0] value = m.group[1] Checking the bugzilla sources a new flag is validated against: ($name && $name !~ /[ ,]/ && length($name) <= 50). so that's why the [^ ,]. And I think it's good to add the +-? for the value to try to make false-positives very unlikely. @@ +1582,3 @@ + requesteeable = flag_config.get('requesteeable', 'false') + if value.startswith('?') and len(value) > 1 and requesteeable != 'true': + print "Flag %r is not requesteeable! Setting fallback value: '?'" % flag_name Remember, our goal is to get common flags in to the git-bz codebase, so the person who hits this error message probably has never seen the word 'requesteeable', definitely doesn't need to be scolded with a ! :-) something like: Flag 'CommitQueue' cannot be requested for a specific user. Ignoring 'joe@example.com'. seems like a more friendly error message. But you also should warn about doing + joe@example.com - with something like: A specific user can only be requested for the '?' status. Ignoring 'joe@example.com'. @@ +1584,3 @@ + print "Flag %r is not requesteeable! Setting fallback value: '?'" % flag_name + value = '?' + flags["flag_type-%s" % flag_config['id']] = value This doesn't look right to me comparing to the bugzilla sources. It looks like the reuestee is in a separate requestee_type parameter. Something like: requestees = re.split(r'\s+|\s*,\s*,', value[1:]) flags["requestee_type-%s" % flag_config['id']] = requestees Possibly adding 'multiplicable' to the understood config and erroring nicely if multiple requestees are specified and the flag isn't multiplicable. Probably need to test against bugzilla.mozilla.org before landing this patch if bugzilla.webkit.org doesn't have any reuesteeable flags.
> (I'm not really sure where the ':' is handled in :jane.doe - it looks like the > server code always does substring matches, though they can obviously fail from > not matching or matching multiply. But maybe I'm misreading the server code or > the git-bz patches.) I got rid of the special handling of ':' and '@' in Mozilla's fork and just let the server do its substring matches; it's simpler and matches the behavior of the Bugzilla web UI. For those playing along at home, the main repository is now https://github.com/jlebar/git-bz-moz
Thanks Owen, it's a bit hard to get back into this patch after all this time but hopefully we'll get there :) (In reply to comment #10) > > @@ +1584,3 @@ > + print "Flag %r is not requesteeable! Setting fallback value: > '?'" % flag_name > + value = '?' > + flags["flag_type-%s" % flag_config['id']] = value > > This doesn't look right to me comparing to the bugzilla sources. It looks like > the reuestee is in a separate requestee_type parameter. Something like: > > requestees = re.split(r'\s+|\s*,\s*,', value[1:]) > flags["requestee_type-%s" % flag_config['id']] = requestees > > Possibly adding 'multiplicable' to the understood config and erroring nicely if > multiple requestees are specified and the flag isn't multiplicable. > > Probably need to test against bugzilla.mozilla.org before landing this patch if > bugzilla.webkit.org doesn't have any reuesteeable flags. WebKit's bugzilla indeed doesn't use that feature and I doubt Mozilla's does either (by looking at their git-bz repo). Maybe Justin can confirm? Can this part of the patch be deferred to a follow-up patch in that case?
(In reply to comment #12) > > Possibly adding 'multiplicable' to the understood config and erroring nicely if > > multiple requestees are specified and the flag isn't multiplicable. > > > > Probably need to test against bugzilla.mozilla.org before landing this patch if > > bugzilla.webkit.org doesn't have any reuesteeable flags. > > WebKit's bugzilla indeed doesn't use that feature and I doubt Mozilla's does > either (by looking at their git-bz repo). Maybe Justin can confirm? > > Can this part of the patch be deferred to a follow-up patch in that case? The Review feature in git-bz-moz seems to mostly be about the requestee - you can definitely request a a review from a particular user. If you mean multiplicable rather than requesteeable, that could be omitted for an initial patch, though I think then the first version should just accept a single requestee, so that if people need the feature, it gets added later rather than just sitting there as a trap to create server errors.
(In reply to comment #13) > (In reply to comment #12) > > > > Possibly adding 'multiplicable' to the understood config and erroring nicely if > > > multiple requestees are specified and the flag isn't multiplicable. > > > > > > Probably need to test against bugzilla.mozilla.org before landing this patch if > > > bugzilla.webkit.org doesn't have any reuesteeable flags. > > > > WebKit's bugzilla indeed doesn't use that feature and I doubt Mozilla's does > > either (by looking at their git-bz repo). Maybe Justin can confirm? > > > > Can this part of the patch be deferred to a follow-up patch in that case? > > The Review feature in git-bz-moz seems to mostly be about the requestee - you > can definitely request a a review from a particular user. > > If you mean multiplicable rather than requesteeable, that could be omitted for > an initial patch, though I think then the first version should just accept a > single requestee, so that if people need the feature, it gets added later > rather than just sitting there as a trap to create server errors. I meant the multiplicable thing indeed. Alright then, I'm updating the patch.
Created attachment 207697 [details] [review] New patch
Review of attachment 207697 [details] [review]: Thanks for updating the patch! After such a ridiculously long time for me to get to reviewing this, I decided to simply go ahead and make the fixes listed below and commit rather than asking you to remember where you were again and make the commits (and risk me not looking at it for several more years!) I've tested things with bugzilla.redhat.com so hopefully my changes are OK - I apologize if I introduced any bugs :-) ::: git-bz @@ +311,3 @@ +def add_config_from_string(config_text, existing_config): + result = existing_config You are probably doing this to have the clearest parameter name, but not change the code - but the code ends up looking confused about how arguments are passed in Python - especially the assigment back to existing_config at the end. It's better to just use 'result' as the parameter name. @@ +334,3 @@ + param_dict = param_dict[part] + param_dict[param_parts[0]] = value + result.update(param_dict) You don't want this this - this makes it so if the line was: foo.bar = 1 Then you'd end up with result as: { 'foo': { 'bar': 1 }, 'bar': 1 } @@ +340,1 @@ +def add_config_from_git(name, existing_config): it doesn't look you've actually implemented parsing thse options out of git config despite the example in the commit message bz.config bz.bugzilla.mozilla.org.attachment-flag.Review.requesteeable true @@ +1640,3 @@ + # Lookup for a known attachment flag in the line. It has to be + # at the beginning of the line. + for flag_name in flag_names: You loop over the flag names, but then ignore flag_name and overwrite it with the match. @@ +1649,3 @@ + # Flag found, check its value and build the form data + # that bugzilla will be able to understand. + flag_config = attachment_flags[flag_name] This is going to backtrace on an a line that looks like a flag but isn't. I grepped through the 400,000 line GTK+ log and found half-a-dozen lines that would have false-matched - one example that came up a few times was something along the lines of: This patch finally fixes the last bug in my program. Yay :-) A false match isn't likely, but needs to be handled in some way - either by ignoring lines with unknown flags, or by warning. Since we actually write the lines with the flags into the output and only expect the user to edit them, I think ignoring unknown flags is least likely to cause confusion; there's no way that the user will be anything but confused by an error message about an unknown flag "Yay". @@ +1654,3 @@ + if requesteeable != 'true': + ignored_value_chunk = value[1:] + print "Flag %r cannot be requested for a specific user. Ignoring %r and setting flag to fallback value: '?'." % (flag_name, ignored_value_chunk) Using '%r' like this isn't a good idea, since flag_name could be unicode, and then you'd get u'review'. There's a small whitespace problem here - you'll get "ignoring ' otaylor@redhat.com'" @@ +1657,3 @@ + value = '?' + else: + requestees = value[1:].strip().replace(' ', '').split(',') The code in bugzilla actually is meant to allow using, say, 'Owen Taylor' as a requestee. So it's better to have: requestees = [r.strip() for r in value[1:].split(',')] @@ +1664,3 @@ + value = '?' + + if value.startswith('+') and len(value) > 1: I'd handle '-' as well as '+'. I can see someone wanting to attach a patch for documentation or P.O.C. but self-review it to - at the same point. (I do an equivalent thing with bugzilla.gnome.org patch statuses occasionally.) ::: git-bz.txt @@ +269,3 @@ +ATTACHMENT FLAGS +---------------- Various minor edits below @@ +272,3 @@ + +When editing the description of an attachment with 'git-bz attach -e' +it is possible to set different flag values understandable by is is possible to set flag values, depending on the configuration of the bug tracker. @@ +273,3 @@ +When editing the description of an attachment with 'git-bz attach -e' +it is possible to set different flag values understandable by +the bug tracker. However it is first required to configure the flag However, it is first necessary.. @@ +276,3 @@ +types available for your bug tracker. Ask the administrator of the +tracker or inspect the HTML source code of the attachment.cgi +page. For each flag you need to configure its id and wether or not it whether @@ +286,3 @@ + +With the above flag configuration, when editing an attachment +description you should see a template allowing to set the flag: allowing settings the flag:
Created attachment 298131 [details] [review] Support for editing attachment flags. Here's my corrected version. In addition to what I mentioned in the review, I decided since what is exposed on bugzilla.webkit.org to the user is "review" and "commit-queue", that's what should be in the config and examples, not "Review" and "CommitQueue" ----- One has to first define the available flags for the bugtracker used. The only way I found is to look at the source of the bugtracker "Create New Attachment" page. Examples of use of a review: flag below. Self-review would be: review: + Requesting a review from a specific persoon would look like: review: ? joe@example.com To request review from a specific person as shown above, the requesteeable git-bz option of the flag has to be set to true like: git config bz-tracker.bugzilla.mozilla.org.attachment-flag.review.requesteeable true (Patch includes fixes by Owen Taylor <otaylor@redhat.com>)
Created attachment 298132 [details] [review] Support for editing attachment flags. Forgot to include git-bz.txt fixes in the last version I attached. --- One has to first define the available flags for the bugtracker used. The only way I found is to look at the source of the bugtracker "Create New Attachment" page. Examples of use of a review: flag below. Self-review would be: review: + Requesting a review from a specific persoon would look like: review: ? joe@example.com To request review from a specific person as shown above, the requesteeable git-bz option of the flag has to be set to true like: git config bz-tracker.bugzilla.mozilla.org.attachment-flag.review.requesteeable true (Patch includes fixes by Owen Taylor <otaylor@redhat.com>)
Created attachment 298134 [details] [review] Allow "multiplicable" attachment flags A multiplicable flag can be requested of several users.
Created attachment 298136 [details] [review] Add basic attachment flags for bugzilla.mozilla.org Add the attachment flags that git-bz-moz supports for bugzilla.mozilla.org; there are more attachment flags available, but listing only the most important ones reduces noise.
Attachment 298132 [details] pushed as 146ec9c - Support for editing attachment flags. Attachment 298134 [details] pushed as da982ce - Allow "multiplicable" attachment flags Attachment 298136 [details] pushed as a1ed1a7 - Add basic attachment flags for bugzilla.mozilla.org
Thanks Owen. Seems like I can finally get rid of my fork :)