comparison hgext/obsolete.py @ 114:1a64195e2b09

nicer hiddenrevs init
author Pierre-Yves David <pierre-yves.david@logilab.fr>
date Mon, 19 Dec 2011 16:27:00 +0100
parents eae9be0ee00e
children d60eddda9546
comparison
equal deleted inserted replaced
113:3bdabdbb4140 114:1a64195e2b09
89 from mercurial import extensions 89 from mercurial import extensions
90 from mercurial import pushkey 90 from mercurial import pushkey
91 from mercurial import discovery 91 from mercurial import discovery
92 from mercurial import error 92 from mercurial import error
93 from mercurial import commands 93 from mercurial import commands
94 from mercurial import changelog
94 from mercurial.node import hex, bin, short, nullid 95 from mercurial.node import hex, bin, short, nullid
95 from mercurial.lock import release 96 from mercurial.lock import release
96 97
97 ### Patch changectx 98 ### Patch changectx
98 ############################# 99 #############################
103 return False 104 return False
104 return bool(ctx._repo.obsoletedby(ctx.node())) and ctx.phase() 105 return bool(ctx._repo.obsoletedby(ctx.node())) and ctx.phase()
105 106
106 context.changectx.obsolete = obsolete 107 context.changectx.obsolete = obsolete
107 108
108 ohidden = context.changectx.hidden
109 def hidden(ctx):
110 """hacked version fo hidden that also initialize hiddenrevs set
111
112 XXX we need something cleaner"""
113 # hack to fill hiddenrevs
114 # compute hidden (XXX should move elsewhere)
115 if not getattr(ctx._repo.changelog, 'hiddeninit', False):
116 shown = ['not obsolete()', '.', 'bookmark()', 'tagged()',
117 'public()']
118 basicquery = 'obsolete() - (::(%s))' % (' or '.join(shown))
119 ctx._repo.changelog.hiddenrevs.update(
120 scmutil.revrange(ctx._repo, [basicquery]))
121 ctx._repo.changelog.hiddeninit = True
122
123 return ohidden(ctx)
124 context.changectx.hidden = hidden
125 109
126 ### revset 110 ### revset
127 ############################# 111 #############################
128 112
129 def revsetpublic(repo, subset, x): 113 def revsetpublic(repo, subset, x):
484 self.__dict__.pop('_obsobjrels', None) 468 self.__dict__.pop('_obsobjrels', None)
485 return ret 469 return ret
486 finally: 470 finally:
487 release(lock, wlock) 471 release(lock, wlock)
488 472
473 @scmutil.filecache('00changelog.i', True)
474 def changelog(self):
475 changelog = getattr(super(obsoletingrepo, self), 'changelog')
476 assert not changelog.__dict__.pop('hiddenrevs', ())
477 def _sethidden(changelog, value):
478 print 'COIN COIN', value
479 assert not value
480
481
482 class hchangelog(changelog.__class__):
483 @util.propertycache
484 def hiddenrevs(changelog):
485 shown = ['not obsolete()', '.', 'bookmark()', 'tagged()',
486 'public()']
487 basicquery = 'obsolete() - (::(%s))' % (' or '.join(shown))
488 # !!! self is repo not changelog
489 result = set(scmutil.revrange(self, [basicquery]))
490 return result
491 changelog.__class__ = hchangelog
492 return changelog
493
494
495
496
489 repo.__class__ = obsoletingrepo 497 repo.__class__ = obsoletingrepo
490 498