bg{dZddlmZmZmZddlmZddlmZm Z m Z ddl m Z ddl mZddlZddlZdZGd d eeeeZdS) z/Module containing a database to deal with packs) FileDBBase ObjectDBR CachingDB) LazyMixin) BadObjectUnsupportedOperationAmbiguousObjectName) PackEntity)reduceN)PackedDBcpeZdZdZdZfdZdZdZdZdZ dZ d Z d Z d Z d ZddZdZdZxZS)r z-A database operating on a set of object packsicft|d|_d|_dSNr)super__init__ _hit_count _st_mtime)self root_path __class__s ^/builddir/build/BUILD/cloudlinux-venv-1.0.7/venv/lib/python3.11/site-packages/gitdb/db/pack.pyrzPackedDB.__init__)s/ ### ch|dkr+t|_|ddSdS)N _entitiesT)force)listr update_cache)rattrs r _set_cache_zPackedDB._set_cache_3s= ;  !VVDN   D  ) ) ) ) )  rc@|jdddS)Nc|dSr)ls rz)PackedDB._sort_entities..:s !A$rT)keyreverse)rsortrs r_sort_entitieszPackedDB._sort_entities9s% =====rc|j|jzdkr||jD]A}|d|}|,|dxxdz cc<|xjdz c_|d|fcSBt |)a:return: tuple(entity, index) for an item at the given sha :param sha: 20 or 40 byte sha :raise BadObject: **Note:** This method is not thread-safe, but may be hit in multi-threaded operation. The worst thing that can happen though is a counter that was not incremented, or the list being in wrong order. So we safe the time for locking here, lets see how that goesrN)r_sort_intervalr)rr)rshaitemindexs r _pack_infozPackedDB._pack_info<s ?T0 0A 5 5    ! ! !N ( (DDGCLLE Q1 1$Q''''!nnrcT ||dS#t$rYdSwxYw)NTF)r1r)rr.s r has_objectzPackedDB.has_objectYs@  OOC 4   55 s  ''c\||\}}||SN)r1 info_at_indexrr.entityr0s rinfoz PackedDB.infoas+,, ##E***rc\||\}}||Sr5)r1stream_at_indexr7s rstreamzPackedDB.streames+,, %%e,,,rc#K|D]N}|}|j}t|D]}||VOdSr5)entitiesr0r.rangesize)rr8r0 sha_by_indexs rsha_iterzPackedDB.sha_iterisxmmoo * *FLLNNE 9Luzz||,, * *"l5)))))) * * *rcHd|jD}td|dS)Ncfg|].}|d/Sr,)r0r@.0r/s r z!PackedDB.size..ss0CCCDa%%''CCCrc ||zSr5r")xys rr$zPackedDB.size..ts 1q5rr)rr )rsizess rr@z PackedDB.sizers-CCDNCCC((%333rct)zStoring individual objects is not feasible as a pack is designed to hold multiple objects. Writing or rewriting packs for single objects is inefficient)r)ristreams rstorezPackedDB.storezs#$$$rFc,tj|}|s|j|jkrdS|j|_t t jtj|d}d|j D}||z D]i}t|}|j | ||jgj||z D]b}d}t!|j D]9\}} | d |kr|}n:|dksJ|j |=c|dS)a Update our cache with the actually existing packs on disk. Add new ones, and remove deleted ones. We keep the unchanged ones :param force: If True, the cache will be updated even though the directory does not appear to have changed according to its modification timestamp. :return: True if the packs have been updated so there is new information, False if there was no change to the pack databaseFz pack-*.packcfh|].}|d/SrE)packpathrFs r z(PackedDB.update_cache..s0KKKD$q',,..--//KKKrr,T)osstatrst_mtimersetglobrSjoinrr appendrRr@r0 sha_to_index enumerater)) rrrW pack_filesour_pack_files pack_filer8 del_indexir/s rrzPackedDB.update_cacheswt~~''(( $.88527<<0@0@-#P#PQQRR KKDNKKK%~5 _ _I **F N ! !6;;==#5#5#7#7A\"] ^ ^ ^ ^):5 + +II$T^44  47<<>>&&((I55 !IE6 ????y)) trc$d|jDS)z=:return: list of pack entities operated upon by this databasecg|] }|d SrEr"rFs rrHz%PackedDB.entities..s333DQ333r)rr(s rr>zPackedDB.entitiess33DN3333rc,d}|jD]x}|d||}|F|d|}|r||krt ||}y|r|St |)a:return: 20 byte sha as inferred by the given partial binary sha :param partial_binsha: binary sha with less than 20 bytes :param canonical_length: length of the corresponding canonical representation. It is required as binary sha's cannot display whether the original hex sha had an odd or even number of characters :raise AmbiguousObjectName: :raise BadObject: Nr,)rr0partial_sha_to_indexr.r r)rpartial_binshacanonical_length candidater/ item_indexr.s rpartial_to_complete_shaz PackedDB.partial_to_complete_shas N  Da==nN^__J%1gmmoo))*55>c!1!1-n===    '''r)F)__name__ __module__ __qualname____doc__r-rrr)r1r3r9r<rBr@rOrr>rl __classcell__)rs@rr r s77 N*** >>>:+++---***444%%%++++Z444(((((((rr )rp gitdb.db.baserrr gitdb.utilr gitdb.excrrr gitdb.packr functoolsr rVrZ__all__r r"rrrxs 65 !  "!!!!!  l(l(l(l(l(z9il(l(l(l(l(r