summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--manifest_xml.py5
-rwxr-xr-xrepo1
-rw-r--r--subcmds/cherry_pick.py3
-rw-r--r--subcmds/smartsync.py2
-rw-r--r--subcmds/sync.py63
-rw-r--r--subcmds/version.py2
6 files changed, 69 insertions, 7 deletions
diff --git a/manifest_xml.py b/manifest_xml.py
index be185477..a6364a77 100644
--- a/manifest_xml.py
+++ b/manifest_xml.py
@@ -21,7 +21,8 @@ import urlparse
21import xml.dom.minidom 21import xml.dom.minidom
22 22
23from git_config import GitConfig 23from git_config import GitConfig
24from project import RemoteSpec, Project, MetaProject, R_HEADS, HEAD 24from git_refs import R_HEADS, HEAD
25from project import RemoteSpec, Project, MetaProject
25from error import ManifestParseError 26from error import ManifestParseError
26 27
27MANIFEST_FILE_NAME = 'manifest.xml' 28MANIFEST_FILE_NAME = 'manifest.xml'
@@ -584,7 +585,7 @@ class XmlManifest(object):
584 groups = node.getAttribute('groups') 585 groups = node.getAttribute('groups')
585 groups = [x for x in re.split('[,\s]+', groups) if x] 586 groups = [x for x in re.split('[,\s]+', groups) if x]
586 587
587 default_groups = ['default', 'name:%s' % name, 'path:%s' % path] 588 default_groups = ['all', 'name:%s' % name, 'path:%s' % path]
588 groups.extend(set(default_groups).difference(groups)) 589 groups.extend(set(default_groups).difference(groups))
589 590
590 if self.IsMirror: 591 if self.IsMirror:
diff --git a/repo b/repo
index d6b46c87..f540cbb3 100755
--- a/repo
+++ b/repo
@@ -88,7 +88,6 @@ REPO_MAIN = S_repo + '/main.py' # main script
88import optparse 88import optparse
89import os 89import os
90import re 90import re
91import readline
92import subprocess 91import subprocess
93import sys 92import sys
94import urllib2 93import urllib2
diff --git a/subcmds/cherry_pick.py b/subcmds/cherry_pick.py
index 7890af4d..7a6d4c20 100644
--- a/subcmds/cherry_pick.py
+++ b/subcmds/cherry_pick.py
@@ -13,7 +13,8 @@
13# See the License for the specific language governing permissions and 13# See the License for the specific language governing permissions and
14# limitations under the License. 14# limitations under the License.
15 15
16import sys, re 16import re
17import sys
17from command import Command 18from command import Command
18from git_command import GitCommand 19from git_command import GitCommand
19 20
diff --git a/subcmds/smartsync.py b/subcmds/smartsync.py
index 1edbd35b..e164859f 100644
--- a/subcmds/smartsync.py
+++ b/subcmds/smartsync.py
@@ -13,7 +13,7 @@
13# See the License for the specific language governing permissions and 13# See the License for the specific language governing permissions and
14# limitations under the License. 14# limitations under the License.
15 15
16from sync import Sync 16from subcmds.sync import Sync
17 17
18class Smartsync(Sync): 18class Smartsync(Sync):
19 common = True 19 common = True
diff --git a/subcmds/sync.py b/subcmds/sync.py
index cbf0decc..f573b980 100644
--- a/subcmds/sync.py
+++ b/subcmds/sync.py
@@ -13,6 +13,7 @@
13# See the License for the specific language governing permissions and 13# See the License for the specific language governing permissions and
14# limitations under the License. 14# limitations under the License.
15 15
16import netrc
16from optparse import SUPPRESS_HELP 17from optparse import SUPPRESS_HELP
17import os 18import os
18import re 19import re
@@ -21,6 +22,7 @@ import socket
21import subprocess 22import subprocess
22import sys 23import sys
23import time 24import time
25import urlparse
24import xmlrpclib 26import xmlrpclib
25 27
26try: 28try:
@@ -81,6 +83,18 @@ build as specified by the manifest-server element in the current
81manifest. The -t/--smart-tag option is similar and allows you to 83manifest. The -t/--smart-tag option is similar and allows you to
82specify a custom tag/label. 84specify a custom tag/label.
83 85
86The -u/--manifest-server-username and -p/--manifest-server-password
87options can be used to specify a username and password to authenticate
88with the manifest server when using the -s or -t option.
89
90If -u and -p are not specified when using the -s or -t option, '%prog'
91will attempt to read authentication credentials for the manifest server
92from the user's .netrc file.
93
94'%prog' will not use authentication credentials from -u/-p or .netrc
95if the manifest server specified in the manifest file already includes
96credentials.
97
84The -f/--force-broken option can be used to proceed with syncing 98The -f/--force-broken option can be used to proceed with syncing
85other projects if a project sync fails. 99other projects if a project sync fails.
86 100
@@ -157,6 +171,12 @@ later is required to fix a server side protocol bug.
157 p.add_option('-t', '--smart-tag', 171 p.add_option('-t', '--smart-tag',
158 dest='smart_tag', action='store', 172 dest='smart_tag', action='store',
159 help='smart sync using manifest from a known tag') 173 help='smart sync using manifest from a known tag')
174 p.add_option('-u', '--manifest-server-username', action='store',
175 dest='manifest_server_username',
176 help='username to authenticate with the manifest server')
177 p.add_option('-p', '--manifest-server-password', action='store',
178 dest='manifest_server_password',
179 help='password to authenticate with the manifest server')
160 180
161 g = p.add_option_group('repo Version options') 181 g = p.add_option_group('repo Version options')
162 g.add_option('--no-repo-verify', 182 g.add_option('--no-repo-verify',
@@ -356,6 +376,14 @@ uncommitted changes are present' % project.relpath
356 if opt.manifest_name and opt.smart_tag: 376 if opt.manifest_name and opt.smart_tag:
357 print >>sys.stderr, 'error: cannot combine -m and -t' 377 print >>sys.stderr, 'error: cannot combine -m and -t'
358 sys.exit(1) 378 sys.exit(1)
379 if opt.manifest_server_username or opt.manifest_server_password:
380 if not (opt.smart_sync or opt.smart_tag):
381 print >>sys.stderr, 'error: -u and -p may only be combined with ' \
382 '-s or -t'
383 sys.exit(1)
384 if None in [opt.manifest_server_username, opt.manifest_server_password]:
385 print >>sys.stderr, 'error: both -u and -p must be given'
386 sys.exit(1)
359 387
360 if opt.manifest_name: 388 if opt.manifest_name:
361 self.manifest.Override(opt.manifest_name) 389 self.manifest.Override(opt.manifest_name)
@@ -365,8 +393,41 @@ uncommitted changes are present' % project.relpath
365 print >>sys.stderr, \ 393 print >>sys.stderr, \
366 'error: cannot smart sync: no manifest server defined in manifest' 394 'error: cannot smart sync: no manifest server defined in manifest'
367 sys.exit(1) 395 sys.exit(1)
396
397 manifest_server = self.manifest.manifest_server
398
399 if not '@' in manifest_server:
400 username = None
401 password = None
402 if opt.manifest_server_username and opt.manifest_server_password:
403 username = opt.manifest_server_username
404 password = opt.manifest_server_password
405 else:
406 try:
407 info = netrc.netrc()
408 except IOError:
409 print >>sys.stderr, '.netrc file does not exist or could not be opened'
410 else:
411 try:
412 parse_result = urlparse.urlparse(manifest_server)
413 if parse_result.hostname:
414 username, _account, password = \
415 info.authenticators(parse_result.hostname)
416 except TypeError:
417 # TypeError is raised when the given hostname is not present
418 # in the .netrc file.
419 print >>sys.stderr, 'No credentials found for %s in .netrc' % \
420 parse_result.hostname
421 except netrc.NetrcParseError, e:
422 print >>sys.stderr, 'Error parsing .netrc file: %s' % e
423
424 if (username and password):
425 manifest_server = manifest_server.replace('://', '://%s:%s@' %
426 (username, password),
427 1)
428
368 try: 429 try:
369 server = xmlrpclib.Server(self.manifest.manifest_server) 430 server = xmlrpclib.Server(manifest_server)
370 if opt.smart_sync: 431 if opt.smart_sync:
371 p = self.manifest.manifestProject 432 p = self.manifest.manifestProject
372 b = p.GetBranch(p.CurrentBranch) 433 b = p.GetBranch(p.CurrentBranch)
diff --git a/subcmds/version.py b/subcmds/version.py
index 03195f88..243e3676 100644
--- a/subcmds/version.py
+++ b/subcmds/version.py
@@ -16,7 +16,7 @@
16import sys 16import sys
17from command import Command, MirrorSafeCommand 17from command import Command, MirrorSafeCommand
18from git_command import git 18from git_command import git
19from project import HEAD 19from git_refs import HEAD
20 20
21class Version(Command, MirrorSafeCommand): 21class Version(Command, MirrorSafeCommand):
22 wrapper_version = None 22 wrapper_version = None