summaryrefslogtreecommitdiffstats
path: root/subcmds/init.py
diff options
context:
space:
mode:
Diffstat (limited to 'subcmds/init.py')
-rw-r--r--subcmds/init.py36
1 files changed, 26 insertions, 10 deletions
diff --git a/subcmds/init.py b/subcmds/init.py
index 0586721f..53c3a010 100644
--- a/subcmds/init.py
+++ b/subcmds/init.py
@@ -62,6 +62,10 @@ to update the working directory files.
62 g.add_option('-b', '--manifest-branch', 62 g.add_option('-b', '--manifest-branch',
63 dest='manifest_branch', 63 dest='manifest_branch',
64 help='manifest branch or revision', metavar='REVISION') 64 help='manifest branch or revision', metavar='REVISION')
65 g.add_option('-o', '--origin',
66 dest='manifest_origin',
67 help="use REMOTE instead of 'origin' to track upstream",
68 metavar='REMOTE')
65 if isinstance(self.manifest, XmlManifest) \ 69 if isinstance(self.manifest, XmlManifest) \
66 or not self.manifest.manifestProject.Exists: 70 or not self.manifest.manifestProject.Exists:
67 g.add_option('-m', '--manifest-name', 71 g.add_option('-m', '--manifest-name',
@@ -84,30 +88,42 @@ to update the working directory files.
84 dest='no_repo_verify', action='store_true', 88 dest='no_repo_verify', action='store_true',
85 help='do not verify repo source code') 89 help='do not verify repo source code')
86 90
87 def _SyncManifest(self, opt): 91 def _ApplyOptions(self, opt, is_new):
88 m = self.manifest.manifestProject 92 m = self.manifest.manifestProject
89 is_new = not m.Exists
90 93
91 if is_new: 94 if is_new:
92 if not opt.manifest_url: 95 if opt.manifest_origin:
93 print >>sys.stderr, 'fatal: manifest url (-u) is required.' 96 m.remote.name = opt.manifest_origin
94 sys.exit(1)
95
96 if not opt.quiet:
97 print >>sys.stderr, 'Getting manifest ...'
98 print >>sys.stderr, ' from %s' % opt.manifest_url
99 m._InitGitDir()
100 97
101 if opt.manifest_branch: 98 if opt.manifest_branch:
102 m.revisionExpr = opt.manifest_branch 99 m.revisionExpr = opt.manifest_branch
103 else: 100 else:
104 m.revisionExpr = 'refs/heads/master' 101 m.revisionExpr = 'refs/heads/master'
105 else: 102 else:
103 if opt.manifest_origin:
104 print >>sys.stderr, 'fatal: cannot change origin name'
105 sys.exit(1)
106
106 if opt.manifest_branch: 107 if opt.manifest_branch:
107 m.revisionExpr = opt.manifest_branch 108 m.revisionExpr = opt.manifest_branch
108 else: 109 else:
109 m.PreSync() 110 m.PreSync()
110 111
112 def _SyncManifest(self, opt):
113 m = self.manifest.manifestProject
114 is_new = not m.Exists
115
116 if is_new:
117 if not opt.manifest_url:
118 print >>sys.stderr, 'fatal: manifest url (-u) is required.'
119 sys.exit(1)
120
121 if not opt.quiet:
122 print >>sys.stderr, 'Getting manifest ...'
123 print >>sys.stderr, ' from %s' % opt.manifest_url
124 m._InitGitDir()
125
126 self._ApplyOptions(opt, is_new)
111 if opt.manifest_url: 127 if opt.manifest_url:
112 r = m.GetRemote(m.remote.name) 128 r = m.GetRemote(m.remote.name)
113 r.url = opt.manifest_url 129 r.url = opt.manifest_url