Check length for parents before usage

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

Information

Review Board
release-2.5.x
bb290e0...

Reviewers

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.

Description From Last Updated

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

daviddavid

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

daviddavid
misery
david
  1. 
      
  2. reviewboard/scmtools/hg.py (Diff revision 1)
     
     
    Show all issues

    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)
     
     
    Show all issues

    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:
Completed
Change Summary:
Pushed to release-2.5.x (c1e6e62)