summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn O. Pearce <sop@google.com>2009-07-03 17:24:17 -0700
committerShawn O. Pearce <sop@google.com>2009-07-03 20:50:52 -0700
commit5f947bba69de81f58f1adef10225c04727fa0ed5 (patch)
tree96da97d3e570c4b2238c807700060c144b333d09
parentb3d2c9214be60f575d64b3af3b87a3632de04ba0 (diff)
downloadgit-repo-5f947bba69de81f58f1adef10225c04727fa0ed5.tar.gz
init: add -o, --origin to name manifest remote
The -o option permits the user to control the name of the manifest's remote, which normally is hardcoded to be 'origin', but can differ because we derive it at runtime from the configuration file. Signed-off-by: Shawn O. Pearce <sop@google.com>
-rw-r--r--manifest_xml.py5
-rw-r--r--project.py8
-rwxr-xr-xrepo6
-rw-r--r--subcmds/init.py36
4 files changed, 40 insertions, 15 deletions
diff --git a/manifest_xml.py b/manifest_xml.py
index 45896be9..d888653d 100644
--- a/manifest_xml.py
+++ b/manifest_xml.py
@@ -189,7 +189,10 @@ class XmlManifest(Manifest):
189 def _Load(self): 189 def _Load(self):
190 if not self._loaded: 190 if not self._loaded:
191 m = self.manifestProject 191 m = self.manifestProject
192 b = m.GetBranch(m.CurrentBranch).merge 192 b = m.GetBranch(m.CurrentBranch)
193 if b.remote and b.remote.name:
194 m.remote.name = b.remote.name
195 b = b.merge
193 if b is not None and b.startswith(R_HEADS): 196 if b is not None and b.startswith(R_HEADS):
194 b = b[len(R_HEADS):] 197 b = b[len(R_HEADS):]
195 self.branch = b 198 self.branch = b
diff --git a/project.py b/project.py
index 6188ca72..c79e8fb9 100644
--- a/project.py
+++ b/project.py
@@ -1442,10 +1442,12 @@ class MetaProject(Project):
1442 if self.Exists: 1442 if self.Exists:
1443 cb = self.CurrentBranch 1443 cb = self.CurrentBranch
1444 if cb: 1444 if cb:
1445 base = self.GetBranch(cb).merge 1445 cb = self.GetBranch(cb)
1446 if base: 1446 if cb.merge:
1447 self.revisionExpr = base 1447 self.revisionExpr = cb.merge
1448 self.revisionId = None 1448 self.revisionId = None
1449 if cb.remote and cb.remote.name:
1450 self.remote.name = cb.remote.name
1449 1451
1450 @property 1452 @property
1451 def LastFetch(self): 1453 def LastFetch(self):
diff --git a/repo b/repo
index f73fa58b..ff7c4188 100755
--- a/repo
+++ b/repo
@@ -28,7 +28,7 @@ if __name__ == '__main__':
28del magic 28del magic
29 29
30# increment this whenever we make important changes to this script 30# increment this whenever we make important changes to this script
31VERSION = (1, 8) 31VERSION = (1, 9)
32 32
33# increment this if the MAINTAINER_KEYS block is modified 33# increment this if the MAINTAINER_KEYS block is modified
34KEYRING_VERSION = (1,0) 34KEYRING_VERSION = (1,0)
@@ -109,6 +109,10 @@ group = init_optparse.add_option_group('Manifest options')
109group.add_option('-u', '--manifest-url', 109group.add_option('-u', '--manifest-url',
110 dest='manifest_url', 110 dest='manifest_url',
111 help='manifest repository location', metavar='URL') 111 help='manifest repository location', metavar='URL')
112group.add_option('-o', '--origin',
113 dest='manifest_origin',
114 help="use REMOTE instead of 'origin' to track upstream",
115 metavar='REMOTE')
112group.add_option('-b', '--manifest-branch', 116group.add_option('-b', '--manifest-branch',
113 dest='manifest_branch', 117 dest='manifest_branch',
114 help='manifest branch or revision', metavar='REVISION') 118 help='manifest branch or revision', metavar='REVISION')
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