diff options
Diffstat (limited to 'subcmds/sync.py')
-rw-r--r-- | subcmds/sync.py | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/subcmds/sync.py b/subcmds/sync.py index 27dd877d..d565af7b 100644 --- a/subcmds/sync.py +++ b/subcmds/sync.py | |||
@@ -510,7 +510,6 @@ uncommitted changes are present' % project.relpath | |||
510 | to_fetch.append(rp) | 510 | to_fetch.append(rp) |
511 | to_fetch.extend(all_projects) | 511 | to_fetch.extend(all_projects) |
512 | to_fetch.sort(key=self._fetch_times.Get, reverse=True) | 512 | to_fetch.sort(key=self._fetch_times.Get, reverse=True) |
513 | self._fetch_times.Clear() | ||
514 | 513 | ||
515 | fetched = self._Fetch(to_fetch, opt) | 514 | fetched = self._Fetch(to_fetch, opt) |
516 | _PostRepoFetch(rp, opt.no_repo_verify) | 515 | _PostRepoFetch(rp, opt.no_repo_verify) |
@@ -632,19 +631,24 @@ warning: Cannot automatically authenticate repo.""" | |||
632 | return True | 631 | return True |
633 | 632 | ||
634 | class _FetchTimes(object): | 633 | class _FetchTimes(object): |
634 | _ALPHA = 0.5 | ||
635 | |||
635 | def __init__(self, manifest): | 636 | def __init__(self, manifest): |
636 | self._path = os.path.join(manifest.repodir, '.repopickle_fetchtimes') | 637 | self._path = os.path.join(manifest.repodir, '.repopickle_fetchtimes') |
637 | self._times = None | 638 | self._times = None |
638 | 639 | self._seen = set() | |
639 | def Clear(self): | ||
640 | self._times = {} | ||
641 | 640 | ||
642 | def Get(self, project): | 641 | def Get(self, project): |
643 | self._Load() | 642 | self._Load() |
644 | return self._times.get(project.name, _ONE_DAY_S) | 643 | return self._times.get(project.name, _ONE_DAY_S) |
645 | 644 | ||
646 | def Set(self, project, t): | 645 | def Set(self, project, t): |
647 | self._times[project.name] = t | 646 | self._Load() |
647 | name = project.name | ||
648 | old = self._times.get(name, t) | ||
649 | self._seen.add(name) | ||
650 | a = self._ALPHA | ||
651 | self._times[name] = (a*t) + ((1-a) * old) | ||
648 | 652 | ||
649 | def _Load(self): | 653 | def _Load(self): |
650 | if self._times is None: | 654 | if self._times is None: |
@@ -669,6 +673,14 @@ class _FetchTimes(object): | |||
669 | def Save(self): | 673 | def Save(self): |
670 | if self._times is None: | 674 | if self._times is None: |
671 | return | 675 | return |
676 | |||
677 | to_delete = [] | ||
678 | for name in self._times: | ||
679 | if name not in self._seen: | ||
680 | to_delete.append(name) | ||
681 | for name in to_delete: | ||
682 | del self._times[name] | ||
683 | |||
672 | try: | 684 | try: |
673 | f = open(self._path, 'wb') | 685 | f = open(self._path, 'wb') |
674 | try: | 686 | try: |