Add local branch information to rbt status

Review Request #7951 — Created Feb. 7, 2016 and submitted

Information

RBTools
master

Reviewers

Modified rbt post to append current local branch to the POST request, modified the rbt status to obtain the saved local branch from the GET request, and altered the formatting of rbt status to show the last local branch that was used to post the review request.

I tested both rbt post and rbt status manually.

rbt post

  • Create branches in both git and bzr repos and do rbt post and ensure that local_branch is added to the review request as extra_data
  • Create bookmark in hg repo and do rbt post and ensure that local_bookmark is added to the review request as extra_data
  • Do an rbt post in and hg repo without specifying a bookmark and ensure that no local_bookmark is not added to the review request as extra data
  • Do an rbt post with an SCM that doesn't have branching/bookmarking capabilities (I used svn) and ensure no unintended extra_data is being added

rbt status

  • Run rbt status in repos that support branching (both git and bzr) and ensure that only the 'Branch' column shows up
  • Run rbt status in repos that support branching (hg) and ensure that only the 'Bookmark' column shows up
  • Run rbt status in a repo that don't support branching/bookmarking (I used svn) and ensure that neither 'Branch' nor 'Bookmark' columns show up
  • Run rbt status --all and ensure that both the 'Branch' and 'Bookmark' columns show up, and also that each branch and bookmark shows up properly associated with the correct review request
  • Make terminal large enough to fit each record of the rbt status output in one line and ensure that it outputs properly
  • Shrink terminal small enough to require word wraps for various records in the rbt status output and ensure that it outputs properly

Description From Last Updated

I think we should print a blank string instead of "None"

daviddavid

I wouldn't mind other opinions on this, it looks like TextTable will try to limit the size of the table …

EV evanhunzinger

This should be extra_data.local_branch.

brenniebrennie

Col: 30 E128 continuation line under-indented for visual indent

reviewbotreviewbot

Col: 30 W503 line break before binary operator

reviewbotreviewbot

Col: 80 E501 line too long (80 > 79 characters)

reviewbotreviewbot

Col: 30 E128 continuation line under-indented for visual indent

reviewbotreviewbot

Col: 30 W503 line break before binary operator

reviewbotreviewbot

Col: 80 E501 line too long (121 > 79 characters)

reviewbotreviewbot

This should just be None, in my opinion.

brenniebrennie

This should just be None, in my opinion.

brenniebrennie

Col: 80 E501 line too long (80 > 79 characters)

reviewbotreviewbot

Col: 30 E113 unexpected indentation

reviewbotreviewbot

Col: 30 E111 indentation is not a multiple of four

reviewbotreviewbot

Col: 30 E111 indentation is not a multiple of four

reviewbotreviewbot

This should just be blank, actually. That way, if a user did have an actual None branch, it wouldnt be …

brenniebrennie

Col: 80 E501 line too long (99 > 79 characters)

reviewbotreviewbot

Col: 80 E501 line too long (102 > 79 characters)

reviewbotreviewbot

Col: 80 E501 line too long (99 > 79 characters)

reviewbotreviewbot

We're not consistent (especially in old code like this file), but docstrings should be in the imperative mood rather than …

daviddavid

This is getting pretty ugly and repetitive. Can we abstract this somehow so we store the table and then print …

daviddavid

Col: 80 E501 line too long (80 > 79 characters)

reviewbotreviewbot

I wasn't sure about this solution, should I be utilizing the SCMClient Capabilities object instead?

EV evanhunzinger

Col: 17 W503 line break before binary operator

reviewbotreviewbot

Col: 17 W503 line break before binary operator

reviewbotreviewbot

Col: 17 E128 continuation line under-indented for visual indent

reviewbotreviewbot

Pretty close. Formatting should be: Returns: bytes: A string with ...

daviddavid

Same here with the "type"

daviddavid

This is a third party import It should be in its own group. Also, you'll have to update setup.py to …

brenniebrennie

Hmm. What happens in the case where a user does --all with both git and hg repos? In that case …

daviddavid

This doesn't handle the can_bookmark case. Perhaps we should just have if 'branch' in request: ?

daviddavid

Dedent this 4 spaces ('local_bookmark' should start on the same column as self.tool.can_bookmark)

daviddavid

Dedent this 2 spaces.

daviddavid

The len fields are no longer required, right?

daviddavid

This is no longer required, right?

daviddavid

Missing trailing comma.

brenniebrennie

This can be simplified a bit. We don't need to have the not has_* checks in there (we can always …

daviddavid

