[obsolete] Update pushkey code
authorPierre-Yves David <pierre-yves.david@logilab.fr>
Thu, 08 Sep 2011 19:07:00 +0200
changeset 56 27f9c0d0a996
parent 55 cf4626a13345
child 57 62f2fe22bd42
[obsolete] Update pushkey code
hgext/obsolete.py
--- a/hgext/obsolete.py	Thu Sep 08 19:03:42 2011 +0200
+++ b/hgext/obsolete.py	Thu Sep 08 19:07:00 2011 +0200
@@ -229,19 +229,20 @@
         ### pull // push support
 
         def pull(self, remote, *args, **kwargs):
-            obskey = remote.listkeys('obsolete')
-            obsrels = obskey.get('relations', {})
             result = opull(remote, *args, **kwargs)
-            for sub, objs in obsrels.iteritems():
-                for obj in objs:
-                    self.addobsolete(sub, obj)
+            if 'obsolete' in remote.listkeys('namespaces'):
+                tmp = StringIO()
+                tmp.write(remote.listkeys('obsolete')['relations'])
+                tmp.seek(0)
+                obsrels = repo._obsdeserialise(tmp)
+                for sub, objs in obsrels.iteritems():
+                    for obj in objs:
+                        self.addobsolete(sub, obj)
             return result
 
         def push(self, remote, *args, **opts):
-            obskey = remote.listkeys('obsolete')
-            obssupport = 'relations' in obskey
             result = opush(remote, *args, **opts)
-            if obssupport:
+            if 'obsolete' in remote.listkeys('namespaces'):
                 tmp = StringIO()
                 repo._obsserialise(tmp)
                 remote.pushkey('obsolete', 'relations', {}, tmp.getvalue())