Mercurial > evolve
comparison hgext/obsolete.py @ 80:5d029a358252
[obsolete] add kill support
author | Pierre-Yves David <pierre-yves.david@ens-lyon.org> |
---|---|
date | Wed, 14 Sep 2011 19:52:57 +0200 |
parents | 9906560f585e |
children | 97a5c943db19 |
comparison
equal
deleted
inserted
replaced
79:9906560f585e | 80:5d029a358252 |
---|---|
85 from mercurial import extensions | 85 from mercurial import extensions |
86 from mercurial import pushkey | 86 from mercurial import pushkey |
87 from mercurial import discovery | 87 from mercurial import discovery |
88 from mercurial import error | 88 from mercurial import error |
89 from mercurial import commands | 89 from mercurial import commands |
90 from mercurial.node import hex, bin, short | 90 from mercurial.node import hex, bin, short, nullid |
91 from mercurial.lock import release | 91 from mercurial.lock import release |
92 | 92 |
93 ### Patch changectx | 93 ### Patch changectx |
94 ############################# | 94 ############################# |
95 | 95 |
253 format is:: | 253 format is:: |
254 | 254 |
255 <subject-full-hex> <object-full-hex>\n""" | 255 <subject-full-hex> <object-full-hex>\n""" |
256 for sub, objs in obssubrels.iteritems(): | 256 for sub, objs in obssubrels.iteritems(): |
257 for obj in objs: | 257 for obj in objs: |
258 if sub is None: | |
259 sub = nullid | |
258 flike.write('%s %s\n' % (hex(sub), hex(obj))) | 260 flike.write('%s %s\n' % (hex(sub), hex(obj))) |
259 | 261 |
260 def _obsdeserialise(flike): | 262 def _obsdeserialise(flike): |
261 """read a file like object serialised with _obsserialise | 263 """read a file like object serialised with _obsserialise |
262 | 264 |
263 this desierialize into a {subject -> objects} mapping""" | 265 this desierialize into a {subject -> objects} mapping""" |
264 rels = {} | 266 rels = {} |
265 for line in flike: | 267 for line in flike: |
266 subhex, objhex = line.split() | 268 subhex, objhex = line.split() |
267 rels.setdefault(bin(subhex), set()).add(bin(objhex)) | 269 subnode = bin(subhex) |
270 if subnode == nullid: | |
271 subnode = None | |
272 rels.setdefault( subnode, set()).add(bin(objhex)) | |
268 return rels | 273 return rels |
269 | 274 |
270 def reposetup(ui, repo): | 275 def reposetup(ui, repo): |
271 | 276 |
272 if not repo.local(): | 277 if not repo.local(): |
289 """return the set of node that <node> make obsolete (sub)""" | 294 """return the set of node that <node> make obsolete (sub)""" |
290 return self._obssubrels.get(node, set()) | 295 return self._obssubrels.get(node, set()) |
291 | 296 |
292 def addobsolete(self, sub, obj): | 297 def addobsolete(self, sub, obj): |
293 """Add a relation marking that node <sub> is a new version of <obj>""" | 298 """Add a relation marking that node <sub> is a new version of <obj>""" |
299 if sub == nullid: | |
300 sub = None | |
294 self._obssubrels.setdefault(sub, set()).add(obj) | 301 self._obssubrels.setdefault(sub, set()).add(obj) |
295 self._obsobjrels.setdefault(obj, set()).add(sub) | 302 self._obsobjrels.setdefault(obj, set()).add(sub) |
296 try: | 303 try: |
297 if not self.nodestate(obj).mutable: | 304 if not self.nodestate(obj).mutable: |
298 self.ui.warn( | 305 self.ui.warn( |