summaryrefslogtreecommitdiffstats
path: root/subcmds/sync.py
diff options
context:
space:
mode:
Diffstat (limited to 'subcmds/sync.py')
-rw-r--r--subcmds/sync.py39
1 files changed, 24 insertions, 15 deletions
diff --git a/subcmds/sync.py b/subcmds/sync.py
index 79ffcf51..f6eb2a08 100644
--- a/subcmds/sync.py
+++ b/subcmds/sync.py
@@ -20,6 +20,7 @@ import subprocess
20import sys 20import sys
21 21
22from git_command import GIT 22from git_command import GIT
23from project import HEAD
23from command import Command, MirrorSafeCommand 24from command import Command, MirrorSafeCommand
24from error import RepoChangedException, GitError 25from error import RepoChangedException, GitError
25from project import R_HEADS 26from project import R_HEADS
@@ -99,26 +100,13 @@ revision is temporarily needed.
99 mp.PreSync() 100 mp.PreSync()
100 101
101 if opt.repo_upgraded: 102 if opt.repo_upgraded:
102 for project in self.manifest.projects.values(): 103 _PostRepoUpgrade(self.manifest)
103 if project.Exists:
104 project.PostRepoUpgrade()
105 104
106 all = self.GetProjects(args, missing_ok=True) 105 all = self.GetProjects(args, missing_ok=True)
107 106
108 if not opt.local_only: 107 if not opt.local_only:
109 fetched = self._Fetch(rp, mp, *all) 108 fetched = self._Fetch(rp, mp, *all)
110 109 _PostRepoFetch(rp, opt.no_repo_verify)
111 if rp.HasChanges:
112 print >>sys.stderr, 'info: A new version of repo is available'
113 print >>sys.stderr, ''
114 if opt.no_repo_verify or _VerifyTag(rp):
115 if not rp.Sync_LocalHalf():
116 sys.exit(1)
117 print >>sys.stderr, 'info: Restarting repo with latest version'
118 raise RepoChangedException(['--repo-upgraded'])
119 else:
120 print >>sys.stderr, 'warning: Skipped upgrade to unverified version'
121
122 if opt.network_only: 110 if opt.network_only:
123 # bail out now; the rest touches the working tree 111 # bail out now; the rest touches the working tree
124 return 112 return
@@ -144,6 +132,27 @@ revision is temporarily needed.
144 sys.exit(1) 132 sys.exit(1)
145 pm.end() 133 pm.end()
146 134
135
136def _PostRepoUpgrade(manifest):
137 for project in manifest.projects.values():
138 if project.Exists:
139 project.PostRepoUpgrade()
140
141def _PostRepoFetch(rp, no_repo_verify=False, verbose=False):
142 if rp.HasChanges:
143 print >>sys.stderr, 'info: A new version of repo is available'
144 print >>sys.stderr, ''
145 if no_repo_verify or _VerifyTag(rp):
146 if not rp.Sync_LocalHalf():
147 sys.exit(1)
148 print >>sys.stderr, 'info: Restarting repo with latest version'
149 raise RepoChangedException(['--repo-upgraded'])
150 else:
151 print >>sys.stderr, 'warning: Skipped upgrade to unverified version'
152 else:
153 if verbose:
154 print >>sys.stderr, 'repo version %s is current' % rp.work_git.describe(HEAD)
155
147def _VerifyTag(project): 156def _VerifyTag(project):
148 gpg_dir = os.path.expanduser('~/.repoconfig/gnupg') 157 gpg_dir = os.path.expanduser('~/.repoconfig/gnupg')
149 if not os.path.exists(gpg_dir): 158 if not os.path.exists(gpg_dir):