If you reorder this a bit, it becomes simpler: request_stats = { 'status': status, 'summary': 'r/%s - %s' % (request.id, …

daviddavid

Col: 68 E502 the backslash is redundant between brackets

reviewbotreviewbot

Col: 59 E703 statement ends with a semicolon

reviewbotreviewbot

Col: 17 E128 continuation line under-indented for visual indent

reviewbotreviewbot

This should be grouped with the other 3rd party imports (the texttable one)

daviddavid

Is it possible to skip all this and just pass in the max width to the Texttable constructor?

daviddavid

Please keep this is alphabetical order.

daviddavid

Col: 80 E501 line too long (80 > 79 characters)

reviewbotreviewbot
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        rbtools/commands/status.py
        rbtools/commands/post.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        rbtools/commands/status.py
        rbtools/commands/post.py
    
    
  2. rbtools/commands/status.py (Diff revision 1)
     
     
    Col: 30
     E128 continuation line under-indented for visual indent
    
  3. rbtools/commands/status.py (Diff revision 1)
     
     
    Col: 30
     W503 line break before binary operator
    
  4. rbtools/commands/status.py (Diff revision 1)
     
     
    Col: 80
     E501 line too long (80 > 79 characters)
    
  5. rbtools/commands/status.py (Diff revision 1)
     
     
    Col: 30
     E128 continuation line under-indented for visual indent
    
  6. rbtools/commands/status.py (Diff revision 1)
     
     
    Col: 30
     W503 line break before binary operator
    
  7. rbtools/commands/status.py (Diff revision 1)
     
     
    Col: 80
     E501 line too long (121 > 79 characters)
    
  8. 
      
brennie
  1. 
      
  2. rbtools/commands/post.py (Diff revision 1)
     
     

    This should be extra_data.local_branch.

    1. Actually, I forgot that extra_data__ gets converted to extra_data. in request methods, so this is fine.

  3. rbtools/commands/status.py (Diff revision 1)
     
     

    This should just be None, in my opinion.

    1. RB filed two issues at once. This must be a bug :(

  4. rbtools/commands/status.py (Diff revision 1)
     
     

    This should just be None, in my opinion.

  5. 
      
EV
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        rbtools/commands/status.py
        rbtools/commands/post.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        rbtools/commands/status.py
        rbtools/commands/post.py
    
    
  2. rbtools/commands/status.py (Diff revision 2)
     
     
    Col: 80
     E501 line too long (80 > 79 characters)
    
  3. 
      
EV
reviewbot
  1. Tool: PEP8 Style Checker
    Processed Files:
        rbtools/commands/status.py
        rbtools/commands/post.py
    
    
  2. rbtools/commands/status.py (Diff revision 3)
     
     
    Col: 30
     E113 unexpected indentation
    
  3. rbtools/commands/status.py (Diff revision 3)
     
     
    Col: 30
     E111 indentation is not a multiple of four
    
  4. rbtools/commands/status.py (Diff revision 3)
     
     
    Col: 30
     E111 indentation is not a multiple of four
    
  5. 
      
EV
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        rbtools/commands/status.py
        rbtools/commands/post.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        rbtools/commands/status.py
        rbtools/commands/post.py
    
    
  2. 
      
brennie
  1. 
      
  2. rbtools/commands/status.py (Diff revision 4)
     
     

    This should just be blank, actually. That way, if a user did have an actual None branch, it wouldnt be confusing

  3. 
      
EV
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        rbtools/commands/status.py
        rbtools/commands/post.py
        rbtools/clients/bazaar.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        rbtools/commands/status.py
        rbtools/commands/post.py
        rbtools/clients/bazaar.py
    
    
  2. rbtools/commands/status.py (Diff revision 5)
     
     
    Col: 80
     E501 line too long (99 > 79 characters)
    
  3. rbtools/commands/status.py (Diff revision 5)
     
     
    Col: 80
     E501 line too long (102 > 79 characters)
    
  4. rbtools/commands/status.py (Diff revision 5)
     
     
    Col: 80
     E501 line too long (99 > 79 characters)
    
  5. 
      
EV
reviewbot
  1. Tool: PEP8 Style Checker
    Processed Files:
        rbtools/commands/status.py
        rbtools/commands/post.py
        rbtools/clients/bazaar.py
    
    
    
    Tool: Pyflakes
    Processed Files:
        rbtools/commands/status.py
        rbtools/commands/post.py
        rbtools/clients/bazaar.py
    
    
  2. 
      
david
  1. 
      
  2. rbtools/clients/bazaar.py (Diff revision 6)
     
     

    We're not consistent (especially in old code like this file), but docstrings should be in the imperative mood rather than the passive ("Return the ..." vs. "Returns ...")

    Can you also add the new "Returns:" section as per https://www.reviewboard.org/docs/codebase/dev/docs/writing-codebase-docs/#returns ?

  3. rbtools/commands/status.py (Diff revision 6)
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     

    This is getting pretty ugly and repetitive. Can we abstract this somehow so we store the table and then print it out in a more generic way?

    1. What about something like pretty table ?

    2. I was taking a look at both text table and pretty table, I'll try them out tonight and see how well they work out. It will also clean up the code that I'm working on right now for handling rbt status for SCMClients that don't have branch information since I don't want to output that branch column if that SCM doesn't have branch capabilities.

      How do I handle using external python libraries in Review Board? I'm used to using node.JS where you can run npm install ___ --save or modifying the dependencies.json file manually, I'm not familiar with how to do it for this project though.

      Note: I forgot to submit this message, left it as a draft by accident!

  4. 
      
EV
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        rbtools/commands/status.py
        rbtools/clients/mercurial.py
        rbtools/commands/post.py
        rbtools/clients/bazaar.py
        rbtools/clients/git.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        rbtools/commands/status.py
        rbtools/clients/mercurial.py
        rbtools/commands/post.py
        rbtools/clients/bazaar.py
        rbtools/clients/git.py
    
    
  2. rbtools/commands/post.py (Diff revision 7)
     
     
    Col: 80
     E501 line too long (80 > 79 characters)
    
  3. rbtools/commands/status.py (Diff revision 7)
     
     
    Col: 17
     W503 line break before binary operator
    
  4. rbtools/commands/status.py (Diff revision 7)
     
     
    Col: 17
     W503 line break before binary operator
    
  5. rbtools/commands/status.py (Diff revision 7)
     
     
    Col: 17
     E128 continuation line under-indented for visual indent
    
  6. 
      
EV
  1. 
      
  2. rbtools/commands/status.py (Diff revision 7)
     
     

    I wasn't sure about this solution, should I be utilizing the SCMClient Capabilities object instead?

    1. The capabilities object is sent by the server, and represents what's available server-side. We should instead add a new can_something property to SCMClient (there are several there already) and override it in the tools which support it.

    2. OK, I'll give that a go.

  3. 
      
EV
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        rbtools/commands/status.py
        rbtools/clients/mercurial.py
        rbtools/commands/post.py
        rbtools/clients/bazaar.py
        rbtools/clients/git.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        rbtools/commands/status.py
        rbtools/clients/mercurial.py
        rbtools/commands/post.py
        rbtools/clients/bazaar.py
        rbtools/clients/git.py
    
    
  2. 
      
EV
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        rbtools/commands/status.py
        rbtools/commands/post.py
        rbtools/clients/__init__.py
        rbtools/clients/mercurial.py
        rbtools/clients/git.py
        rbtools/clients/bazaar.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        rbtools/commands/status.py
        rbtools/commands/post.py
        rbtools/clients/__init__.py
        rbtools/clients/mercurial.py
        rbtools/clients/git.py
        rbtools/clients/bazaar.py
    
    
  2. 
      
EV
david
  1. 
      
  2. rbtools/clients/git.py (Diff revision 9)
     
     
     
     

    Pretty close. Formatting should be:

    Returns:
        bytes:
        A string with ...
    
  3. rbtools/clients/mercurial.py (Diff revision 9)
     
     
     

    Same here with the "type"

  4. rbtools/commands/status.py (Diff revision 9)
     
     
     
     
     

    Hmm. What happens in the case where a user does --all with both git and hg repos? In that case I think we'll always say "Bookmark" even for things that are branches.

    Perhaps just always call it "branch"? "local branch"?

    Anyone else have a suggestion?

    1. I didn't know of that ability, does --all still just look at the same directory so it handles the case where the user has two repos in the same directory? That seems to complicate any functionality in RBTools where self.tool is utilized, which SCMClient would be initialized to self.tool?

    2. Based on my reading of the code (and understanding of what the feature does), it doesn't filter based on the current directory. In that case, the tool and repository are initialized to match the current directory but not actually used. We should probably change it so those don't get initialized if they're not needed.

  5. rbtools/commands/status.py (Diff revision 9)
     
     
     

    This doesn't handle the can_bookmark case. Perhaps we should just have if 'branch' in request: ?

    1. You're right, this was a bit of an oversight that worked because I added can_branch to the hg SCMClient which is unrelated but allowing this to work. I'll switch that over.

    2. I realized that there is a case where there can be a review request from an SCMClient that has branching/bookmarking capabilities (so they have the third header, therefore require three elements in each row). If that request doesn't have a bookmark associated with it, it won't be in the request data from the API call, meaning there won't be a 'branch' property in the request. So how about for this I add the can_bookmark in the if statement and still use the .get() function to return None if it doesn't exist, but will at least append as a value to the row?

  6. rbtools/commands/status.py (Diff revision 9)
     
     

    Dedent this 4 spaces ('local_bookmark' should start on the same column as self.tool.can_bookmark)

  7. rbtools/commands/status.py (Diff revision 9)
     
     

    Dedent this 2 spaces.

    1. Just out of curiosity, why is this one only 2 spaces and the one above 4 spaces?

    2. Never mind, I didn't take into consideration the extra characters in elif.

  8. rbtools/commands/status.py (Diff revision 9)
     
     
     

    The len fields are no longer required, right?

    1. You're right, I'll get rid of those.

  9. rbtools/commands/status.py (Diff revision 9)
     
     

    This is no longer required, right?

  10. 
      
brennie
  1. 
      
  2. rbtools/commands/status.py (Diff revision 9)
     
     

    This is a third party import It should be in its own group. Also, you'll have to update setup.py to add it as a dependency.

    1. Is this just done by appending a package name to the install_requires list?

    2. Yes

  3. 
      
EV
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        rbtools/commands/status.py
        rbtools/commands/post.py
        rbtools/clients/__init__.py
        rbtools/clients/mercurial.py
        rbtools/clients/git.py
        rbtools/clients/bazaar.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        rbtools/commands/status.py
        rbtools/commands/post.py
        rbtools/clients/__init__.py
        rbtools/clients/mercurial.py
        rbtools/clients/git.py
        rbtools/clients/bazaar.py
    
    
  2. 
      
EV
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        rbtools/commands/status.py
        rbtools/commands/post.py
        rbtools/clients/__init__.py
        rbtools/clients/mercurial.py
        rbtools/clients/git.py
        rbtools/clients/bazaar.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        rbtools/commands/status.py
        rbtools/commands/post.py
        rbtools/clients/__init__.py
        rbtools/clients/mercurial.py
        rbtools/clients/git.py
        rbtools/clients/bazaar.py
    
    
  2. 
      
EV
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        rbtools/commands/status.py
        rbtools/commands/post.py
        rbtools/clients/__init__.py
        rbtools/clients/mercurial.py
        rbtools/clients/git.py
        rbtools/clients/bazaar.py
        setup.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        rbtools/commands/status.py
        rbtools/commands/post.py
        rbtools/clients/__init__.py
        rbtools/clients/mercurial.py
        rbtools/clients/git.py
        rbtools/clients/bazaar.py
        setup.py
    
    
  2. 
      
brennie
  1. Can you attach some sample output of the table as a screenshot or text?

    Also, this is probably worth removing the [WIP] tag on.

    1. I uploaded three images from three different scenarios. Let me know if you want the decorators to look different or anything!

  2. setup.py (Diff revision 12)
     
     

    Missing trailing comma.

  3. 
      
EV
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        rbtools/commands/status.py
        rbtools/commands/post.py
        rbtools/clients/__init__.py
        rbtools/clients/mercurial.py
        rbtools/clients/git.py
        rbtools/clients/bazaar.py
        setup.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        rbtools/commands/status.py
        rbtools/commands/post.py
        rbtools/clients/__init__.py
        rbtools/clients/mercurial.py
        rbtools/clients/git.py
        rbtools/clients/bazaar.py
        setup.py
    
    
  2. 
      
david
  1. This is looking pretty good. You said you uploaded three examples of output but I don't see them.

    1. I left it as a draft again, sorry!

  2. rbtools/commands/status.py (Diff revision 13)
     
     
     
     
     
     
     
     
     

    This can be simplified a bit. We don't need to have the not has_* checks in there (we can always just set to True if it's present). We can also skip the early break because it doesn't buy very much.

    for request in request_stats:
        if 'branch' in request:
            has_branches = True
    
        if 'bookmark' in request:
            has_bookmarks = True
    
    1. OK, my idea was that the not has_* checks could save some time in the and conditional, but you're right that the savings are minimal at the expense of less consise code.

  3. rbtools/commands/status.py (Diff revision 13)
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     

    If you reorder this a bit, it becomes simpler:

    request_stats = {
        'status': status,
        'summary': 'r/%s - %s' % (request.id, request.summary),
    }
    
    if 'local_branch' in request.extra_data:
        request_stats['branch'] = \
            request.extra_data['local_branch']
    
    if 'local_bookmark' in request.extra_data:
        request_stats['bookmark'] = \
            request.extra_data['local_bookmark']
    
  4. 
      
EV
EV
  1. 
      
  2. I wouldn't mind other opinions on this, it looks like TextTable will try to limit the size of the table (and therefore columns) if you don't manually set size constraints on the column, which leads to crunched up columns like this in the --all case. I was thinking of determining column size at run time based off the largest values, but then that could mean really wide tables which probably won't print well if someone is running a small console.

    1. Can we use https://pypi.python.org/pypi/backports.shutil_get_terminal_size to determine the width of the console and use that for the max-width of the table?

  3. 
      
david
  1. 
      
  2. I think we should print a blank string instead of "None"

  3. 
      
EV
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        rbtools/commands/status.py
        rbtools/commands/post.py
        rbtools/clients/__init__.py
        rbtools/clients/mercurial.py
        rbtools/clients/git.py
        rbtools/clients/bazaar.py
        setup.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        rbtools/commands/status.py
        rbtools/commands/post.py
        rbtools/clients/__init__.py
        rbtools/clients/mercurial.py
        rbtools/clients/git.py
        rbtools/clients/bazaar.py
        setup.py
    
    
  2. 
      
EV
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        rbtools/commands/status.py
        rbtools/commands/post.py
        rbtools/clients/__init__.py
        rbtools/clients/mercurial.py
        rbtools/clients/git.py
        rbtools/clients/bazaar.py
        setup.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        rbtools/commands/status.py
        rbtools/commands/post.py
        rbtools/clients/__init__.py
        rbtools/clients/mercurial.py
        rbtools/clients/git.py
        rbtools/clients/bazaar.py
        setup.py
    
    
  2. rbtools/commands/status.py (Diff revision 15)
     
     
    Col: 68
     E502 the backslash is redundant between brackets
    
  3. rbtools/commands/status.py (Diff revision 15)
     
     
    Col: 59
     E703 statement ends with a semicolon
    
  4. rbtools/commands/status.py (Diff revision 15)
     
     
    Col: 17
     E128 continuation line under-indented for visual indent
    
  5. 
      
EV
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        rbtools/commands/status.py
        rbtools/commands/post.py
        rbtools/clients/__init__.py
        rbtools/clients/mercurial.py
        rbtools/clients/git.py
        rbtools/clients/bazaar.py
        setup.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        rbtools/commands/status.py
        rbtools/commands/post.py
        rbtools/clients/__init__.py
        rbtools/clients/mercurial.py
        rbtools/clients/git.py
        rbtools/clients/bazaar.py
        setup.py
    
    
  2. 
      
david
  1. 
      
  2. rbtools/commands/status.py (Diff revision 16)
     
     

    This should be grouped with the other 3rd party imports (the texttable one)

  3. rbtools/commands/status.py (Diff revision 16)
     
     
     
     
     
     
     

    Is it possible to skip all this and just pass in the max width to the Texttable constructor?

    1. Do you mean to just solve for the max once when I put the values in col_widths? (ex. combining line 54 and 61)

    2. Based on my reading of the texttable code, if you pass in the number of columns to the constructor [ table = tt.Texttable(get_terminal_size().columns) ], it should do its own calculation to try to size the columns nicely.

    3. Ah, you're right! I should have read the documentation more closely, would have saved me some time.

  4. setup.py (Diff revision 16)
     
     

    Please keep this is alphabetical order.

  5. 
      
EV
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        rbtools/commands/status.py
        rbtools/commands/post.py
        rbtools/clients/__init__.py
        rbtools/clients/mercurial.py
        rbtools/clients/git.py
        rbtools/clients/bazaar.py
        setup.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        rbtools/commands/status.py
        rbtools/commands/post.py
        rbtools/clients/__init__.py
        rbtools/clients/mercurial.py
        rbtools/clients/git.py
        rbtools/clients/bazaar.py
        setup.py
    
    
  2. rbtools/commands/status.py (Diff revision 17)
     
     
    Col: 80
     E501 line too long (80 > 79 characters)
    
  3. 
      
EV
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        rbtools/commands/status.py
        rbtools/commands/post.py
        rbtools/clients/__init__.py
        rbtools/clients/mercurial.py
        rbtools/clients/git.py
        rbtools/clients/bazaar.py
        setup.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        rbtools/commands/status.py
        rbtools/commands/post.py
        rbtools/clients/__init__.py
        rbtools/clients/mercurial.py
        rbtools/clients/git.py
        rbtools/clients/bazaar.py
        setup.py
    
    
  2. 
      
brennie
  1. This looks good to me. Can you add some testing information?

  2. 
      
EV
brennie
  1. Ship It!
  2. 
      
EV
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to master (63b91e6)
Loading...