• Manuel Jacob's avatar
    repomodel, revpanel: improve upon "Not a head revision!" warning · 02bf7e7f2c44
    Manuel Jacob authored
    The original motivation was to fix the calculation of what leads to "Not a head
    revision!" warnings in several places, which were all different and flawed in
    different ways.
    
    When thinking about how to fix them, deeper problems surfaced. The previous code
    showed "Not a head revision!" on the working directory line in the log, which
    is actually incorrect, as a working directory, when being committed, always
    becomes a head, as a freshly created revision trivally can’t have any children.
    Obviously, the label "Not a head revision!" was meant to refer to the working
    directory parent instead of the working directory. In addition to being at the
    wrong place, it also broke down for merges, where there are two working
    directory parents. E.g. when merging the heads of two differently named
    branches, it incorrectly showed the warning.
    
    Because the working directory pseudo-revision is about what happens when
    committing, a "Creates new head!" warning makes more sense. The logic for
    determining whether to show this warning is based on that from the `hg commit`
    command to determine whether to show "created new head".
    
    In the commit widget, it could be argued that the "Not a head revision!" warning
    was not at the wrong place, as it could refer to the parent(s) above the
    warning instead of to the working directory. Still, it didn’t quite make sense
    when merging two parents, where it’s not clear which parent it refers to. Also,
    the previous calculation used a definition of "head" which doesn’t match
    Mercurial’s.
    
    With this patch, it’s clarified that the commit widget is about the working
    directory. Therefore the warning and calculation is changed to be the same as
    in the log widget.
    
    These changes also make sense from a usability perspective. The user doesn’t
    need to be warned that they checked out a revision that is not a head. Instead,
    the user should be warned against creating a new head, as that is often
    undesirable.
    
    Similarly, instead of showing that the working directory parent is closed, we
    show if a closed branch head is reopened. Again, we use the same logic as the
    `hg commit` command.
    
    When amending a revision that is not a topological head, there is now a note
    that it will create orphans. In practice, I found this to be a much more
    valueable information than whether it creates an additional head. See the added
    comment for detailed reasoning.
    
    A few other places had to be changed to be consistent. One notable exception is
    the backout dialog, where the warning stayed "Not a head, backout will create a
    new head!". It already had the advantages of the new warning and it was clear
    which revision "not a head" refers to. The calculation still had to be fixed.
    
    For my taste, the patch is a bit too big. However splitting in into smaller
    parts would have risked that intermediate states would have even more
    inconsistencies.
    02bf7e7f2c44
csinfo.py 18.7 KB