Mercurial > evolve
changeset 443:3f8c11865ed2
obsolete: remove usage of addcollapsedobsolete
author | Pierre-Yves David <pierre-yves.david@logilab.fr> |
---|---|
date | Tue, 07 Aug 2012 18:05:41 +0200 |
parents | 48d18ba05480 |
children | aedb6b8ace86 |
files | hgext/evolve.py hgext/obsolete.py tests/test-amend.t tests/test-evolve.t tests/test-stabilize-order.t |
diffstat | 5 files changed, 51 insertions(+), 50 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/evolve.py Tue Aug 07 18:17:13 2012 +0200 +++ b/hgext/evolve.py Tue Aug 07 18:05:41 2012 +0200 @@ -118,8 +118,10 @@ if created: updatebookmarks(newid) # add evolution metadata - collapsed = set([u.node() for u in updates] + [old.node()]) - repo.addcollapsedobsolete(collapsed, new.node()) + markers = [(u, (new,)) for u in updates] + markers.append((old, (new,))) + obsolete = extensions.find('obsolete') + obsolete.createmarkers(repo, markers) else: # newid is an existing revision. It could make sense to # replace revisions with existing ones but probably not by
--- a/hgext/obsolete.py Tue Aug 07 18:17:13 2012 +0200 +++ b/hgext/obsolete.py Tue Aug 07 18:05:41 2012 +0200 @@ -609,15 +609,6 @@ finally: lock.release() - # XXX kill me - def addcollapsedobsolete(self, oldnodes, newnode): - """Mark oldnodes as collapsed into newnode.""" - # Assume oldnodes are all descendants of a single rev - rootrevs = self.revs('roots(%ln)', oldnodes) - assert len(rootrevs) == 1, rootrevs - #rootnode = self[rootrevs[0]].node() - for n in oldnodes: - self.addobsolete(newnode, n) repo.__class__ = obsoletingrepo ##################################################################### @@ -873,41 +864,49 @@ repo._rebasestate = {} repo._rebasetarget = None try: - res = orig(ui, repo, *args, **kwargs) - if not reallykeep: - # Filter nullmerge or unrebased entries - repo._rebasestate = dict(p for p in repo._rebasestate.iteritems() - if p[1] >= 0) - if not res and not kwargs.get('abort') and repo._rebasestate: - # Rebased revisions are assumed to be descendants of - # targetrev. If a source revision is mapped to targetrev - # or to another rebased revision, it must have been - # removed. - targetrev = repo[repo._rebasetarget].rev() - newrevs = set([targetrev]) - replacements = {} - for rev, newrev in sorted(repo._rebasestate.items()): - oldnode = repo[rev].node() - if newrev not in newrevs: - newnode = repo[newrev].node() - newrevs.add(newrev) + l = repo.lock() + try: + res = orig(ui, repo, *args, **kwargs) + if not reallykeep: + # Filter nullmerge or unrebased entries + repo._rebasestate = dict(p for p in repo._rebasestate.iteritems() + if p[1] >= 0) + if not res and not kwargs.get('abort') and repo._rebasestate: + # Rebased revisions are assumed to be descendants of + # targetrev. If a source revision is mapped to targetrev + # or to another rebased revision, it must have been + # removed. + targetrev = repo[repo._rebasetarget].rev() + newrevs = set([targetrev]) + replacements = {} + for rev, newrev in sorted(repo._rebasestate.items()): + oldnode = repo[rev].node() + if newrev not in newrevs: + newnode = repo[newrev].node() + newrevs.add(newrev) + else: + newnode = nullid + replacements[oldnode] = newnode + + if kwargs.get('collapse'): + newnodes = set(n for n in replacements.values() if n != nullid) + if newnodes: + # Collapsing into more than one revision? + assert len(newnodes) == 1, newnodes + newnode = newnodes.pop() + markers = [(repo[r], (repo[newnode],)) + for r in replacements] + else: + newnode = nullid + markers = [(repo[r], ()) + for r in replacements] + createmarkers(repo, markers) else: - newnode = nullid - replacements[oldnode] = newnode - - if kwargs.get('collapse'): - newnodes = set(n for n in replacements.values() if n != nullid) - if newnodes: - # Collapsing into more than one revision? - assert len(newnodes) == 1, newnodes - newnode = newnodes.pop() - else: - newnode = nullid - repo.addcollapsedobsolete(replacements, newnode) - else: - for oldnode, newnode in replacements.iteritems(): - repo.addobsolete(newnode, oldnode) - return res + for oldnode, newnode in replacements.iteritems(): + repo.addobsolete(newnode, oldnode) + return res + finally: + l.release() finally: delattr(repo, '_rebasestate') delattr(repo, '_rebasetarget')
--- a/tests/test-amend.t Tue Aug 07 18:17:13 2012 +0200 +++ b/tests/test-amend.t Tue Aug 07 18:05:41 2012 +0200 @@ -25,8 +25,8 @@ (branches are permanent and global, did you want a bookmark?) $ hg amend $ hg debugobsolete + bd19cbe78fbfbd87eb33420c63986fe5f3154f2c a34b93d251e49c93d5685ebacad785c73a7e8605 0 {'date': '* *', 'user': 'test'} (glob) 07f4944404050f47db2e5c5071e0e84e7a27bba9 a34b93d251e49c93d5685ebacad785c73a7e8605 0 {'date': '* *', 'user': 'test'} (glob) - bd19cbe78fbfbd87eb33420c63986fe5f3154f2c a34b93d251e49c93d5685ebacad785c73a7e8605 0 {'date': '* *', 'user': 'test'} (glob) $ hg branch foo $ hg branches @@ -63,8 +63,8 @@ abort: no updates found [255] $ hg debugobsolete + bd19cbe78fbfbd87eb33420c63986fe5f3154f2c a34b93d251e49c93d5685ebacad785c73a7e8605 0 {'date': '* *', 'user': 'test'} (glob) 07f4944404050f47db2e5c5071e0e84e7a27bba9 a34b93d251e49c93d5685ebacad785c73a7e8605 0 {'date': '* *', 'user': 'test'} (glob) - bd19cbe78fbfbd87eb33420c63986fe5f3154f2c a34b93d251e49c93d5685ebacad785c73a7e8605 0 {'date': '* *', 'user': 'test'} (glob) $ hg phase 2 2: draft $ glog @@ -89,8 +89,8 @@ abort: no updates found [255] $ hg debugobsolete + bd19cbe78fbfbd87eb33420c63986fe5f3154f2c a34b93d251e49c93d5685ebacad785c73a7e8605 0 {'date': '* *', 'user': 'test'} (glob) 07f4944404050f47db2e5c5071e0e84e7a27bba9 a34b93d251e49c93d5685ebacad785c73a7e8605 0 {'date': '* *', 'user': 'test'} (glob) - bd19cbe78fbfbd87eb33420c63986fe5f3154f2c a34b93d251e49c93d5685ebacad785c73a7e8605 0 {'date': '* *', 'user': 'test'} (glob) 7384bbcba36fde1a789cd00f9cd6f9b919ab5910 0000000000000000000000000000000000000000 0 {'date': '* *', 'user': 'test'} (glob) $ glog @ 6@foo(draft) amends a34b93d251e49c93d5685ebacad785c73a7e8605
--- a/tests/test-evolve.t Tue Aug 07 18:17:13 2012 +0200 +++ b/tests/test-evolve.t Tue Aug 07 18:05:41 2012 +0200 @@ -253,8 +253,8 @@ @ 0:e55e0562ee93@default(draft) base $ hg debugobsolete + 524e478d4811d405c8771e4c441de4483bdf8b33 f8111a076f0975cbecb336e2bd3411be22b673fb 0 {'date': '* *', 'user': 'test'} (glob) 7b36850622b2fd159fa30a4fb2a1edd2043b4a14 f8111a076f0975cbecb336e2bd3411be22b673fb 0 {'date': '* *', 'user': 'test'} (glob) - 524e478d4811d405c8771e4c441de4483bdf8b33 f8111a076f0975cbecb336e2bd3411be22b673fb 0 {'date': '* *', 'user': 'test'} (glob) e416e48b27428695d00c2a2cc4a0b9619482e63f 23409eba69a0986e90cd42252852c1e6da97af5b 0 {'date': '* *', 'user': 'test'} (glob) 568a468b60fc99a42d5d4ddbe181caff1eef308d 23409eba69a0986e90cd42252852c1e6da97af5b 0 {'date': '* *', 'user': 'test'} (glob) $ hg stabilize
--- a/tests/test-stabilize-order.t Tue Aug 07 18:17:13 2012 +0200 +++ b/tests/test-stabilize-order.t Tue Aug 07 18:05:41 2012 +0200 @@ -103,8 +103,8 @@ --- successors.old* (glob) +++ successors.new* (glob) @@ -3,3 +3,4 @@ + 3a4a591493f80708e46f2bf6d3b4debfad8ff91e f5ff10856e5ab3c8dc420b9c11460e6832a3b78c 0 {'date': '* *', 'user': 'test'} (glob) 93418d2c0979643ad446f621195e78720edb05b4 f5ff10856e5ab3c8dc420b9c11460e6832a3b78c 0 {'date': '* *', 'user': 'test'} (glob) - 3a4a591493f80708e46f2bf6d3b4debfad8ff91e f5ff10856e5ab3c8dc420b9c11460e6832a3b78c 0 {'date': '* *', 'user': 'test'} (glob) ab8cbb6d87ff3ab5526735a051cba6b63f3d6775 6bf44048e43f830accbf7d2bd7bc252ad7a3b99c 0 {'date': '* *', 'user': 'test'} (glob) +7a7552255fb5f8bd745e46fba6f0ca633a4dd716 5e819fbb0d278117c0a83b7f6f6486689732cfb2 0 {'date': '* *', 'user': 'test'} (glob) [1]