Add clearcase integration

Review Request #641 — Created Nov. 17, 2008 and discarded

Information

Review Board SVN (deprecated)
trunk

Reviewers

clearcase integration. add a file clearcase.py under scmtools, add a record in file scmtools\fixtures\initial_data.json.
It works fine in our team.
david
  1. 
      
  2. If this is unnecessary, please remove it. If it will be uncommented in the future, please add a note explaining why it's turned off.
  3. /trunk/reviewboard/scmtools/clearcase.py (Diff revision 1)
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
    This is all vestigial, right?
    1. yes, I had removed it.
  4. Remove this line.
    1. Removed already.
  5. liua6_codeReview isn't something portable, is it?
    1. liua6_codeReview is the view name that had been created using clearcase. I had changed it to a more general name Reviewboard_codeReview.
  6. /trunk/reviewboard/scmtools/clearcase.py (Diff revision 1)
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
    This is all vestigial, right?
    1. Yes, removed already.
  7. No spaces between parentheses and function parameters.
  8. Remove this line.
  9. Remove this.
  10. /trunk/reviewboard/scmtools/clearcase.py (Diff revision 1)
     
     
     
     
     
     
    Python makes it really easy to iterate like this:
    
    for line in lines:
        if not re.match("^\s*$", line):
            clearcase_diff_lines.append(line)
    1. Thanks, This is my first python program:), now i am using for statement.
  11. This reads better as "if not match:"
    1. changed already.
  12. No parentheses around the while condition.  You can also use the for ... in ... syntax to make this a lot more readable.
  13. /trunk/reviewboard/scmtools/clearcase.py (Diff revision 1)
     
     
     
     
    Remove this.
  14. /trunk/reviewboard/scmtools/clearcase.py (Diff revision 1)
     
     
     
     
     
    Indentation here looks like tabs. All indentation should be 4 spaces.
    1. now it's space.
  15. /trunk/reviewboard/scmtools/clearcase.py (Diff revision 1)
     
     
     
     
    Remove this.
  16. Please add spaces around operators.
  17. /trunk/reviewboard/scmtools/clearcase.py (Diff revision 1)
     
     
     
     
    Remove this.
  18. /trunk/reviewboard/scmtools/clearcase.py (Diff revision 1)
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
    This is just leftover from the SVN tool, no?
    1. Yes, I had removed the whole clearcaseparser class, as for there are no needs to override it.
  19. 
      
