Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/cmdutil.py @ 45039:c05ac059749f
cleanup: use any() instead of checking truthiness of temporary list
It was not immediately obvious to me, when first seeing this, why a list was
created. It needed a second look to understand that the purpose was to check
whether the condition is true for any of the parents. Using any() for that is
clearer.
author | Manuel Jacob <me@manueljacob.de> |
---|---|
date | Thu, 02 Jul 2020 02:46:15 +0200 |
parents | 065421e12248 |
children | 0c40d2d151cb |
comparison
equal
deleted
inserted
replaced
45038:3862de62d5cf | 45039:c05ac059749f |
---|---|
3435 | 3435 |
3436 if ( | 3436 if ( |
3437 not opts.get(b'amend') | 3437 not opts.get(b'amend') |
3438 and bheads | 3438 and bheads |
3439 and node not in bheads | 3439 and node not in bheads |
3440 and not [ | 3440 and not any( |
3441 x for x in parents if x.node() in bheads and x.branch() == branch | 3441 x.node() in bheads and x.branch() == branch for x in parents |
3442 ] | 3442 ) |
3443 ): | 3443 ): |
3444 repo.ui.status(_(b'created new head\n')) | 3444 repo.ui.status(_(b'created new head\n')) |
3445 # The message is not printed for initial roots. For the other | 3445 # The message is not printed for initial roots. For the other |
3446 # changesets, it is printed in the following situations: | 3446 # changesets, it is printed in the following situations: |
3447 # | 3447 # |