diff options
| -rw-r--r-- | subcmds/sync.py | 58 |
1 files changed, 33 insertions, 25 deletions
diff --git a/subcmds/sync.py b/subcmds/sync.py index 542b4c20..21e0899a 100644 --- a/subcmds/sync.py +++ b/subcmds/sync.py | |||
| @@ -52,6 +52,9 @@ revision is temporarily needed. | |||
| 52 | """ | 52 | """ |
| 53 | 53 | ||
| 54 | def _Options(self, p): | 54 | def _Options(self, p): |
| 55 | p.add_option('-l','--local-only', | ||
| 56 | dest='local_only', action='store_true', | ||
| 57 | help="only update working tree, don't fetch") | ||
| 55 | p.add_option('-n','--network-only', | 58 | p.add_option('-n','--network-only', |
| 56 | dest='network_only', action='store_true', | 59 | dest='network_only', action='store_true', |
| 57 | help="fetch only, don't update working tree") | 60 | help="fetch only, don't update working tree") |
| @@ -80,6 +83,9 @@ revision is temporarily needed. | |||
| 80 | if opt.network_only and opt.detach_head: | 83 | if opt.network_only and opt.detach_head: |
| 81 | print >>sys.stderr, 'error: cannot combine -n and -d' | 84 | print >>sys.stderr, 'error: cannot combine -n and -d' |
| 82 | sys.exit(1) | 85 | sys.exit(1) |
| 86 | if opt.network_only and opt.local_only: | ||
| 87 | print >>sys.stderr, 'error: cannot combine -n and -l' | ||
| 88 | sys.exit(1) | ||
| 83 | 89 | ||
| 84 | rp = self.manifest.repoProject | 90 | rp = self.manifest.repoProject |
| 85 | rp.PreSync() | 91 | rp.PreSync() |
| @@ -93,34 +99,36 @@ revision is temporarily needed. | |||
| 93 | project.PostRepoUpgrade() | 99 | project.PostRepoUpgrade() |
| 94 | 100 | ||
| 95 | all = self.GetProjects(args, missing_ok=True) | 101 | all = self.GetProjects(args, missing_ok=True) |
| 96 | fetched = self._Fetch(rp, mp, *all) | ||
| 97 | 102 | ||
| 98 | if rp.HasChanges: | 103 | if not opt.local_only: |
| 99 | print >>sys.stderr, 'info: A new version of repo is available' | 104 | fetched = self._Fetch(rp, mp, *all) |
| 100 | print >>sys.stderr, '' | 105 | |
| 101 | if opt.no_repo_verify or _VerifyTag(rp): | 106 | if rp.HasChanges: |
| 102 | if not rp.Sync_LocalHalf(): | 107 | print >>sys.stderr, 'info: A new version of repo is available' |
| 108 | print >>sys.stderr, '' | ||
| 109 | if opt.no_repo_verify or _VerifyTag(rp): | ||
| 110 | if not rp.Sync_LocalHalf(): | ||
| 111 | sys.exit(1) | ||
| 112 | print >>sys.stderr, 'info: Restarting repo with latest version' | ||
| 113 | raise RepoChangedException(['--repo-upgraded']) | ||
| 114 | else: | ||
| 115 | print >>sys.stderr, 'warning: Skipped upgrade to unverified version' | ||
| 116 | |||
| 117 | if opt.network_only: | ||
| 118 | # bail out now; the rest touches the working tree | ||
| 119 | return | ||
| 120 | |||
| 121 | if mp.HasChanges: | ||
| 122 | if not mp.Sync_LocalHalf(): | ||
| 103 | sys.exit(1) | 123 | sys.exit(1) |
| 104 | print >>sys.stderr, 'info: Restarting repo with latest version' | ||
| 105 | raise RepoChangedException(['--repo-upgraded']) | ||
| 106 | else: | ||
| 107 | print >>sys.stderr, 'warning: Skipped upgrade to unverified version' | ||
| 108 | |||
| 109 | if opt.network_only: | ||
| 110 | # bail out now; the rest touches the working tree | ||
| 111 | return | ||
| 112 | |||
| 113 | if mp.HasChanges: | ||
| 114 | if not mp.Sync_LocalHalf(): | ||
| 115 | sys.exit(1) | ||
| 116 | 124 | ||
| 117 | self.manifest._Unload() | 125 | self.manifest._Unload() |
| 118 | all = self.GetProjects(args, missing_ok=True) | 126 | all = self.GetProjects(args, missing_ok=True) |
| 119 | missing = [] | 127 | missing = [] |
| 120 | for project in all: | 128 | for project in all: |
| 121 | if project.gitdir not in fetched: | 129 | if project.gitdir not in fetched: |
| 122 | missing.append(project) | 130 | missing.append(project) |
| 123 | self._Fetch(*missing) | 131 | self._Fetch(*missing) |
| 124 | 132 | ||
| 125 | for project in all: | 133 | for project in all: |
| 126 | if project.worktree: | 134 | if project.worktree: |
