Check length for parents before usage

Review Request #9679 — Created Feb. 20, 2018 and submitted

misery
Review Board
release-2.5.x
bb290e0...
reviewboard

The first changeset cannot have a parent so this would be an empty list.
That should be checked.

Sometimes mercurial uses "0000000000000000000000000000000000000000"
to indicate that the parent is the "null" changeset. Sometimes the
array is empty.

Used a repo with a few changesets. Saw
that it will result into an error if first
changeset will be fetched with cmdline or hgweb.

Added this change and saw that cmdline and hgweb
won't get an error.

  • 0
  • 0
  • 2
  • 0
  • 2
Description From Last Updated
misery
david
  1. 
      
  2. reviewboard/scmtools/hg.py (Diff revision 1)
     
     

    We generally avoid the python ternary syntax because it's ugly. I know it's a bit longer but this is preferable:

    try:
        parent = data['parents'][0]
    except IndexError:
        parent = None
    
  3. reviewboard/scmtools/hg.py (Diff revision 1)
     
     

    Same here. Can you also fix up the naming of p to be parent to not shadow the process handle?

  4. 
      
misery
david
  1. Ship It!
  2. 
      
misery
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to release-2.5.x (c1e6e62)
Loading...