summaryrefslogtreecommitdiffstats
path: root/subcmds/sync.py
diff options
context:
space:
mode:
authorSimran Basi <sbasi@google.com>2015-08-10 13:23:23 -0700
committerSimran Basi <sbasi@google.com>2015-08-18 11:59:10 -0700
commitbdb5271de3fafb9fbec3fde0e8e95e5b061ab0f5 (patch)
tree73e247db933aebfce5a63dbce6a1966c09cef3e0 /subcmds/sync.py
parent5d0c3a614edc3f3d5967cfc07c7981da7013ea91 (diff)
downloadgit-repo-bdb5271de3fafb9fbec3fde0e8e95e5b061ab0f5.tar.gz
GITC: Add repo sync support.
Add repo sync support for GITC checkouts. If the user is in the GITC client directory they can still pull the sources as normal if they pass in the --force-gitc argument. Otherwise the user should call repo sync in the GITC view to update the user's remote view. (This works because .repo in the GITC view will link to .repo in the client config directory.) Part of the support for this change is the refactoring of GITC related code into gitc_utils.py. Change-Id: I2636aaa50b450b6f091309db8dd0e8f4dbdad579
Diffstat (limited to 'subcmds/sync.py')
-rw-r--r--subcmds/sync.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/subcmds/sync.py b/subcmds/sync.py
index 43d450be..652a0c0d 100644
--- a/subcmds/sync.py
+++ b/subcmds/sync.py
@@ -58,6 +58,7 @@ except ImportError:
58 58
59from git_command import GIT, git_require 59from git_command import GIT, git_require
60from git_refs import R_HEADS, HEAD 60from git_refs import R_HEADS, HEAD
61import gitc_utils
61from project import Project 62from project import Project
62from project import RemoteSpec 63from project import RemoteSpec
63from command import Command, MirrorSafeCommand 64from command import Command, MirrorSafeCommand
@@ -184,6 +185,9 @@ later is required to fix a server side protocol bug.
184 help="overwrite an existing git directory if it needs to " 185 help="overwrite an existing git directory if it needs to "
185 "point to a different object directory. WARNING: this " 186 "point to a different object directory. WARNING: this "
186 "may cause loss of data") 187 "may cause loss of data")
188 p.add_option('--force-gitc',
189 dest='force_gitc', action='store_true',
190 help="actually sync sources in the gitc client directory.")
187 p.add_option('-l', '--local-only', 191 p.add_option('-l', '--local-only',
188 dest='local_only', action='store_true', 192 dest='local_only', action='store_true',
189 help="only update working tree, don't fetch") 193 help="only update working tree, don't fetch")
@@ -526,6 +530,25 @@ later is required to fix a server side protocol bug.
526 print('error: both -u and -p must be given', file=sys.stderr) 530 print('error: both -u and -p must be given', file=sys.stderr)
527 sys.exit(1) 531 sys.exit(1)
528 532
533 cwd = os.getcwd()
534 if cwd.startswith(gitc_utils.GITC_MANIFEST_DIR) and not opt.force_gitc:
535 print('WARNING this will pull all the sources like a normal repo sync.\n'
536 '\nIf you want to update your GITC Client View please rerun this '
537 'command in \n%s%s.\nOr if you actually want to pull the sources, '
538 'rerun with --force-gitc.' %
539 (gitc_utils.GITC_FS_ROOT_DIR,
540 cwd.split(gitc_utils.GITC_MANIFEST_DIR)[1]))
541 sys.exit(1)
542
543 self._gitc_sync = False
544 if cwd.startswith(gitc_utils.GITC_FS_ROOT_DIR):
545 self._gitc_sync = True
546 self._client_name = cwd.split(gitc_utils.GITC_FS_ROOT_DIR)[1].split(
547 '/')[0]
548 self._client_dir = os.path.join(gitc_utils.GITC_MANIFEST_DIR,
549 self._client_name)
550 print('Updating GITC client: %s' % self._client_name)
551
529 if opt.manifest_name: 552 if opt.manifest_name:
530 self.manifest.Override(opt.manifest_name) 553 self.manifest.Override(opt.manifest_name)
531 554
@@ -642,6 +665,12 @@ later is required to fix a server side protocol bug.
642 if opt.repo_upgraded: 665 if opt.repo_upgraded:
643 _PostRepoUpgrade(self.manifest, quiet=opt.quiet) 666 _PostRepoUpgrade(self.manifest, quiet=opt.quiet)
644 667
668 if self._gitc_sync:
669 gitc_utils.generate_gitc_manifest(self._client_dir, self.manifest)
670 print('GITC client successfully synced.')
671 return
672
673
645 if not opt.local_only: 674 if not opt.local_only:
646 mp.Sync_NetworkHalf(quiet=opt.quiet, 675 mp.Sync_NetworkHalf(quiet=opt.quiet,
647 current_branch_only=opt.current_branch_only, 676 current_branch_only=opt.current_branch_only,