Fix issues with successive calls to .create() or .update() on resources.

Review Request #5269 — Created Jan. 16, 2014 and submitted

Information

RBTools
release-0.5.x

Reviewers

Fix issues with successive calls to .create() or .update() on resources.

The create and update methods had a parameter data which had a default value
of {}. In the body of these methods, we used data.update(...), which would
write to that default value. This means that successive calls would include
data that wasn't intended.

This was hit when using 'rbt post -u CLN' to update a public review request
with a perforce repository. We'd update the review request resource with
'changenum', and then try to update the draft with 'public', but that would end
up also sending 'changenum' to the draft resource, which doesn't have that
attribute.

Reproduced the case in the bug. After this fix, I can use 'rbt post -u CLN' to
update and publish a review request all in one go.

Description From Last Updated

Blank line between.

SM smacleod
chipx86
  1. Ship It!
  2. 
      
david
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to release-0.5.x (3f2e135).
SM
  1. Just a couple nits. Ship-It with the updated spacing and your call on the dict updating.

  2. rbtools/api/resource.py (Diff revision 1)
     
     
     
     
     
     
     
     

    This fixes the current bug, but also modifies the dictionary passed into data.

    Maybe we should switch to:
    if data in None:
    data = {}

    kwargs.update(data)
    
    for name, value in kwargs.iteritems():
        ...
    

    I'll leave if up to you to decide if we want the passed in dict to be modified.

  3. rbtools/api/resource.py (Diff revision 1)
     
     
     
    Show all issues

    Blank line between.

  4. 
      
Loading...