AA
AA
Review request changed
Change Summary:
1. Made the correspond changed according comments.
2. Delete the ClearCaseParser class as for there is no special case needs override DiffParser'd method.
3. Add more comment about how to used it on windows' platform.
chipx86
  1. Lots of little things that should be cleaned up. Some large things, but also a lot of code that can be simplified with some Pythonisms.
    
    I am wondering, though, why this converts from a Clearcase diff into a standard GNU diff instead of implementing a diff parser. It seems you should be adding a DiffParser subclass that does the work necessary to parse.
    
    What are the differences between Clearcase diffs and standard diffs? We may be able to simplify this code drastically.
    1. It seems that we have another clearcase module up for review that implements a proper diff parser and post-review support. We should see if it's lacking anything that yours provides.
      
      http://reviews.review-board.org/r/653/
  2. trunk/reviewboard/scmtools/clearcase.py (Diff revision 2)
     
     
     
    We can't put code in that's specific to a single platform and requires modification to make it work. What's the reason this can't be used on Windows?
  3. trunk/reviewboard/scmtools/clearcase.py (Diff revision 2)
     
     
    How do these names work? I'm a little concerned about having a hard-coded name here.
  4. trunk/reviewboard/scmtools/clearcase.py (Diff revision 2)
     
     
    The file handle returned from open() must be close()'d or there will be a leak.
  5. trunk/reviewboard/scmtools/clearcase.py (Diff revision 2)
     
     
    Should re-use stre.
  6. trunk/reviewboard/scmtools/clearcase.py (Diff revision 2)
     
     
    Why 100?
  7. trunk/reviewboard/scmtools/clearcase.py (Diff revision 2)
     
     
     
    Only a single blank line between these functions.
  8. trunk/reviewboard/scmtools/clearcase.py (Diff revision 2)
     
     
     
     
     
     
     
     
    Should just return in each case instead of assigning to r.
  9. trunk/reviewboard/scmtools/clearcase.py (Diff revision 2)
     
     
    An empty filename here is confusing. I'm not even sure why this exception is here?
  10. trunk/reviewboard/scmtools/clearcase.py (Diff revision 2)
     
     
     
    Should be one blank line.
  11. trunk/reviewboard/scmtools/clearcase.py (Diff revision 2)
     
     
    "gun" should probably be "gnu"
  12. trunk/reviewboard/scmtools/clearcase.py (Diff revision 2)
     
     
     
     
     
     
    This is better done as:
    
    return DiffParser("\n".join(self.ccdiff_to_gnudiff(data)))
  13. trunk/reviewboard/scmtools/clearcase.py (Diff revision 2)
     
     
    Can you document exactly what this function is doing? It's kind of confusing.
  14. trunk/reviewboard/scmtools/clearcase.py (Diff revision 2)
     
     
    No need for the outer parens.
  15. trunk/reviewboard/scmtools/clearcase.py (Diff revision 2)
     
     
    Indentation looks to be using tabs instead of spaces here.
  16. trunk/reviewboard/scmtools/clearcase.py (Diff revision 2)
     
     
    Do we know for sure it's always \r\n?
  17. trunk/reviewboard/scmtools/clearcase.py (Diff revision 2)
     
     
     
     
     
    This could be better written as:
    
    clearcase_diff_lines = [
        line for line in lines
        if not re.match("^\s*$", line)
    ]
  18. trunk/reviewboard/scmtools/clearcase.py (Diff revision 2)
     
     
     
    The first part of the if statement should always be true, since we've verified it through the condition in the while loop.
  19. trunk/reviewboard/scmtools/clearcase.py (Diff revision 2)
     
     
     
     
     
    When doing multi-line if statements, it's best to do:
    
    if (.... and
        .... and
        ....):
  20. trunk/reviewboard/scmtools/clearcase.py (Diff revision 2)
     
     
     
     
     
     
     
     
     
     
     
     
     
    Indentation is wrong for all this. It should be indented 4 spaces from the if statement.
  21. trunk/reviewboard/scmtools/clearcase.py (Diff revision 2)
     
     
    No need for these parens.
  22. trunk/reviewboard/scmtools/clearcase.py (Diff revision 2)
     
     
     
     
    Indentation seems wrong.
  23. trunk/reviewboard/scmtools/clearcase.py (Diff revision 2)
     
     
     
    These should use \t before the (revision ...) instead of spaces.
    
    Also, the hard-coded "(revision 100)" seems very bad to me. We need to use actual revisions, but made-up ones.
  24. trunk/reviewboard/scmtools/clearcase.py (Diff revision 2)
     
     
    Blank line before this if statement.
  25. trunk/reviewboard/scmtools/clearcase.py (Diff revision 2)
     
     
    These might be better as:
    
    newline = "@@ -%s,0 +%s,%s @@" % (old_start + 1, new_start, new_line_num)
    
    Same with the other ones.
  26. trunk/reviewboard/scmtools/clearcase.py (Diff revision 2)
     
     
    I would do something like:
    
    for i in range(i + 1, i + new_line_num):
        gnu_diff_lines.append("+" + clearcase_diff_lines[i][2:])
  27. trunk/reviewboard/scmtools/clearcase.py (Diff revision 2)
     
     
     
     
     
     
     
     
     
     
     
    Similar to above:
    
    for i in range(i + 1, i + old_line_num):
        gnu_diff_lines.append("-" + clearcase_diff_lines[i][2:])
    
    for i in range(i + 1, i + new_line_num):
        gnu_diff_lines.append("+" + clearcase_diff_lines[i][2:])
  28.