Mercurial > public > mercurial-scm > hg
comparison mercurial/wireproto.py @ 37353:ac666c5c2e0c
wireproto: use repo.lookup() for lookup command
I'm trying to reduce use of repo[<string>] and this seems like an
obvious place to use repo.lookup().
Differential Revision: https://phab.mercurial-scm.org/D3081
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Wed, 04 Apr 2018 15:11:43 -0700 |
parents | 39f7d4ee8bcd |
children | afcfdf53e4b5 |
comparison
equal
deleted
inserted
replaced
37352:92171562c7f3 | 37353:ac666c5c2e0c |
---|---|
1012 | 1012 |
1013 @wireprotocommand('lookup', 'key', permission='pull') | 1013 @wireprotocommand('lookup', 'key', permission='pull') |
1014 def lookup(repo, proto, key): | 1014 def lookup(repo, proto, key): |
1015 try: | 1015 try: |
1016 k = encoding.tolocal(key) | 1016 k = encoding.tolocal(key) |
1017 c = repo[k] | 1017 n = repo.lookup(k) |
1018 r = c.hex() | 1018 r = hex(n) |
1019 success = 1 | 1019 success = 1 |
1020 except Exception as inst: | 1020 except Exception as inst: |
1021 r = stringutil.forcebytestr(inst) | 1021 r = stringutil.forcebytestr(inst) |
1022 success = 0 | 1022 success = 0 |
1023 return wireprototypes.bytesresponse('%d %s\n' % (success, r)) | 1023 return wireprototypes.bytesresponse('%d %s\n' % (success, r)) |