Mercurial > evolve
comparison hgext/obsolete.py @ 203:9799d0aa53c8
[obsolete] add supprt for futur Hg 2.2
author | Alain Leufroy <alain.leufroy@logilab.fr> |
---|---|
date | Mon, 16 Apr 2012 10:51:40 +0200 |
parents | 83b7e2c62ac3 |
children | 50039b9b535e |
comparison
equal
deleted
inserted
replaced
202:83b7e2c62ac3 | 203:9799d0aa53c8 |
---|---|
362 return | 362 return |
363 | 363 |
364 opull = repo.pull | 364 opull = repo.pull |
365 opush = repo.push | 365 opush = repo.push |
366 o_rollback = repo._rollback | 366 o_rollback = repo._rollback |
367 o_writejournal = repo._writejournal | |
368 ocancopy = repo.cancopy | 367 ocancopy = repo.cancopy |
368 | |
369 # /!\ api change in Hg 2.2 (97efd26eb9576f39590812ea9) /!\ | |
370 if util.safehasattr(repo, '_journalfiles'): # Hg 2.2 | |
371 o_journalfiles = repo._journalfiles | |
372 else: # XXX remove this bloc while breaking support to Hg 2.1 | |
373 o_writejournal = repo._writejournal | |
374 | |
369 | 375 |
370 class obsoletingrepo(repo.__class__): | 376 class obsoletingrepo(repo.__class__): |
371 | 377 |
372 ### Public method | 378 ### Public method |
373 def obsoletedby(self, node): | 379 def obsoletedby(self, node): |
382 def _obsoleteset(self): | 388 def _obsoleteset(self): |
383 """the set of obsolete revision""" | 389 """the set of obsolete revision""" |
384 obs = set() | 390 obs = set() |
385 nm = self.changelog.nodemap | 391 nm = self.changelog.nodemap |
386 for obj in self._obsobjrels: | 392 for obj in self._obsobjrels: |
387 rev = nm.get(obj, None) | 393 try: # /!\api change in Hg 2.2 (e8d37b78acfb22ae2c1fb126c2)/!\ |
394 rev = nm.get(obj) | |
395 except TypeError: #XXX to remove while breaking Hg 2.1 support | |
396 rev = nm.get(obj, None) | |
388 if rev is not None: | 397 if rev is not None: |
389 obs.add(rev) | 398 obs.add(rev) |
390 return obs | 399 return obs |
391 | 400 |
392 @util.propertycache | 401 @util.propertycache |
527 remote.pushkey('obsolete', 'relations', '', tmp.getvalue()) | 536 remote.pushkey('obsolete', 'relations', '', tmp.getvalue()) |
528 | 537 |
529 return result | 538 return result |
530 | 539 |
531 | 540 |
532 | |
533 ### rollback support | 541 ### rollback support |
534 | 542 |
535 def _writejournal(self, desc): | 543 # /!\ api change in Hg 2.2 (97efd26eb9576f39590812ea9) /!\ |
536 """wrapped version of _writejournal that save obsolete data""" | 544 if util.safehasattr(repo, '_journalfiles'): # Hg 2.2 |
537 entries = list(o_writejournal(desc)) | 545 def _journalfiles(self): |
538 filename = 'obsolete-relations' | 546 return o_journalfiles() + ('journal.obsolete-relations',) |
539 filepath = self.join(filename) | 547 else: # XXX remove this bloc while breaking support to Hg 2.1 |
540 if os.path.exists(filepath): | 548 def _writejournal(self, desc): |
541 journalname = 'journal.' + filename | 549 """wrapped version of _writejournal that save obsolete data""" |
542 journalpath = self.join(journalname) | 550 entries = list(o_writejournal(desc)) |
543 util.copyfile(filepath, journalpath) | 551 filename = 'obsolete-relations' |
544 entries.append(journalpath) | 552 filepath = self.join(filename) |
545 return tuple(entries) | 553 if os.path.exists(filepath): |
554 journalname = 'journal.' + filename | |
555 journalpath = self.join(journalname) | |
556 util.copyfile(filepath, journalpath) | |
557 entries.append(journalpath) | |
558 return tuple(entries) | |
546 | 559 |
547 def _rollback(self, dryrun=False, **kwargs): | 560 def _rollback(self, dryrun=False, **kwargs): |
548 """wrapped version of _rollback that restore obsolete data""" | 561 """wrapped version of _rollback that restore obsolete data""" |
549 ret = o_rollback(dryrun, **kwargs) | 562 ret = o_rollback(dryrun, **kwargs) |
550 if not (ret or dryrun): #rollback did not failed | 563 if not (ret or dryrun): #rollback did not failed |