summaryrefslogtreecommitdiffstats
path: root/subcmds/sync.py
diff options
context:
space:
mode:
authorShawn O. Pearce <sop@google.com>2008-11-03 10:32:09 -0800
committerShawn O. Pearce <sop@google.com>2008-11-03 11:00:44 -0800
commitc9ef744c7b5f6bcab446cf0a0bc9cc1b016dd5f8 (patch)
treeff1bd7309698ef0dd312daf205512b1fa96d3e8d /subcmds/sync.py
parent438ee1cad98ac32509718976e63c36a449bfb679 (diff)
downloadgit-repo-c9ef744c7b5f6bcab446cf0a0bc9cc1b016dd5f8.tar.gz
Install a default pre-auto-gc hook in all repositories
This hook is evaluated by `git gc --auto` to determine if it is a good idea to execute a GC at this time, or defer it to some later date. When working on a laptop its a good idea to avoid GC if you are on battery power as the extra CPU and disk IO would consume a decent amount of the charge. The hook is the standard sample hook from git.git contrib/hooks, last modified in git.git by 84ed4c5d117d72f02cc918e413b9861a9d2846d7. I added the GPLv2 header to the script to ensure the license notice is clear, as it does not match repo's own APLv2 license. We only update hooks during initial repository creation or on a repo sync. This way we don't incur huge overheads from the hook stat operations during "repo status" or even the normal "repo sync" cases. Signed-off-by: Shawn O. Pearce <sop@google.com>
Diffstat (limited to 'subcmds/sync.py')
-rw-r--r--subcmds/sync.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/subcmds/sync.py b/subcmds/sync.py
index 3eb44edf..9af12322 100644
--- a/subcmds/sync.py
+++ b/subcmds/sync.py
@@ -49,6 +49,9 @@ the manifest.
49 p.add_option('--no-repo-verify', 49 p.add_option('--no-repo-verify',
50 dest='no_repo_verify', action='store_true', 50 dest='no_repo_verify', action='store_true',
51 help='do not verify repo source code') 51 help='do not verify repo source code')
52 p.add_option('--repo-upgraded',
53 dest='repo_upgraded', action='store_true',
54 help='perform additional actions after a repo upgrade')
52 55
53 def _Fetch(self, *projects): 56 def _Fetch(self, *projects):
54 fetched = set() 57 fetched = set()
@@ -67,6 +70,11 @@ the manifest.
67 mp = self.manifest.manifestProject 70 mp = self.manifest.manifestProject
68 mp.PreSync() 71 mp.PreSync()
69 72
73 if opt.repo_upgraded:
74 for project in self.manifest.projects.values():
75 if project.Exists:
76 project.PostRepoUpgrade()
77
70 all = self.GetProjects(args, missing_ok=True) 78 all = self.GetProjects(args, missing_ok=True)
71 fetched = self._Fetch(rp, mp, *all) 79 fetched = self._Fetch(rp, mp, *all)
72 80
@@ -77,7 +85,7 @@ the manifest.
77 if not rp.Sync_LocalHalf(): 85 if not rp.Sync_LocalHalf():
78 sys.exit(1) 86 sys.exit(1)
79 print >>sys.stderr, 'info: Restarting repo with latest version' 87 print >>sys.stderr, 'info: Restarting repo with latest version'
80 raise RepoChangedException() 88 raise RepoChangedException(['--repo-upgraded'])
81 else: 89 else:
82 print >>sys.stderr, 'warning: Skipped upgrade to unverified version' 90 print >>sys.stderr, 'warning: Skipped upgrade to unverified version'
83 91