diff options
Diffstat (limited to 'subcmds/sync.py')
| -rw-r--r-- | subcmds/sync.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/subcmds/sync.py b/subcmds/sync.py index ed8622c1..0fc493c4 100644 --- a/subcmds/sync.py +++ b/subcmds/sync.py | |||
| @@ -67,6 +67,7 @@ except ImportError: | |||
| 67 | from git_command import GIT, git_require | 67 | from git_command import GIT, git_require |
| 68 | from git_config import GetSchemeFromUrl, GetUrlCookieFile | 68 | from git_config import GetSchemeFromUrl, GetUrlCookieFile |
| 69 | from git_refs import R_HEADS, HEAD | 69 | from git_refs import R_HEADS, HEAD |
| 70 | import gitc_utils | ||
| 70 | from project import Project | 71 | from project import Project |
| 71 | from project import RemoteSpec | 72 | from project import RemoteSpec |
| 72 | from command import Command, MirrorSafeCommand | 73 | from command import Command, MirrorSafeCommand |
| @@ -193,6 +194,9 @@ later is required to fix a server side protocol bug. | |||
| 193 | help="overwrite an existing git directory if it needs to " | 194 | help="overwrite an existing git directory if it needs to " |
| 194 | "point to a different object directory. WARNING: this " | 195 | "point to a different object directory. WARNING: this " |
| 195 | "may cause loss of data") | 196 | "may cause loss of data") |
| 197 | p.add_option('--force-gitc', | ||
| 198 | dest='force_gitc', action='store_true', | ||
| 199 | help="actually sync sources in the gitc client directory.") | ||
| 196 | p.add_option('-l', '--local-only', | 200 | p.add_option('-l', '--local-only', |
| 197 | dest='local_only', action='store_true', | 201 | dest='local_only', action='store_true', |
| 198 | help="only update working tree, don't fetch") | 202 | help="only update working tree, don't fetch") |
| @@ -535,6 +539,25 @@ later is required to fix a server side protocol bug. | |||
| 535 | print('error: both -u and -p must be given', file=sys.stderr) | 539 | print('error: both -u and -p must be given', file=sys.stderr) |
| 536 | sys.exit(1) | 540 | sys.exit(1) |
| 537 | 541 | ||
| 542 | cwd = os.getcwd() | ||
| 543 | if cwd.startswith(gitc_utils.GITC_MANIFEST_DIR) and not opt.force_gitc: | ||
| 544 | print('WARNING this will pull all the sources like a normal repo sync.\n' | ||
| 545 | '\nIf you want to update your GITC Client View please rerun this ' | ||
| 546 | 'command in \n%s%s.\nOr if you actually want to pull the sources, ' | ||
| 547 | 'rerun with --force-gitc.' % | ||
| 548 | (gitc_utils.GITC_FS_ROOT_DIR, | ||
| 549 | cwd.split(gitc_utils.GITC_MANIFEST_DIR)[1])) | ||
| 550 | sys.exit(1) | ||
| 551 | |||
| 552 | self._gitc_sync = False | ||
| 553 | if cwd.startswith(gitc_utils.GITC_FS_ROOT_DIR): | ||
| 554 | self._gitc_sync = True | ||
| 555 | self._client_name = cwd.split(gitc_utils.GITC_FS_ROOT_DIR)[1].split( | ||
| 556 | '/')[0] | ||
| 557 | self._client_dir = os.path.join(gitc_utils.GITC_MANIFEST_DIR, | ||
| 558 | self._client_name) | ||
| 559 | print('Updating GITC client: %s' % self._client_name) | ||
| 560 | |||
| 538 | if opt.manifest_name: | 561 | if opt.manifest_name: |
| 539 | self.manifest.Override(opt.manifest_name) | 562 | self.manifest.Override(opt.manifest_name) |
| 540 | 563 | ||
| @@ -655,6 +678,12 @@ later is required to fix a server side protocol bug. | |||
| 655 | if opt.repo_upgraded: | 678 | if opt.repo_upgraded: |
| 656 | _PostRepoUpgrade(self.manifest, quiet=opt.quiet) | 679 | _PostRepoUpgrade(self.manifest, quiet=opt.quiet) |
| 657 | 680 | ||
| 681 | if self._gitc_sync: | ||
| 682 | gitc_utils.generate_gitc_manifest(self._client_dir, self.manifest) | ||
| 683 | print('GITC client successfully synced.') | ||
| 684 | return | ||
| 685 | |||
| 686 | |||
| 658 | if not opt.local_only: | 687 | if not opt.local_only: |
| 659 | mp.Sync_NetworkHalf(quiet=opt.quiet, | 688 | mp.Sync_NetworkHalf(quiet=opt.quiet, |
| 660 | current_branch_only=opt.current_branch_only, | 689 | current_branch_only=opt.current_branch_only, |
