diff options
Diffstat (limited to 'project.py')
-rw-r--r-- | project.py | 59 |
1 files changed, 31 insertions, 28 deletions
@@ -3284,9 +3284,7 @@ class SyncBuffer(object): | |||
3284 | 3284 | ||
3285 | 3285 | ||
3286 | class MetaProject(Project): | 3286 | class MetaProject(Project): |
3287 | 3287 | """A special project housed under .repo.""" | |
3288 | """A special project housed under .repo. | ||
3289 | """ | ||
3290 | 3288 | ||
3291 | def __init__(self, manifest, name, gitdir, worktree): | 3289 | def __init__(self, manifest, name, gitdir, worktree): |
3292 | Project.__init__(self, | 3290 | Project.__init__(self, |
@@ -3310,33 +3308,9 @@ class MetaProject(Project): | |||
3310 | self.revisionExpr = base | 3308 | self.revisionExpr = base |
3311 | self.revisionId = None | 3309 | self.revisionId = None |
3312 | 3310 | ||
3313 | def MetaBranchSwitch(self, submodules=False): | ||
3314 | """ Prepare MetaProject for manifest branch switch | ||
3315 | """ | ||
3316 | |||
3317 | # detach and delete manifest branch, allowing a new | ||
3318 | # branch to take over | ||
3319 | syncbuf = SyncBuffer(self.config, detach_head=True) | ||
3320 | self.Sync_LocalHalf(syncbuf, submodules=submodules) | ||
3321 | syncbuf.Finish() | ||
3322 | |||
3323 | return GitCommand(self, | ||
3324 | ['update-ref', '-d', 'refs/heads/default'], | ||
3325 | capture_stdout=True, | ||
3326 | capture_stderr=True).Wait() == 0 | ||
3327 | |||
3328 | @property | ||
3329 | def LastFetch(self): | ||
3330 | try: | ||
3331 | fh = os.path.join(self.gitdir, 'FETCH_HEAD') | ||
3332 | return os.path.getmtime(fh) | ||
3333 | except OSError: | ||
3334 | return 0 | ||
3335 | |||
3336 | @property | 3311 | @property |
3337 | def HasChanges(self): | 3312 | def HasChanges(self): |
3338 | """Has the remote received new commits not yet checked out? | 3313 | """Has the remote received new commits not yet checked out?""" |
3339 | """ | ||
3340 | if not self.remote or not self.revisionExpr: | 3314 | if not self.remote or not self.revisionExpr: |
3341 | return False | 3315 | return False |
3342 | 3316 | ||
@@ -3354,3 +3328,32 @@ class MetaProject(Project): | |||
3354 | elif self._revlist(not_rev(HEAD), revid): | 3328 | elif self._revlist(not_rev(HEAD), revid): |
3355 | return True | 3329 | return True |
3356 | return False | 3330 | return False |
3331 | |||
3332 | |||
3333 | class RepoProject(MetaProject): | ||
3334 | """The MetaProject for repo itself.""" | ||
3335 | |||
3336 | @property | ||
3337 | def LastFetch(self): | ||
3338 | try: | ||
3339 | fh = os.path.join(self.gitdir, 'FETCH_HEAD') | ||
3340 | return os.path.getmtime(fh) | ||
3341 | except OSError: | ||
3342 | return 0 | ||
3343 | |||
3344 | class ManifestProject(MetaProject): | ||
3345 | """The MetaProject for manifests.""" | ||
3346 | |||
3347 | def MetaBranchSwitch(self, submodules=False): | ||
3348 | """Prepare for manifest branch switch.""" | ||
3349 | |||
3350 | # detach and delete manifest branch, allowing a new | ||
3351 | # branch to take over | ||
3352 | syncbuf = SyncBuffer(self.config, detach_head=True) | ||
3353 | self.Sync_LocalHalf(syncbuf, submodules=submodules) | ||
3354 | syncbuf.Finish() | ||
3355 | |||
3356 | return GitCommand(self, | ||
3357 | ['update-ref', '-d', 'refs/heads/default'], | ||
3358 | capture_stdout=True, | ||
3359 | capture_stderr=True).Wait() == 0 | ||