Check length for parents before usage
Review Request #9679 — Created Feb. 20, 2018 and submitted
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.
-
-
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
-
reviewboard/scmtools/hg.py (Diff revision 1) Same here. Can you also fix up the naming of
p
to beparent
to not shadow the process handle?
Description: |
|
|||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Commit: |
|
|||||||||||||||||||||||||||
Diff: |
Revision 2 (+17 -5) |