comparison mercurial/bookmarks.py @ 29084:052c9318e464

bookmarks: jettison bmstore's write() method per deprecation policy
author Augie Fackler <augie@google.com>
date Wed, 04 May 2016 21:01:49 -0400
parents e6f490e32863
children f92afd23a099
comparison
equal deleted inserted replaced
29083:af6d4a49e361 29084:052c9318e464
106 106
107 The transaction is then responsible for updating the file content.""" 107 The transaction is then responsible for updating the file content."""
108 tr.addfilegenerator('bookmarks', ('bookmarks',), self._write, 108 tr.addfilegenerator('bookmarks', ('bookmarks',), self._write,
109 location='plain') 109 location='plain')
110 tr.hookargs['bookmark_moved'] = '1' 110 tr.hookargs['bookmark_moved'] = '1'
111
112 def write(self):
113 '''Write bookmarks
114
115 Write the given bookmark => hash dictionary to the .hg/bookmarks file
116 in a format equal to those of localtags.
117
118 We also store a backup of the previous state in undo.bookmarks that
119 can be copied back on rollback.
120 '''
121 msg = 'bm.write() is deprecated, use bm.recordchange(transaction)'
122 self._repo.ui.deprecwarn(msg, '3.7')
123 # TODO: writing the active bookmark should probably also use a
124 # transaction.
125 self._writeactive()
126 if self._clean:
127 return
128 repo = self._repo
129 if (repo.ui.configbool('devel', 'all-warnings')
130 or repo.ui.configbool('devel', 'check-locks')):
131 l = repo._wlockref and repo._wlockref()
132 if l is None or not l.held:
133 repo.ui.develwarn('bookmarks write with no wlock')
134
135 tr = repo.currenttransaction()
136 if tr:
137 self.recordchange(tr)
138 # invalidatevolatilesets() is omitted because this doesn't
139 # write changes out actually
140 return
141
142 self._writerepo(repo)
143 repo.invalidatevolatilesets()
144 111
145 def _writerepo(self, repo): 112 def _writerepo(self, repo):
146 """Factored out for extensibility""" 113 """Factored out for extensibility"""
147 rbm = repo._bookmarks 114 rbm = repo._bookmarks
148 if rbm.active not in self: 115 if rbm.active not in self: