diff options
-rw-r--r-- | project.py | 4 | ||||
-rw-r--r-- | subcmds/sync.py | 16 |
2 files changed, 17 insertions, 3 deletions
@@ -573,7 +573,7 @@ class Project(object): | |||
573 | for file in self.copyfiles: | 573 | for file in self.copyfiles: |
574 | file._Copy() | 574 | file._Copy() |
575 | 575 | ||
576 | def Sync_LocalHalf(self): | 576 | def Sync_LocalHalf(self, detach_head=False): |
577 | """Perform only the local IO portion of the sync process. | 577 | """Perform only the local IO portion of the sync process. |
578 | Network access is not required. | 578 | Network access is not required. |
579 | 579 | ||
@@ -594,7 +594,7 @@ class Project(object): | |||
594 | 594 | ||
595 | branch = self.CurrentBranch | 595 | branch = self.CurrentBranch |
596 | 596 | ||
597 | if branch is None: | 597 | if branch is None or detach_head: |
598 | # Currently on a detached HEAD. The user is assumed to | 598 | # Currently on a detached HEAD. The user is assumed to |
599 | # not have any local modifications worth worrying about. | 599 | # not have any local modifications worth worrying about. |
600 | # | 600 | # |
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 | |||
44 | or absolute path to the project's local directory. If no projects | 44 | or absolute path to the project's local directory. If no projects |
45 | are specified, '%prog' will synchronize all projects listed in | 45 | are specified, '%prog' will synchronize all projects listed in |
46 | the manifest. | 46 | the manifest. |
47 | |||
48 | The -d/--detach option can be used to switch specified projects | ||
49 | back to the manifest revision. This option is especially helpful | ||
50 | if the project is currently on a topic branch, but the manifest | ||
51 | revision 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 | ||