Support for multi commit review requests in patch

Review Request #7175 — Created April 6, 2015 and submitted

Information

RBTools
dvcs
afbd97f...

Reviewers

The patch command now supports applying review requests with commit
history. If requested via command line arguments, each commit in the
review request will be applied in sequence on the current branch,
optionally committing each patch. The default behaviour is to replicate
what ever format of review request was uploaded, but this can be
overridden via flags.

Ran unit tests.

Manually tested the following against review requests with multiple
commits:

  • Ran rbt patch. The commits were not committed. The output of
    git diff was correct.
  • Ran rbt patch -C. The commits were all created client side. The
    output of git diff was correct.
  • Ran rbt patch -S. The commits were not committed. The output of
    git diff was correct. Verified via the --debug flag that we only
    request the condensed diff from the server.
  • Ran rbt patch -SC against a review request with multiple commits.
    The resulting commit was of the old format (description, testing done,
    bugs fixed, etc.).

Manually tested the following against review request without multiple
commits:

  • Ran rbt patch. No commits were created. The output of git diff
    was correct.
  • Ran rbt patch -C. One commit was created and it was of the old
    format (as specified above). The output of git diff was correct.
  • Ran rbt patch -SC. Same behaviour of rbt patch -C.
Description From Last Updated

This should use the new template stuff, no?

daviddavid

This should probably not say "yields" (since that implies a generator). How about something like a list of history entry …

daviddavid

This is assuming a single page of results. You should look at how we iterate over repositories in order to …

daviddavid

I don't think we need to use &= here (or even define success outside of the for loop) because when …

daviddavid

I don't think you need to use the quotes in here, since the shell isn't parsing arguments.

daviddavid

Shouldn't -u and the author be separate arguments?

daviddavid

There's no reason for this format operation now. Just pass in author.

daviddavid

How about wrapping this as: with_history = (should_commit and self.should_use_history(tool, server_url))

daviddavid

Indentation here is crazy. The arguments should just be 4 spaces from the previous indent level, not 20.

daviddavid

How about doing: if not success: raise CommandError(...) if should_commit: ... That way you can un-indent everything one level.

daviddavid
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        rbtools/commands/patch.py
        rbtools/api/resource.py
        rbtools/clients/git.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        rbtools/commands/patch.py
        rbtools/api/resource.py
        rbtools/clients/git.py
    
    
  2. 
      
brennie
reviewbot
  1. Tool: PEP8 Style Checker
    Processed Files:
        rbtools/commands/land.py
        rbtools/clients/mercurial.py
        rbtools/api/resource.py
        rbtools/clients/git.py
        rbtools/commands/patch.py
    
    
    
    Tool: Pyflakes
    Processed Files:
        rbtools/commands/land.py
        rbtools/clients/mercurial.py
        rbtools/api/resource.py
        rbtools/clients/git.py
        rbtools/commands/patch.py
    
    
  2. 
      
brennie
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        rbtools/commands/land.py
        rbtools/clients/mercurial.py
        rbtools/api/resource.py
        rbtools/clients/git.py
        rbtools/commands/patch.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        rbtools/commands/land.py
        rbtools/clients/mercurial.py
        rbtools/api/resource.py
        rbtools/clients/git.py
        rbtools/commands/patch.py
    
    
  2. 
      
david
  1. 
      
  2. rbtools/api/resource.py (Diff revision 3)
     
     
     
    Show all issues

    This should use the new template stuff, no?

    1. Once that lands, I'll put up a new patch to reconcile this.

  3. rbtools/commands/patch.py (Diff revision 3)
     
     
     
    Show all issues

    This should probably not say "yields" (since that implies a generator). How about something like a list of history entry (diff, metadata) tuples?

    1. Oops! This originally was a generator so that is how it crept through.

  4. rbtools/commands/patch.py (Diff revision 3)
     
     
     
     
     
    Show all issues

    This is assuming a single page of results. You should look at how we iterate over repositories in order to fetch all pages.

  5. rbtools/commands/patch.py (Diff revision 3)
     
     
    Show all issues

    I don't think we need to use &= here (or even define success outside of the for loop) because when the result of this is False, you raise a CommandError.

  6. 
      
brennie
brennie
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        rbtools/commands/land.py
        rbtools/clients/mercurial.py
        rbtools/api/resource.py
        rbtools/clients/git.py
        rbtools/commands/patch.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        rbtools/commands/land.py
        rbtools/clients/mercurial.py
        rbtools/api/resource.py
        rbtools/clients/git.py
        rbtools/commands/patch.py
    
    
  2. 
      
david
  1. 
      
  2. rbtools/clients/git.py (Diff revision 4)
     
     
    Show all issues

    I don't think you need to use the quotes in here, since the shell isn't parsing arguments.

  3. rbtools/clients/mercurial.py (Diff revision 4)
     
     
    Show all issues

    Shouldn't -u and the author be separate arguments?

  4. rbtools/commands/patch.py (Diff revision 4)
     
     
     
    Show all issues

    How about wrapping this as:

    with_history = (should_commit and
                    self.should_use_history(tool, server_url))
    
  5. rbtools/commands/patch.py (Diff revision 4)
     
     
    Show all issues

    How about doing:

    if not success:
        raise CommandError(...)
    
    if should_commit:
        ...
    

    That way you can un-indent everything one level.

  6. 
      
brennie
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        rbtools/commands/land.py
        rbtools/clients/mercurial.py
        rbtools/api/resource.py
        rbtools/clients/git.py
        rbtools/commands/patch.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        rbtools/commands/land.py
        rbtools/clients/mercurial.py
        rbtools/api/resource.py
        rbtools/clients/git.py
        rbtools/commands/patch.py
    
    
  2. 
      
david
  1. 
      
  2. rbtools/clients/mercurial.py (Diff revisions 4 - 5)
     
     
    Show all issues

    There's no reason for this format operation now. Just pass in author.

  3. rbtools/commands/patch.py (Diff revisions 4 - 5)
     
     
     
     
    Show all issues

    Indentation here is crazy. The arguments should just be 4 spaces from the previous indent level, not 20.

  4. 
      
brennie
reviewbot
  1. Tool: PEP8 Style Checker
    Processed Files:
        rbtools/commands/land.py
        rbtools/clients/mercurial.py
        rbtools/api/resource.py
        rbtools/clients/git.py
        rbtools/commands/patch.py
    
    
    
    Tool: Pyflakes
    Processed Files:
        rbtools/commands/land.py
        rbtools/clients/mercurial.py
        rbtools/api/resource.py
        rbtools/clients/git.py
        rbtools/commands/patch.py
    
    
  2. 
      
david
  1. Ship It!
  2. 
      
brennie
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to dvcs (80debfe)
Loading...