comparison hgext/obsolete.py @ 53:0bcbf690dfca

reorganise code
author Pierre-Yves David <pierre-yves.david@logilab.fr>
date Thu, 08 Sep 2011 17:46:54 +0200
parents 62bdc2567099
children ad1a4fb0fc49
comparison
equal deleted inserted replaced
52:62bdc2567099 53:0bcbf690dfca
124 orollback = repo.rollback 124 orollback = repo.rollback
125 o_writejournal = repo._writejournal 125 o_writejournal = repo._writejournal
126 126
127 class obsoletingrepo(repo.__class__): 127 class obsoletingrepo(repo.__class__):
128 128
129 ### Public method
130 def obsoletedby(self, node):
131 """return the set of node that make <node> obsolete (obj)"""
132 return self._obsobjrels.get(node, set())
133
134 def obsolete(self, node):
135 """return the set of node that <node> make obsolete (sub)"""
136 return self._obssubrels.get(node, set())
137
138 def addobsolete(self, sub, obj):
139 """Add a relation marking that node <sub> is a new version of <obj>"""
140 self._obssubrels.setdefault(sub, set()).add(obj)
141 self._obsobjrels.setdefault(obj, set()).add(sub)
142 try:
143 self.changelog.hiddenrevs.add(repo[obj].rev())
144 except error.RepoLookupError:
145 pass #unknow revision (but keep propagating the data
146 self._writeobsrels()
129 147
130 ### Hidden revision support 148 ### Hidden revision support
131 @util.propertycache 149 @util.propertycache
132 def hiddenrevs(self): 150 def hiddenrevs(self):
133 # It's a property because It simpler that to handle the __init__ 151 # It's a property because It simpler that to handle the __init__
205 if obssupport: 223 if obssupport:
206 remote.pushkey('obsolete', 'relations', {}, self._obssubrels) 224 remote.pushkey('obsolete', 'relations', {}, self._obssubrels)
207 return result 225 return result
208 226
209 227
210 ### Public method
211 def obsoletedby(self, node):
212 """return the set of node that make <node> obsolete (obj)"""
213 return self._obsobjrels.get(node, set())
214
215 def obsolete(self, node):
216 """return the set of node that <node> make obsolete (sub)"""
217 return self._obssubrels.get(node, set())
218
219 def addobsolete(self, sub, obj):
220 """Add a relation marking that node <sub> is a new version of <obj>"""
221 self._obssubrels.setdefault(sub, set()).add(obj)
222 self._obsobjrels.setdefault(obj, set()).add(sub)
223 try:
224 self.changelog.hiddenrevs.add(repo[obj].rev())
225 except error.RepoLookupError:
226 pass #unknow revision (but keep propagating the data
227 self._writeobsrels()
228 228
229 ### rollback support 229 ### rollback support
230 230
231 def _writejournal(self, desc): 231 def _writejournal(self, desc):
232 entries = list(o_writejournal(desc)) 232 entries = list(o_writejournal(desc))