##// END OF EJS Templates
annotate: fix alignment of columns in front of line numbers (issue2807)
Thomas Arendsen Hein -
r14358:bf93e78f default
parent child Browse files
Show More
@@ -238,11 +238,12 b' def annotate(ui, repo, *pats, **opts):'
238 if not pats:
238 if not pats:
239 raise util.Abort(_('at least one filename or pattern is required'))
239 raise util.Abort(_('at least one filename or pattern is required'))
240
240
241 opmap = [('user', lambda x: ui.shortuser(x[0].user())),
241 opmap = [('user', ' ', lambda x: ui.shortuser(x[0].user())),
242 ('number', lambda x: str(x[0].rev())),
242 ('number', ' ', lambda x: str(x[0].rev())),
243 ('changeset', lambda x: short(x[0].node())),
243 ('changeset', ' ', lambda x: short(x[0].node())),
244 ('date', getdate),
244 ('date', ' ', getdate),
245 ('file', lambda x: x[0].path()),
245 ('file', ' ', lambda x: x[0].path()),
246 ('line_number', ':', lambda x: str(x[1])),
246 ]
247 ]
247
248
248 if (not opts.get('user') and not opts.get('changeset')
249 if (not opts.get('user') and not opts.get('changeset')
@@ -253,10 +254,8 b' def annotate(ui, repo, *pats, **opts):'
253 if linenumber and (not opts.get('changeset')) and (not opts.get('number')):
254 if linenumber and (not opts.get('changeset')) and (not opts.get('number')):
254 raise util.Abort(_('at least one of -n/-c is required for -l'))
255 raise util.Abort(_('at least one of -n/-c is required for -l'))
255
256
256 funcmap = [func for op, func in opmap if opts.get(op)]
257 funcmap = [(func, sep) for op, sep, func in opmap if opts.get(op)]
257 if linenumber:
258 funcmap[0] = (funcmap[0][0], '') # no separator in front of first column
258 lastfunc = funcmap[-1]
259 funcmap[-1] = lambda x: "%s:%s" % (lastfunc(x), x[1])
260
259
261 def bad(x, y):
260 def bad(x, y):
262 raise util.Abort("%s: %s" % (x, y))
261 raise util.Abort("%s: %s" % (x, y))
@@ -274,16 +273,17 b' def annotate(ui, repo, *pats, **opts):'
274 lines = fctx.annotate(follow=follow, linenumber=linenumber)
273 lines = fctx.annotate(follow=follow, linenumber=linenumber)
275 pieces = []
274 pieces = []
276
275
277 for f in funcmap:
276 for f, sep in funcmap:
278 l = [f(n) for n, dummy in lines]
277 l = [f(n) for n, dummy in lines]
279 if l:
278 if l:
280 sized = [(x, encoding.colwidth(x)) for x in l]
279 sized = [(x, encoding.colwidth(x)) for x in l]
281 ml = max([w for x, w in sized])
280 ml = max([w for x, w in sized])
282 pieces.append(["%s%s" % (' ' * (ml - w), x) for x, w in sized])
281 pieces.append(["%s%s%s" % (sep, ' ' * (ml - w), x)
282 for x, w in sized])
283
283
284 if pieces:
284 if pieces:
285 for p, l in zip(zip(*pieces), lines):
285 for p, l in zip(zip(*pieces), lines):
286 ui.write("%s: %s" % (" ".join(p), l[1]))
286 ui.write("%s: %s" % ("".join(p), l[1]))
287
287
288 @command('archive',
288 @command('archive',
289 [('', 'no-decode', None, _('do not pass files through decoders')),
289 [('', 'no-decode', None, _('do not pass files through decoders')),
@@ -193,6 +193,26 b' annotate after rename merge with -l'
193 3 b:5: b5
193 3 b:5: b5
194 7 b:7: d
194 7 b:7: d
195
195
196 Issue2807: alignment of line numbers with -l
197
198 $ echo more >> b
199 $ hg ci -mmore -d '5 0'
200 $ echo more >> b
201 $ hg ci -mmore -d '6 0'
202 $ echo more >> b
203 $ hg ci -mmore -d '7 0'
204 $ hg annotate -nlf b
205 0 a: 1: a
206 6 b: 2: z
207 1 a: 3: a
208 3 b: 4: b4
209 4 b: 5: c
210 3 b: 5: b5
211 7 b: 7: d
212 8 b: 8: more
213 9 b: 9: more
214 10 b:10: more
215
196 linkrev vs rev
216 linkrev vs rev
197
217
198 $ hg annotate -r tip -n a
218 $ hg annotate -r tip -n a
@@ -231,5 +251,5 b' annotate after ABA with follow'
231 missing file
251 missing file
232
252
233 $ hg ann nosuchfile
253 $ hg ann nosuchfile
234 abort: nosuchfile: no such file in rev c8abddb41a00
254 abort: nosuchfile: no such file in rev e9e6b4fa872f
235 [255]
255 [255]
General Comments 0
You need to be logged in to leave comments. Login now