##// END OF EJS Templates
templatekw: choose {latesttag} by len(changes), not date (issue5659)...
Martin von Zweigbergk -
r33866:fb672eac stable
parent child Browse files
Show More
@@ -208,10 +208,22 b' def getlatesttags(repo, ctx, cache, patt'
208 208 latesttags[rev] = ctx.date()[0], 0, [t for t in sorted(tags)]
209 209 continue
210 210 try:
211 # The tuples are laid out so the right one can be found by
212 # comparison.
213 pdate, pdist, ptag = max(
214 latesttags[p.rev()] for p in ctx.parents())
211 ptags = [latesttags[p.rev()] for p in ctx.parents()]
212 if len(ptags) > 1:
213 if ptags[0][2] == ptags[1][2]:
214 # The tuples are laid out so the right one can be found by
215 # comparison in this case.
216 pdate, pdist, ptag = max(ptags)
217 else:
218 def key(x):
219 changessincetag = len(repo.revs('only(%d, %s)',
220 ctx.rev(), x[2][0]))
221 # Smallest number of changes since tag wins. Date is
222 # used as tiebreaker.
223 return [-changessincetag, x[0]]
224 pdate, pdist, ptag = max(ptags, key=key)
225 else:
226 pdate, pdist, ptag = ptags[0]
215 227 except KeyError:
216 228 # Cache miss - recurse
217 229 todo.append(rev)
@@ -2885,7 +2885,7 b' No tag set:'
2885 2885 o 0: null+1
2886 2886
2887 2887
2888 One common tag: longest path wins:
2888 One common tag: longest path wins for {latesttagdistance}:
2889 2889
2890 2890 $ hg tag -r 1 -m t1 -d '6 0' t1
2891 2891 $ hg log -G --template '{rev}: {latesttag}+{latesttagdistance}\n'
@@ -2904,7 +2904,7 b' One common tag: longest path wins:'
2904 2904 o 0: null+1
2905 2905
2906 2906
2907 One ancestor tag: more recent wins:
2907 One ancestor tag: closest wins:
2908 2908
2909 2909 $ hg tag -r 2 -m t2 -d '7 0' t2
2910 2910 $ hg log -G --template '{rev}: {latesttag}+{latesttagdistance}\n'
@@ -2925,7 +2925,7 b' One ancestor tag: more recent wins:'
2925 2925 o 0: null+1
2926 2926
2927 2927
2928 Two branch tags: more recent wins:
2928 Two branch tags: more recent wins if same number of changes:
2929 2929
2930 2930 $ hg tag -r 3 -m t3 -d '8 0' t3
2931 2931 $ hg log -G --template '{rev}: {latesttag}+{latesttagdistance}\n'
@@ -2948,12 +2948,39 b' Two branch tags: more recent wins:'
2948 2948 o 0: null+1
2949 2949
2950 2950
2951 Two branch tags: fewest changes wins:
2952
2953 $ hg tag -r 4 -m t4 -d '4 0' t4 # older than t2, but should not matter
2954 $ hg log -G --template "{rev}: {latesttag % '{tag}+{distance},{changes} '}\n"
2955 @ 9: t4+5,6
2956 |
2957 o 8: t4+4,5
2958 |
2959 o 7: t4+3,4
2960 |
2961 o 6: t4+2,3
2962 |
2963 o 5: t4+1,2
2964 |\
2965 | o 4: t4+0,0
2966 | |
2967 | o 3: t3+0,0
2968 | |
2969 o | 2: t2+0,0
2970 |/
2971 o 1: t1+0,0
2972 |
2973 o 0: null+1,1
2974
2975
2951 2976 Merged tag overrides:
2952 2977
2953 2978 $ hg tag -r 5 -m t5 -d '9 0' t5
2954 2979 $ hg tag -r 3 -m at3 -d '10 0' at3
2955 2980 $ hg log -G --template '{rev}: {latesttag}+{latesttagdistance}\n'
2956 @ 10: t5+5
2981 @ 11: t5+6
2982 |
2983 o 10: t5+5
2957 2984 |
2958 2985 o 9: t5+4
2959 2986 |
@@ -2965,7 +2992,7 b' Merged tag overrides:'
2965 2992 |
2966 2993 o 5: t5+0
2967 2994 |\
2968 | o 4: at3:t3+1
2995 | o 4: t4+0
2969 2996 | |
2970 2997 | o 3: at3:t3+0
2971 2998 | |
@@ -2977,7 +3004,9 b' Merged tag overrides:'
2977 3004
2978 3005
2979 3006 $ hg log -G --template "{rev}: {latesttag % '{tag}+{distance},{changes} '}\n"
2980 @ 10: t5+5,5
3007 @ 11: t5+6,6
3008 |
3009 o 10: t5+5,5
2981 3010 |
2982 3011 o 9: t5+4,4
2983 3012 |
@@ -2989,7 +3018,7 b' Merged tag overrides:'
2989 3018 |
2990 3019 o 5: t5+0,0
2991 3020 |\
2992 | o 4: at3+1,1 t3+1,1
3021 | o 4: t4+0,0
2993 3022 | |
2994 3023 | o 3: at3+0,0 t3+0,0
2995 3024 | |
@@ -3001,7 +3030,9 b' Merged tag overrides:'
3001 3030
3002 3031
3003 3032 $ hg log -G --template "{rev}: {latesttag('re:^t[13]$') % '{tag}, C: {changes}, D: {distance}'}\n"
3004 @ 10: t3, C: 8, D: 7
3033 @ 11: t3, C: 9, D: 8
3034 |
3035 o 10: t3, C: 8, D: 7
3005 3036 |
3006 3037 o 9: t3, C: 7, D: 6
3007 3038 |
@@ -3044,7 +3075,7 b' if it is a relative path'
3044 3075 > EOF
3045 3076
3046 3077 $ hg -R latesttag tip
3047 test 10:9b4a630e5f5f
3078 test 11:97e5943b523a
3048 3079
3049 3080 Test recursive showlist template (issue1989):
3050 3081
@@ -3057,7 +3088,7 b' Test recursive showlist template (issue1'
3057 3088
3058 3089 $ hg -R latesttag log -r tip --style=style1989
3059 3090 M|test
3060 10,test
3091 11,test
3061 3092 branch: test
3062 3093
3063 3094 Test new-style inline templating:
@@ -3090,6 +3121,7 b' Test the strip function with chars speci'
3090 3121 $ hg log -R latesttag --template '{desc}\n'
3091 3122 at3
3092 3123 t5
3124 t4
3093 3125 t3
3094 3126 t2
3095 3127 t1
@@ -3103,6 +3135,7 b' Test the strip function with chars speci'
3103 3135 $ hg log -R latesttag --template '{strip(desc, "te")}\n'
3104 3136 at3
3105 3137 5
3138 4
3106 3139 3
3107 3140 2
3108 3141 1
@@ -3118,6 +3151,7 b' Test date format:'
3118 3151 $ hg log -R latesttag --template 'date: {date(date, "%y %m %d %S %z")}\n'
3119 3152 date: 70 01 01 10 +0000
3120 3153 date: 70 01 01 09 +0000
3154 date: 70 01 01 04 +0000
3121 3155 date: 70 01 01 08 +0000
3122 3156 date: 70 01 01 07 +0000
3123 3157 date: 70 01 01 06 +0000
General Comments 0
You need to be logged in to leave comments. Login now