summaryrefslogtreecommitdiffstats
path: root/subcmds/sync.py
diff options
context:
space:
mode:
authorShawn O. Pearce <sop@google.com>2009-04-10 16:59:36 -0700
committerShawn O. Pearce <sop@google.com>2009-04-10 17:08:02 -0700
commit3e768c9dc7f77cb2960f990f6e2d15890e96abdb (patch)
treeb5d256542c4e6aeeb467cd830584941542c8362f /subcmds/sync.py
parent96fdcef9e3087d71266d5c78e4a9716e3afa6d41 (diff)
downloadgit-repo-3e768c9dc7f77cb2960f990f6e2d15890e96abdb.tar.gz
Add 'repo sync -d' to detach projects from their current topic
The -d flag moves the project back to a detached HEAD state, matching what is listed in the manifest. This can be useful to set a client to something stable (or at least well-known), such as before a sequence of 'repo download' commands are used to get some changes for testing. Signed-off-by: Shawn O. Pearce <sop@google.com>
Diffstat (limited to 'subcmds/sync.py')
-rw-r--r--subcmds/sync.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/subcmds/sync.py b/subcmds/sync.py
index 01e2eba6..542b4c20 100644
--- a/subcmds/sync.py
+++ b/subcmds/sync.py
@@ -44,12 +44,21 @@ line. Projects can be specified either by name, or by a relative
44or absolute path to the project's local directory. If no projects 44or absolute path to the project's local directory. If no projects
45are specified, '%prog' will synchronize all projects listed in 45are specified, '%prog' will synchronize all projects listed in
46the manifest. 46the manifest.
47
48The -d/--detach option can be used to switch specified projects
49back to the manifest revision. This option is especially helpful
50if the project is currently on a topic branch, but the manifest
51revision is temporarily needed.
47""" 52"""
48 53
49 def _Options(self, p): 54 def _Options(self, p):
50 p.add_option('-n','--network-only', 55 p.add_option('-n','--network-only',
51 dest='network_only', action='store_true', 56 dest='network_only', action='store_true',
52 help="fetch only, don't update working tree") 57 help="fetch only, don't update working tree")
58 p.add_option('-d','--detach',
59 dest='detach_head', action='store_true',
60 help='detach projects back to manifest revision')
61
53 p.add_option('--no-repo-verify', 62 p.add_option('--no-repo-verify',
54 dest='no_repo_verify', action='store_true', 63 dest='no_repo_verify', action='store_true',
55 help='do not verify repo source code') 64 help='do not verify repo source code')
@@ -68,6 +77,10 @@ the manifest.
68 return fetched 77 return fetched
69 78
70 def Execute(self, opt, args): 79 def Execute(self, opt, args):
80 if opt.network_only and opt.detach_head:
81 print >>sys.stderr, 'error: cannot combine -n and -d'
82 sys.exit(1)
83
71 rp = self.manifest.repoProject 84 rp = self.manifest.repoProject
72 rp.PreSync() 85 rp.PreSync()
73 86
@@ -111,7 +124,8 @@ the manifest.
111 124
112 for project in all: 125 for project in all:
113 if project.worktree: 126 if project.worktree:
114 if not project.Sync_LocalHalf(): 127 if not project.Sync_LocalHalf(
128 detach_head=opt.detach_head):
115 sys.exit(1) 129 sys.exit(1)
116 130
117 131