@@ -536,7 +536,7 @@ class GitAddon(caches.CachedAddon):
536536 """
537537
538538 # cache registry
539- cache = caches .CacheData (type = "git" , file = "git.pickle" , version = 5 )
539+ cache = caches .CacheData (type = "git" , file = "git.pickle" , version = 6 )
540540
541541 @classmethod
542542 def mangle_argparser (cls , parser ):
@@ -680,9 +680,12 @@ def _get_default_branch(path, remote):
680680
681681 @staticmethod
682682 def pkg_history (repo , commit_range , data = None , local = False , verbosity = - 1 ):
683- """Create or update historical package data for a given commit range."""
684- if data is None :
685- data = {}
683+ """Create or update historical package data for a given commit range.
684+
685+ Changes in the range supersede those in ``data`` for the same version
686+ and status, so the result matches a scan of the whole history.
687+ """
688+ history = {}
686689 seen = set ()
687690 with base .ProgressManager (verbosity = verbosity ) as progress :
688691 for pkg in GitRepoPkgs (repo .location , commit_range , local = local ):
@@ -696,10 +699,18 @@ def pkg_history(repo, commit_range, data=None, local=False, verbosity=-1):
696699 date = datetime .fromtimestamp (pkg .commit_time , tz = UTC ).strftime ("%Y-%m-%d" )
697700 progress (f"{ repo } -- updating git cache: commit date: { date } " )
698701 commit = (atom .fullver , pkg .commit_time , pkg .commit )
699- data .setdefault (atom .category , {}).setdefault (atom .package , {}).setdefault (
702+ history .setdefault (atom .category , {}).setdefault (atom .package , {}).setdefault (
700703 pkg .status , []
701704 ).append (commit )
702- return data
705+
706+ for category , pkgs in (data or {}).items ():
707+ for package , statuses in pkgs .items ():
708+ merged = history .setdefault (category , {}).setdefault (package , {})
709+ for status , commits in statuses .items ():
710+ entries = merged .setdefault (status , [])
711+ versions = {x [0 ] for x in entries }
712+ entries .extend (x for x in commits if x [0 ] not in versions )
713+ return history
703714
704715 def update_cache (self , force = False ):
705716 """Update related cache and push updates to disk."""
@@ -738,7 +749,7 @@ def update_cache(self, force=False):
738749 commit_range = f"{ git_cache .commit } ..{ remote } /HEAD"
739750
740751 try :
741- self .pkg_history (
752+ data = self .pkg_history (
742753 repo , commit_range , data = data , verbosity = self .options .verbosity
743754 )
744755 except GitError as exc :
0 commit comments