summaryrefslogtreecommitdiffstats
path: root/subcmds/sync.py
diff options
context:
space:
mode:
authorShawn O. Pearce <sop@google.com>2009-04-18 10:49:00 -0700
committerShawn O. Pearce <sop@google.com>2009-04-18 10:49:00 -0700
commitf6906876719a665819c603604603570363389d0d (patch)
treea309fe795eff059f5f464fd522fff74af148415b /subcmds/sync.py
parent336f7bd0ed70f5ee2595463b6bd8dd277e90c833 (diff)
downloadgit-repo-f6906876719a665819c603604603570363389d0d.tar.gz
Only fetch repo once-per-day under normal 'repo sync' usage
Its unlikely that a new version of repo will be delivered in any given day, so we now check only once every 24 hours to see if repo has been updated. This reduces the sync cost, as we no longer need to contact the repo distribution servers every time we do a sync. repo selfupdate can still be used to force a check. Signed-off-by: Shawn O. Pearce <sop@google.com>
Diffstat (limited to 'subcmds/sync.py')
-rw-r--r--subcmds/sync.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/subcmds/sync.py b/subcmds/sync.py
index ec5ada21..55ffca3e 100644
--- a/subcmds/sync.py
+++ b/subcmds/sync.py
@@ -18,6 +18,7 @@ import os
18import re 18import re
19import subprocess 19import subprocess
20import sys 20import sys
21import time
21 22
22from git_command import GIT 23from git_command import GIT
23from project import HEAD 24from project import HEAD
@@ -72,7 +73,7 @@ revision is temporarily needed.
72 dest='repo_upgraded', action='store_true', 73 dest='repo_upgraded', action='store_true',
73 help=SUPPRESS_HELP) 74 help=SUPPRESS_HELP)
74 75
75 def _Fetch(self, *projects): 76 def _Fetch(self, projects):
76 fetched = set() 77 fetched = set()
77 pm = Progress('Fetching projects', len(projects)) 78 pm = Progress('Fetching projects', len(projects))
78 for project in projects: 79 for project in projects:
@@ -106,7 +107,14 @@ revision is temporarily needed.
106 all = self.GetProjects(args, missing_ok=True) 107 all = self.GetProjects(args, missing_ok=True)
107 108
108 if not opt.local_only: 109 if not opt.local_only:
109 fetched = self._Fetch(rp, mp, *all) 110 to_fetch = []
111 now = time.time()
112 if (24 * 60 * 60) <= (now - rp.LastFetch):
113 to_fetch.append(rp)
114 to_fetch.append(mp)
115 to_fetch.extend(all)
116
117 fetched = self._Fetch(to_fetch)
110 _PostRepoFetch(rp, opt.no_repo_verify) 118 _PostRepoFetch(rp, opt.no_repo_verify)
111 if opt.network_only: 119 if opt.network_only:
112 # bail out now; the rest touches the working tree 120 # bail out now; the rest touches the working tree
@@ -124,7 +132,7 @@ revision is temporarily needed.
124 for project in all: 132 for project in all:
125 if project.gitdir not in fetched: 133 if project.gitdir not in fetched:
126 missing.append(project) 134 missing.append(project)
127 self._Fetch(*missing) 135 self._Fetch(missing)
128 136
129 syncbuf = SyncBuffer(mp.config, 137 syncbuf = SyncBuffer(mp.config,
130 detach_head = opt.detach_head) 138 detach_head = opt.detach_head)