From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id EA5341381F3 for ; Thu, 5 Sep 2013 14:43:18 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id EEA7DE0EB8; Thu, 5 Sep 2013 14:43:16 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 3141BE0EBE for ; Thu, 5 Sep 2013 14:43:16 +0000 (UTC) Received: from hornbill.gentoo.org (hornbill.gentoo.org [94.100.119.163]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id E99F733EA5A for ; Thu, 5 Sep 2013 14:43:14 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id 74463E5463 for ; Thu, 5 Sep 2013 14:43:12 +0000 (UTC) From: "André Erdmann" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "André Erdmann" Message-ID: <1378385997.c2a13a2f3ec262b0bd0aa2229b9672f4878f8776.dywi@gentoo> Subject: [gentoo-commits] proj/R_overlay:master commit in: roverlay/db/ X-VCS-Repository: proj/R_overlay X-VCS-Files: roverlay/db/distmap.py X-VCS-Directories: roverlay/db/ X-VCS-Committer: dywi X-VCS-Committer-Name: André Erdmann X-VCS-Revision: c2a13a2f3ec262b0bd0aa2229b9672f4878f8776 X-VCS-Branch: master Date: Thu, 5 Sep 2013 14:43:12 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 5e1cfe55-c920-4477-8a32-daca3278355d X-Archives-Hash: eab33a676be51016c11e4e238eb4fa70 commit: c2a13a2f3ec262b0bd0aa2229b9672f4878f8776 Author: André Erdmann mailerd de> AuthorDate: Thu Sep 5 12:59:57 2013 +0000 Commit: André Erdmann mailerd de> CommitDate: Thu Sep 5 12:59:57 2013 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=c2a13a2f distmap: use VirtualDistMapInfo ... for virtual entries --- roverlay/db/distmap.py | 60 +++++++++++++++++++++++++++++++++++--------------- 1 file changed, 42 insertions(+), 18 deletions(-) diff --git a/roverlay/db/distmap.py b/roverlay/db/distmap.py index 0a3ee64..e4f8616 100644 --- a/roverlay/db/distmap.py +++ b/roverlay/db/distmap.py @@ -22,7 +22,47 @@ class DistMapException ( Exception ): pass -class DistMapInfo ( object ): + +class VirtualDistMapInfo ( object ): + + def __init__ ( self ): + super ( VirtualDistMapInfo, self ).__init__() + # references to objects that "own" (use, ...) this distfile + self.backrefs = set() + self.add_backref = self.backrefs.add + # --- end of __init__ (...) --- + + def is_volatile ( self ): + return True + + def is_persistent ( self ): + return False + + def deref_volatile ( self ): + raise NotImplementedError() + + #def add_backref ( self, ref ): self.backrefs.add ( ref ) + + def has_backref_to ( self, obj ): + return any ( ref.deref_unsafe() is obj for ref in self.backrefs ) + # --- end of has_backref_to (...) --- + + def has_backrefs ( self ): + return bool ( self.backrefs ) + + def __eq__ ( self, other ): + return self is other + + def __ne__ ( self, other ): + return self is not other + + def get_repo_name ( self ): + return None + +# --- end of VirtualDistMapInfo --- + + +class DistMapInfo ( VirtualDistMapInfo ): """Distmap entry""" DIGEST_TYPE = 'sha256' @@ -65,10 +105,6 @@ class DistMapInfo ( object ): self.sha256 = sha256 self.volatile = volatile - # references to objects that "own" (use, ...) this distfile - self.backrefs = set() - self.add_backref = self.backrefs.add - if repo_file == self.RESTORE_FROM_DISTFILE: self.repo_file = distfile else: @@ -102,16 +138,6 @@ class DistMapInfo ( object ): return None if self.volatile is None else self.volatile.deref_unsafe() # --- end of deref_volatile (...) --- - #def add_backref ( self, ref ): self.backrefs.add ( ref ) - - def has_backref_to ( self, obj ): - return any ( ( ref.deref_unsafe() is obj ) for ref in self.backrefs ) - # --- end of has_backref_to (...) --- - - def has_backrefs ( self ): - return bool ( self.backrefs ) - # --- end of has_backrefs (...) --- - @property def digest ( self ): return self.sha256 @@ -600,9 +626,7 @@ class _DistMapBase ( roverlay.util.objects.PersistentContent ): # -- end if if self._VIRTUAL_ENTRY is None: - self._VIRTUAL_ENTRY = DistMapInfo ( - None, None, None, None, volatile=True - ) + self._VIRTUAL_ENTRY = VirtualDistMapInfo() if backref is not None: self._VIRTUAL_ENTRY.add_backref ( backref )