Add Perforce submitted changelist support to post-review.

Review Request #158 — Created Oct. 1, 2007 and submitted

Information

Review Board SVN (deprecated)

Reviewers

- Support submitted changelists in Perforce.
- Silence subversion warning message when not using subversion.
- Fix some minor bugs (improperly referenced variables).
- Verify change number is an integer and give a friendly error message.
- Support BSD style diff timestamps.
Posted pending and submitted changelists in Perforce.

Posted a normal change in subversion (this change, in fact).

Tested on FreeBSD (hence the BSD support), but have not tested on Linux.  Should not be a factor, I just don't have a Linux box handy to test on.
chipx86
  1. This is looking pretty good. Complex, but good ;). I'd like this to be thoroughly tested before it goes in. I'll try to start using it at work for a while.
    1. Thanks, feel free to ask any questions you have about any of the changes, since there are a lot of them.  We could also break it into multiple changes if that's more digestible.
  2. /trunk/reviewboard/contrib/tools/post-review (Diff revision 1)
     
     
     
     
     
     
    The indentation looks a bit screwed up here.
    1. I think it's right.  The 'else' of a for-loop will run iff you don't break out of the loop early, which looks like what's intended here.
    2. Wow, I never knew you could do that. I'm not sure what I think of the syntax, but I guess it's valid.. Would you mind putting a comment briefly describing it in the else: just so people don't make the same mistake I did?
    3. I've added a comment in my copy.  It's a feature that's been in Python since the beginning (1.0 at least), and is in the tutorial.
    4. I never read the Tutorial. Guess I should do that sometime :)
  3. /trunk/reviewboard/contrib/tools/post-review (Diff revision 1)
     
     
     
     
     
     
     
    One thing we'll need to make sure we support is spaces in the filename. It looks like this may break in this case.
    1. Hm, you're right.  I can't think of a good solution to this since p4 output isn't very parsable.  I was thinking a regex like this would work:
      
       r'(//.+) (//.+) (/.+)'
      
      But that doesn't work in a Windows environment.  Is it safe to assume that this tool requires a unix-like environment?
      
      Also, the older version will choke on spaces, too.  It used this regular expression:
      
      m = re.match(r'%s \/\/.+ (.+)$' % depot_path, where_info)
      
      which doesn't handle spaces (at least in my testing), so there's no regression at least. ;)
      
      
    2. We have many Windows users at VMware using post-review.
      
      Our whitespace handling before has been pretty bad and there have been complaints. I'd love to find a good solution for this, but I recognize it's difficult.
      
      According to the p4 where manual (http://www.perforce.com/perforce/doc.current/manuals/cmdref/where.html) we might have multiple results for this command, so maybe we should take this into account.
      
      The goal of this is to get the local path of a file based on the depot path, so maybe we just need to be more specific in our parsing. We can get the local directory the checkout resides in, so perhaps we should just find where that is in each of the resulting lines, and if we find out, grab everything from the beginning of that path to the end of the line.
      
      So if we know the checkout is in /home/bvanzant/home-versioned, we can go through each line and see if that string exists (maybe prepend a space before it so we have a reduced chance of hitting that string in one of the other chunks of that line). Then grab everything from /home/bvanzant/home-versioned through the end of the line, giving us that path. That would take into account whitespace.
    3. I've uploaded a new diff that fixes the issue where "p4 where" might return multiple results.  I think taking the last line is sufficient.  I played around with some workspaces that had multiple mappings and it seems reliable.
      
      As for the whitespace in filenames, I like the idea of looking for the local directory and parsing the output based on that.  I made an experimental version that runs "p4 client -o" to determine the Root and AltRoots.  It's unfortunate to run yet another p4 command, but I can't think of another way.  The --output-diff option seems to work ok, but when I tried to look at the diff posted to my test  server it fails when trying to apply the patch (it says "The patch didn't apply cleanly").  I can post my additional changes to post-review to support spaces in filenames if you'd like.  It's about an additional 30 lines on top of this patch.
    4. Sorry for the delays in getting this and your other patch in. I've been busy with a deadline at work so I haven't really had the time the past couple of weeks to give the patches my full attention, but I'm hoping to do some Review Board work this weekend. At the very least, I'll probably be doing a bit during the week of Thanksgiving.
      
      The patch to support spaces would be nice to get in, but I don't think it needs to be part of this diff. It'd make for an easier review if it's separate anyway.
  4. 
      
chipx86
  1. Sorry Eric, I dropped the ball on this. I think it's fine to submit.
    
    Do you have a version of this updated with the latest changes in post-review? The patch fails in several locations.
    1. Just uploaded an update that should apply against the latest svn version.
      
    2. Looks good.  Committed to SVN.  Thanks!
  2. 
      
Loading...