Commits

Pierre-Yves David committed 3f8c118

obsolete: remove usage of addcollapsedobsolete

  • Participants
  • Parent commits 48d18ba
  • Branches default

Comments (0)

Files changed (5)

File hgext/evolve.py

         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

File hgext/obsolete.py

             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
 
 #####################################################################
     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')

File tests/test-amend.t

   (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
   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
   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

File tests/test-evolve.t

   @  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

File tests/test-stabilize-order.t

   --- 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]