comparison hgext/git/gitlog.py @ 44478:6d953b3fc2bd

git: make {shortest()} return shortest *unique* prefix It used to return the prefix of the specified length as long as the full node was unique (i.e. always). Differential Revision: https://phab.mercurial-scm.org/D8256
author Martin von Zweigbergk <martinvonz@google.com>
date Fri, 06 Mar 2020 14:14:05 -0800
parents ad718271a9eb
children f19491aae641
comparison
equal deleted inserted replaced
44477:ad718271a9eb 44478:6d953b3fc2bd
168 for attempt in pycompat.xrange(minlength, len(nodehex) + 1): 168 for attempt in pycompat.xrange(minlength, len(nodehex) + 1):
169 candidate = nodehex[:attempt] 169 candidate = nodehex[:attempt]
170 matches = int( 170 matches = int(
171 self._db.execute( 171 self._db.execute(
172 'SELECT COUNT(*) FROM changelog WHERE node LIKE ?', 172 'SELECT COUNT(*) FROM changelog WHERE node LIKE ?',
173 (pycompat.sysstr(nodehex + b'%'),), 173 (pycompat.sysstr(candidate + b'%'),),
174 ).fetchone()[0] 174 ).fetchone()[0]
175 ) 175 )
176 if matches == 1: 176 if matches == 1:
177 return candidate 177 return candidate
178 return nodehex 178 return nodehex