Mercurial > public > mercurial-scm > hg
comparison mercurial/obsutil.py @ 35571:265cd9e19d26
visibility: improve the message when accessing filtered obsolete rev
When trying to access filtered revision, it is likely because they have been
obsoleted by an obs-marker. The current message shows how to access the
revision anyway:
abort: hidden revision '13bedc178fce'!
But in the case of an obsoleted revision, the user is likely to want to update
to or use the successor of the revision.
We update the message to display more information about the obsolescence fate
of the revision in the following cases:
abort: hidden revision '13bedc178fce' is pruned!
abort: hidden revision '13bedc178fce' has diverged!
abort: hidden revision '13bedc178fce' was rewritten as X, Y and 2 more!
Differential Revision: https://phab.mercurial-scm.org/D1591
author | Boris Feld <boris.feld@octobus.net> |
---|---|
date | Fri, 05 Jan 2018 09:12:08 +0100 |
parents | 137a08d82232 |
children | c026547454dd |
comparison
equal
deleted
inserted
replaced
35570:3e3f4c03876b | 35571:265cd9e19d26 |
---|---|
7 | 7 |
8 from __future__ import absolute_import | 8 from __future__ import absolute_import |
9 | 9 |
10 import re | 10 import re |
11 | 11 |
12 from .i18n import _ | |
12 from . import ( | 13 from . import ( |
14 node as nodemod, | |
13 phases, | 15 phases, |
14 util | 16 util, |
15 ) | 17 ) |
16 | 18 |
17 class marker(object): | 19 class marker(object): |
18 """Wrap obsolete marker raw data""" | 20 """Wrap obsolete marker raw data""" |
19 | 21 |
749 for sset in fullsuccessorsets: | 751 for sset in fullsuccessorsets: |
750 values.append({'successors': sset, 'markers': sset.markers}) | 752 values.append({'successors': sset, 'markers': sset.markers}) |
751 | 753 |
752 return values | 754 return values |
753 | 755 |
756 def _getobsfate(successorssets): | |
757 """ Compute a changeset obsolescence fate based on its successorssets. | |
758 Successors can be the tipmost ones or the immediate ones. This function | |
759 return values are not meant to be shown directly to users, it is meant to | |
760 be used by internal functions only. | |
761 Returns one fate from the following values: | |
762 - pruned | |
763 - diverged | |
764 - superseded | |
765 - superseded_split | |
766 """ | |
767 | |
768 if len(successorssets) == 0: | |
769 # The commit has been pruned | |
770 return 'pruned' | |
771 elif len(successorssets) > 1: | |
772 return 'diverged' | |
773 else: | |
774 # No divergence, only one set of successors | |
775 successors = successorssets[0] | |
776 | |
777 if len(successors) == 1: | |
778 return 'superseded' | |
779 else: | |
780 return 'superseded_split' | |
781 | |
754 def obsfateverb(successorset, markers): | 782 def obsfateverb(successorset, markers): |
755 """ Return the verb summarizing the successorset and potentially using | 783 """ Return the verb summarizing the successorset and potentially using |
756 information from the markers | 784 information from the markers |
757 """ | 785 """ |
758 if not successorset: | 786 if not successorset: |
834 fmtmin_date = util.datestr(min_date, '%Y-%m-%d %H:%M %1%2') | 862 fmtmin_date = util.datestr(min_date, '%Y-%m-%d %H:%M %1%2') |
835 fmtmax_date = util.datestr(max_date, '%Y-%m-%d %H:%M %1%2') | 863 fmtmax_date = util.datestr(max_date, '%Y-%m-%d %H:%M %1%2') |
836 line.append(" (between %s and %s)" % (fmtmin_date, fmtmax_date)) | 864 line.append(" (between %s and %s)" % (fmtmin_date, fmtmax_date)) |
837 | 865 |
838 return "".join(line) | 866 return "".join(line) |
867 | |
868 def _getfilteredreason(unfilteredrepo, ctx): | |
869 """return a human-friendly string on why a obsolete changeset is hidden | |
870 """ | |
871 successors = successorssets(unfilteredrepo, ctx.node()) | |
872 fate = _getobsfate(successors) | |
873 | |
874 # Be more precise in case the revision is superseded | |
875 if fate == 'pruned': | |
876 reason = _('is pruned') | |
877 elif fate == 'diverged': | |
878 reason = _('has diverged') | |
879 elif fate == 'superseded': | |
880 reason = _("was rewritten as: %s") % nodemod.short(successors[0][0]) | |
881 elif fate == 'superseded_split': | |
882 | |
883 succs = [] | |
884 for node_id in successors[0]: | |
885 succs.append(nodemod.short(node_id)) | |
886 | |
887 if len(succs) <= 2: | |
888 reason = _("was split as: %s") % ", ".join(succs) | |
889 else: | |
890 firstsuccessors = ", ".join(succs[:2]) | |
891 remainingnumber = len(succs) - 2 | |
892 | |
893 args = (firstsuccessors, remainingnumber) | |
894 successorsmsg = _("%s and %d more") % args | |
895 reason = _("was split as: %s") % successorsmsg | |
896 | |
897 return reason |