Support SVN 1.9 (nonexistent) diffs with relocation info.

Review Request #8146 — Created May 6, 2016 and submitted

Information

Review Board

Reviewers

Subversion 1.9 introduced the '(nonexistent)' revision as part of the revision string for newly created files in patches, where earlier versions create '(revision 0)' instead.

Revision string handling must cover some variants and shall extract relocation information -if any- (when creating svn diffs between branches), handle a date string (created by svnlook diff) and extract the revision number or the '(nonexistent)' expression.

The current support in reviewboad for '(nonexistent)' revision specifier does not handle diffs created between branches and does not handle diffs created by svnlook with additional date information.

This patch merges the code paths for subversion 1.9 ('nonexistent') revision specifiers and the already existing revision parser regex.

Patches created with earlier subversion clients are properly handled, as well.

A new unit test is included for the '(nonexistent)' revision string as seen in diffs between branches.

Uploading a SVN 1.9 diff with relocation information is successful.
Ran unittests.

Description From Last Updated

Retain comments to indicate the languages.

gmyersgmyers

What happened to group 3? Can we use (?: like we did before so we don't lose a group number?

chipx86chipx86

Why the None? We just didn't have a group matching? Shouldn't there have been something there at least? Should also …

chipx86chipx86

We should have a new unit test for this, rather than reusing this one. This is really about the "nonexistent" …

chipx86chipx86

Col: 1 W191 indentation contains tabs

reviewbotreviewbot

Col: 1 E101 indentation contains mixed spaces and tabs

reviewbotreviewbot

Col: 1 E101 indentation contains mixed spaces and tabs

reviewbotreviewbot

Col: 1 E101 indentation contains mixed spaces and tabs

reviewbotreviewbot

Col: 1 W191 indentation contains tabs

reviewbotreviewbot

Col: 1 W191 indentation contains tabs

reviewbotreviewbot

Col: 1 W191 indentation contains tabs

reviewbotreviewbot

Col: 1 E101 indentation contains mixed spaces and tabs

reviewbotreviewbot

Col: 1 W191 indentation contains tabs

reviewbotreviewbot

Col: 1 W191 indentation contains tabs

reviewbotreviewbot

Col: 1 W191 indentation contains tabs

reviewbotreviewbot

Col: 1 E101 indentation contains mixed spaces and tabs

reviewbotreviewbot

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

reviewbotreviewbot

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

reviewbotreviewbot

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

reviewbotreviewbot

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

reviewbotreviewbot

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

reviewbotreviewbot

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

reviewbotreviewbot

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

reviewbotreviewbot

information, not informationen.

gmyersgmyers
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        reviewboard/scmtools/tests.py
        reviewboard/scmtools/svn/__init__.py
    
    
  2. 
      
gmyers
  1. My regex-fu is not that strong, but this seems reasonable to me.  Thanks for the new unit test.
    
    I believe this also resolves #4374 (https://hellosplat.com/s/beanbag/tickets/4374/)
    1. Indeet, #4374 has the same root cause.

      The regex-fu is not that dramatic.

      just imagine the revision string to be composed of up to three parts

      "(.../trunk/foo.c) SOME_DATE_HERE (revision indicator)"
      ^^^^^^^^^^^^^^^^^^ ~~~~~~ ^^^^^^^^^^^^^^^^^^^^
      (1) (2) (3)
      1. is optional and matches the relative location to the SVN root url.
      2. SOME_DATE_HERE is self describing, but optional
      3. the revision indicator placed between braces () is mandatory.
      - This can be a (localizable) string 'revision' followed by a number or
      - a (localizable) string equivalent for 'nonexistent'.

      The regex matches the the relative location (if any) and matches the revision number or the 'nonexistent'. Reviewboard needs to know if this is a new file (PRE_CREATION), which is true whenever the revision number '0' is detected or the 'nonexistent'-part of the regex matches.

      This is what the patch does.

      I'm going to fix the comments soon.

  2. reviewboard/scmtools/svn/__init__.py (Diff revision 1)
     
     
     
    Show all issues
    Retain comments to indicate the languages.
  3. 
      
chipx86
  1. Does this retain all support for all prior versions?

    The description in the review request (which we'll use for the commit message) should ideally contain more information on what was broken, how it's been fixed, and note that all prior versions are supported (assuming they are). We have a write-up on what we like to see at https://www.reviewboard.org/docs/codebase/dev/writing-good-descriptions/.

    Some good information to include would be the older format for these types of revision indicators in diffs, and the newer format, for comparison purposes.

    The info you have on the regex in your other reply would be good to have in the source code, so it's more clear when reviewing and down the road when further changes are made. (Really, we should have been documenting all the formats this whole time..)

    1. I'll adjust the source and the review description including your suggestions. :-)

      It's a good point to update format specifications of what the svn diffs may look like and what is handled by reviewboard. So, I'm looking into this...

    2. Review description updated.

  2. reviewboard/scmtools/svn/__init__.py (Diff revision 1)
     
     
    Show all issues

    What happened to group 3? Can we use (?: like we did before so we don't lose a group number?

    1. I'm looking into this. Maybe there is another regex trick waiting out there for this particular problem ...

    2. I would prefer to use the updated regex, and have it properly commented. So we will have group(4).

  3. reviewboard/scmtools/svn/__init__.py (Diff revision 1)
     
     
    Show all issues

    Why the None? We just didn't have a group matching? Shouldn't there have been something there at least?

    Should also use a tuple instead of a list here, as it's lighter-weight.

    1. None it is as group(4) only matches the revision number. In case of the '(nonexistent)' string, this part of the regex does not match, so the result will be 'None'. But group(3) will hold the '(nonextistent)' string. group(3) will contain the localized string, so the only useful check would be to check whether group(3) is not None.

      After all this seemed logical to me, as there is literally no revision for a file in the state 'PRE_CREATION'.

    2. Ah, I see. Okay, this would be a great comment to have in there. Basically, breaking down the groups of the regex and the expectations (since that regex is pretty massive).

      Thanks for the contribution, btw, and being so responsive and open to the feedback! :)

  4. reviewboard/scmtools/tests.py (Diff revision 1)
     
     
     
     
     
    Show all issues

    We should have a new unit test for this, rather than reusing this one. This is really about the "nonexistent" string alone, but a new test would be about that + branch names. It could also include the localized versions, to verify.

    Can you think of any other tests that would help prove this change? Other cases we're not already covering?

    1. I will create a new unittest for this.

  5. 
      
HO
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        reviewboard/scmtools/tests.py
        reviewboard/scmtools/svn/__init__.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        reviewboard/scmtools/tests.py
        reviewboard/scmtools/svn/__init__.py
    
    
  2. reviewboard/scmtools/svn/__init__.py (Diff revision 2)
     
     
    Show all issues
    Col: 1
     W191 indentation contains tabs
    
  3. reviewboard/scmtools/svn/__init__.py (Diff revision 2)
     
     
    Show all issues
    Col: 1
     E101 indentation contains mixed spaces and tabs
    
  4. reviewboard/scmtools/svn/__init__.py (Diff revision 2)
     
     
    Show all issues
    Col: 1
     E101 indentation contains mixed spaces and tabs
    
  5. reviewboard/scmtools/svn/__init__.py (Diff revision 2)
     
     
    Show all issues
    Col: 1
     E101 indentation contains mixed spaces and tabs
    
  6. reviewboard/scmtools/svn/__init__.py (Diff revision 2)
     
     
    Show all issues
    Col: 1
     W191 indentation contains tabs
    
  7. reviewboard/scmtools/svn/__init__.py (Diff revision 2)
     
     
    Show all issues
    Col: 1
     W191 indentation contains tabs
    
  8. reviewboard/scmtools/svn/__init__.py (Diff revision 2)
     
     
    Show all issues
    Col: 1
     W191 indentation contains tabs
    
  9. reviewboard/scmtools/svn/__init__.py (Diff revision 2)
     
     
    Show all issues
    Col: 1
     E101 indentation contains mixed spaces and tabs
    
  10. reviewboard/scmtools/svn/__init__.py (Diff revision 2)
     
     
    Show all issues
    Col: 1
     W191 indentation contains tabs
    
  11. reviewboard/scmtools/svn/__init__.py (Diff revision 2)
     
     
    Show all issues
    Col: 1
     W191 indentation contains tabs
    
  12. reviewboard/scmtools/svn/__init__.py (Diff revision 2)
     
     
    Show all issues
    Col: 1
     W191 indentation contains tabs
    
  13. reviewboard/scmtools/svn/__init__.py (Diff revision 2)
     
     
    Show all issues
    Col: 1
     E101 indentation contains mixed spaces and tabs
    
  14. reviewboard/scmtools/tests.py (Diff revision 2)
     
     
    Show all issues
    Col: 80
     E501 line too long (82 > 79 characters)
    
  15. reviewboard/scmtools/tests.py (Diff revision 2)
     
     
    Show all issues
    Col: 80
     E501 line too long (82 > 79 characters)
    
  16. reviewboard/scmtools/tests.py (Diff revision 2)
     
     
    Show all issues
    Col: 80
     E501 line too long (99 > 79 characters)
    
  17. reviewboard/scmtools/tests.py (Diff revision 2)
     
     
    Show all issues
    Col: 80
     E501 line too long (83 > 79 characters)
    
  18. 
      
HO
reviewbot
  1. Tool: PEP8 Style Checker
    Processed Files:
        reviewboard/scmtools/tests.py
        reviewboard/scmtools/svn/__init__.py
    
    
  2. reviewboard/scmtools/tests.py (Diff revision 3)
     
     
    Show all issues
    Col: 13
     E128 continuation line under-indented for visual indent
    
  3. reviewboard/scmtools/tests.py (Diff revision 3)
     
     
    Show all issues
    Col: 13
     E128 continuation line under-indented for visual indent
    
  4. reviewboard/scmtools/tests.py (Diff revision 3)
     
     
    Show all issues
    Col: 13
     E128 continuation line under-indented for visual indent
    
  5. 
      
HO
reviewbot
  1. Tool: PEP8 Style Checker
    Processed Files:
        reviewboard/scmtools/tests.py
        reviewboard/scmtools/svn/__init__.py
    
    
  2. 
      
gmyers
  1. 
      
  2. reviewboard/scmtools/tests.py (Diff revision 4)
     
     
    Show all issues
    information, not informationen.
    1. "Informationen" is German ...

    2. It doesn't appear this test is specific to German, though. Docstrings should be in English, and if they are about a word in another language (or about any string at all), the string in question should be in quotes.

  3. 
      
HO
reviewbot
  1. Tool: PEP8 Style Checker
    Processed Files:
        reviewboard/scmtools/tests.py
        reviewboard/scmtools/svn/__init__.py
    
    
  2. 
      
gmyers
  1. Ship It!
  2. 
      
HO
Review request changed
Status:
Completed
Change Summary:
Pushed to release-2.0.x (33081fb)