comparison mercurial/revlog.py @ 37449:a0d71618074f

revlog: detect pseudo file nodeids to raise WdirUnsupported exception Again, I'm not sure if this is the right thing, but adding a few more pseudo hashes wouldn't be any worse than the current state. Differential Revision: https://phab.mercurial-scm.org/D2942
author Yuya Nishihara <yuya@tcha.org>
date Sun, 25 Mar 2018 18:34:07 +0900
parents 65250a66b55c
children 1ce7a55b09d1
comparison
equal deleted inserted replaced
37448:d7114f883505 37449:a0d71618074f
27 from .node import ( 27 from .node import (
28 bin, 28 bin,
29 hex, 29 hex,
30 nullid, 30 nullid,
31 nullrev, 31 nullrev,
32 wdirfilenodeids,
32 wdirhex, 33 wdirhex,
33 wdirid, 34 wdirid,
34 wdirrev, 35 wdirrev,
35 ) 36 )
36 from .i18n import _ 37 from .i18n import _
805 return self._nodecache[node] 806 return self._nodecache[node]
806 except TypeError: 807 except TypeError:
807 raise 808 raise
808 except RevlogError: 809 except RevlogError:
809 # parsers.c radix tree lookup failed 810 # parsers.c radix tree lookup failed
810 if node == wdirid: 811 if node == wdirid or node in wdirfilenodeids:
811 raise error.WdirUnsupported 812 raise error.WdirUnsupported
812 raise LookupError(node, self.indexfile, _('no node')) 813 raise LookupError(node, self.indexfile, _('no node'))
813 except KeyError: 814 except KeyError:
814 # pure python cache lookup failed 815 # pure python cache lookup failed
815 n = self._nodecache 816 n = self._nodecache
821 v = i[r][7] 822 v = i[r][7]
822 n[v] = r 823 n[v] = r
823 if v == node: 824 if v == node:
824 self._nodepos = r - 1 825 self._nodepos = r - 1
825 return r 826 return r
826 if node == wdirid: 827 if node == wdirid or node in wdirfilenodeids:
827 raise error.WdirUnsupported 828 raise error.WdirUnsupported
828 raise LookupError(node, self.indexfile, _('no node')) 829 raise LookupError(node, self.indexfile, _('no node'))
829 830
830 # Accessors for index entries. 831 # Accessors for index entries.
831 832
1434 return node 1435 return node
1435 except (TypeError, LookupError): 1436 except (TypeError, LookupError):
1436 pass 1437 pass
1437 1438
1438 def _partialmatch(self, id): 1439 def _partialmatch(self, id):
1440 # we don't care wdirfilenodeids as they should be always full hash
1439 maybewdir = wdirhex.startswith(id) 1441 maybewdir = wdirhex.startswith(id)
1440 try: 1442 try:
1441 partial = self.index.partialmatch(id) 1443 partial = self.index.partialmatch(id)
1442 if partial and self.hasnode(partial): 1444 if partial and self.hasnode(partial):
1443 if maybewdir: 1445 if maybewdir:
2112 if both are set, they must correspond to each other. 2114 if both are set, they must correspond to each other.
2113 """ 2115 """
2114 if node == nullid: 2116 if node == nullid:
2115 raise RevlogError(_("%s: attempt to add null revision") % 2117 raise RevlogError(_("%s: attempt to add null revision") %
2116 (self.indexfile)) 2118 (self.indexfile))
2117 if node == wdirid: 2119 if node == wdirid or node in wdirfilenodeids:
2118 raise RevlogError(_("%s: attempt to add wdir revision") % 2120 raise RevlogError(_("%s: attempt to add wdir revision") %
2119 (self.indexfile)) 2121 (self.indexfile))
2120 2122
2121 if self._inline: 2123 if self._inline:
2122 fh = ifh 2124 fh = ifh