##// END OF EJS Templates
Some cleanups in commands.annotate()....
Thomas Arendsen Hein -
r714:29fcd195 default
parent child Browse files
Show More
@@ -311,7 +311,7 b' def addremove(ui, repo, *files):'
311 repo.add(u)
311 repo.add(u)
312 repo.remove(d)
312 repo.remove(d)
313
313
314 def annotate(u, repo, file1, *files, **ops):
314 def annotate(ui, repo, file1, *files, **opts):
315 """show changeset information per file line"""
315 """show changeset information per file line"""
316 def getnode(rev):
316 def getnode(rev):
317 return hg.short(repo.changelog.node(rev))
317 return hg.short(repo.changelog.node(rev))
@@ -333,12 +333,13 b' def annotate(u, repo, file1, *files, **o'
333
333
334 bcache = {}
334 bcache = {}
335 opmap = [['user', getname], ['number', str], ['changeset', getnode]]
335 opmap = [['user', getname], ['number', str], ['changeset', getnode]]
336 if not ops['user'] and not ops['changeset']:
336 if not opts['user'] and not opts['changeset']:
337 ops['number'] = 1
337 opts['number'] = 1
338
338
339 node = repo.dirstate.parents()[0]
339 if opts['revision']:
340 if ops['revision']:
340 node = repo.changelog.lookup(opts['revision'])
341 node = repo.changelog.lookup(ops['revision'])
341 else:
342 node = repo.dirstate.parents()[0]
342 change = repo.changelog.read(node)
343 change = repo.changelog.read(node)
343 mmap = repo.manifest.read(change[0])
344 mmap = repo.manifest.read(change[0])
344 for f in relpath(repo, (file1,) + files):
345 for f in relpath(repo, (file1,) + files):
@@ -346,13 +347,13 b' def annotate(u, repo, file1, *files, **o'
346 pieces = []
347 pieces = []
347
348
348 for o, f in opmap:
349 for o, f in opmap:
349 if ops[o]:
350 if opts[o]:
350 l = [f(n) for n, dummy in lines]
351 l = [f(n) for n, dummy in lines]
351 m = max(map(len, l))
352 m = max(map(len, l))
352 pieces.append(["%*s" % (m, x) for x in l])
353 pieces.append(["%*s" % (m, x) for x in l])
353
354
354 for p, l in zip(zip(*pieces), lines):
355 for p, l in zip(zip(*pieces), lines):
355 u.write(" ".join(p) + ": " + l[1])
356 ui.write("%s: %s" % (" ".join(p), l[1]))
356
357
357 def cat(ui, repo, file1, rev=None, **opts):
358 def cat(ui, repo, file1, rev=None, **opts):
358 """output the latest or given revision of a file"""
359 """output the latest or given revision of a file"""
General Comments 0
You need to be logged in to leave comments. Login now