Mercurial > hg
comparison mercurial/dirstate.py @ 29150:0e9ed09f5fe9
cleanup: replace False identity testing with an explicit token object
The recommended way to check default value (when None is not as option) is a
token object. Identity testing to integer is less explicit and not guaranteed to
work in all implementations.
author | Pierre-Yves David <pierre-yves.david@ens-lyon.org> |
---|---|
date | Thu, 05 May 2016 19:32:51 +0200 |
parents | 2e40fada340b |
children | 930d4ee4647e |
comparison
equal
deleted
inserted
replaced
29149:2e40fada340b | 29150:0e9ed09f5fe9 |
---|---|
71 return (vfs('%s.pending' % filename), True) | 71 return (vfs('%s.pending' % filename), True) |
72 except IOError as inst: | 72 except IOError as inst: |
73 if inst.errno != errno.ENOENT: | 73 if inst.errno != errno.ENOENT: |
74 raise | 74 raise |
75 return (vfs(filename), False) | 75 return (vfs(filename), False) |
76 | |
77 _token = object() | |
76 | 78 |
77 class dirstate(object): | 79 class dirstate(object): |
78 | 80 |
79 def __init__(self, opener, ui, root, validate): | 81 def __init__(self, opener, ui, root, validate): |
80 '''Create a new dirstate object. | 82 '''Create a new dirstate object. |
686 self._nonnormalset.remove(f) | 688 self._nonnormalset.remove(f) |
687 | 689 |
688 self._pl = (parent, nullid) | 690 self._pl = (parent, nullid) |
689 self._dirty = True | 691 self._dirty = True |
690 | 692 |
691 def write(self, tr=False): | 693 def write(self, tr=_token): |
692 if not self._dirty: | 694 if not self._dirty: |
693 return | 695 return |
694 | 696 |
695 filename = self._filename | 697 filename = self._filename |
696 if tr is False: # not explicitly specified | 698 if tr is _token: # not explicitly specified |
697 self._ui.deprecwarn('use dirstate.write with ' | 699 self._ui.deprecwarn('use dirstate.write with ' |
698 'repo.currenttransaction()', | 700 'repo.currenttransaction()', |
699 '3.9') | 701 '3.9') |
700 | 702 |
701 if self._opener.lexists(self._pendingfilename): | 703 if self._opener.lexists(self._pendingfilename): |