Mercurial > hg
comparison mercurial/scmutil.py @ 26836:88c4e97b9669 stable
scmutil: abort if an empty revision is given to revpair()
When using 'extdiff --patch' to check the changes in a rebase, 'precursors(x)'
evaluated to an empty set because I forgot the --hidden flag, so the other
revision was used as the replacement for the empty set. The result was the
patch for the other revision was diffed against itself, and the tool saying
there were no differences. That's misleading since the expected diff args were
silently changed, so it's better to bail out.
The other uses of scmutil.revpair() are commands.diff and commands.status, and
it doesn't make sense to allow an empty revision there either. The code here
was suggested by Yuya Nishihara.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Sat, 31 Oct 2015 21:45:46 -0400 |
parents | 56b2bcea2529 |
children | e40af07e518e 6a6e78f84cc6 |
comparison
equal
deleted
inserted
replaced
26835:6fabc9317b78 | 26836:88c4e97b9669 |
---|---|
715 first = l.first() | 715 first = l.first() |
716 second = l.last() | 716 second = l.last() |
717 | 717 |
718 if first is None: | 718 if first is None: |
719 raise error.Abort(_('empty revision range')) | 719 raise error.Abort(_('empty revision range')) |
720 if (first == second and len(revs) >= 2 | |
721 and not all(revrange(repo, [r]) for r in revs)): | |
722 raise error.Abort(_('empty revision on one side of range')) | |
720 | 723 |
721 # if top-level is range expression, the result must always be a pair | 724 # if top-level is range expression, the result must always be a pair |
722 if first == second and len(revs) == 1 and not _pairspec(revs[0]): | 725 if first == second and len(revs) == 1 and not _pairspec(revs[0]): |
723 return repo.lookup(first), None | 726 return repo.lookup(first), None |
724 | 727 |