comparison mercurial/wireproto.py @ 20920:7fac25eddcea

wireproto: use decorator for the lookup command
author Pierre-Yves David <pierre-yves.david@fb.com>
date Fri, 28 Mar 2014 14:42:38 -0700
parents 0bb1882c85b0
children 70ed3174ce69
comparison
equal deleted inserted replaced
20919:0bb1882c85b0 20920:7fac25eddcea
626 d = repo.listkeys(encoding.tolocal(namespace)).items() 626 d = repo.listkeys(encoding.tolocal(namespace)).items()
627 t = '\n'.join(['%s\t%s' % (encoding.fromlocal(k), encoding.fromlocal(v)) 627 t = '\n'.join(['%s\t%s' % (encoding.fromlocal(k), encoding.fromlocal(v))
628 for k, v in d]) 628 for k, v in d])
629 return t 629 return t
630 630
631 @wireprotocommand('lookup', 'key')
631 def lookup(repo, proto, key): 632 def lookup(repo, proto, key):
632 try: 633 try:
633 k = encoding.tolocal(key) 634 k = encoding.tolocal(key)
634 c = repo[k] 635 c = repo[k]
635 r = c.hex() 636 r = c.hex()
792 finally: 793 finally:
793 fp.close() 794 fp.close()
794 os.unlink(tempname) 795 os.unlink(tempname)
795 796
796 commands.update({ 797 commands.update({
797 'lookup': (lookup, 'key'),
798 'pushkey': (pushkey, 'namespace key old new'), 798 'pushkey': (pushkey, 'namespace key old new'),
799 'stream_out': (stream, ''), 799 'stream_out': (stream, ''),
800 'unbundle': (unbundle, 'heads'), 800 'unbundle': (unbundle, 'heads'),
801 }) 801 })