diff obsolete.py @ 46:3b0364fc822f

Do not propagate obsolete changeset
author Pierre-Yves David <pierre-yves.david@logilab.fr>
date Thu, 08 Sep 2011 16:46:58 +0200
parents b243c10a5fbe
children b73b3e3c9560
line wrap: on
line diff
--- a/obsolete.py	Thu Sep 08 14:02:29 2011 +0200
+++ b/obsolete.py	Thu Sep 08 16:46:58 2011 +0200
@@ -12,6 +12,8 @@
 from mercurial import scmutil
 from mercurial import extensions
 from mercurial import pushkey
+from mercurial import discovery
+from mercurial import error
 from mercurial.node import hex, bin
 
 # Patch changectx
@@ -47,6 +49,29 @@
 
 def extsetup(ui):
     revset.symbols["obsolete"] = revsetobsolete
+
+    def filterobsoleteout(orig, repo, remote, *args,**kwargs):
+        common, heads = orig(repo, remote, *args, **kwargs)
+
+        # filter obsolete
+        heads = set(map(repo.changelog.rev, heads))
+        obsoletes = set()
+        for obj in repo._obsobjrels:
+            try:
+                obsoletes.add(repo.changelog.rev(obj))
+            except error.LookupError:
+                pass # we don't have this node locally
+
+        outgoing = set(repo.changelog.ancestors(*heads))
+        outgoing.update(heads)
+
+        selected = outgoing - obsoletes
+        heads = sorted(map(repo.changelog.node, selected))
+
+        return common, heads
+
+    extensions.wrapfunction(discovery, 'findcommonoutgoing', filterobsoleteout)
+    
     try:
         rebase = extensions.find('rebase')
         if rebase:
@@ -183,7 +208,10 @@
             """Add a relation marking that node <sub> is a new version of <obj>"""
             self._obssubrels.setdefault(sub, set()).add(obj)
             self._obsobjrels.setdefault(obj, set()).add(sub)
-            self.changelog.hiddenrevs.add(repo[obj].rev())
+            try:
+                self.changelog.hiddenrevs.add(repo[obj].rev())
+            except error.RepoLookupError:
+                pass #unknow revision (but keep propagating the data
             self._writeobsrels()
 
     repo.__class__ = obsoletingrepo