diff options
-rw-r--r-- | manifest_xml.py | 5 | ||||
-rwxr-xr-x | repo | 1 | ||||
-rw-r--r-- | subcmds/cherry_pick.py | 3 | ||||
-rw-r--r-- | subcmds/smartsync.py | 2 | ||||
-rw-r--r-- | subcmds/sync.py | 63 | ||||
-rw-r--r-- | subcmds/version.py | 2 |
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 | |||
21 | import xml.dom.minidom | 21 | import xml.dom.minidom |
22 | 22 | ||
23 | from git_config import GitConfig | 23 | from git_config import GitConfig |
24 | from project import RemoteSpec, Project, MetaProject, R_HEADS, HEAD | 24 | from git_refs import R_HEADS, HEAD |
25 | from project import RemoteSpec, Project, MetaProject | ||
25 | from error import ManifestParseError | 26 | from error import ManifestParseError |
26 | 27 | ||
27 | MANIFEST_FILE_NAME = 'manifest.xml' | 28 | MANIFEST_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: |
@@ -88,7 +88,6 @@ REPO_MAIN = S_repo + '/main.py' # main script | |||
88 | import optparse | 88 | import optparse |
89 | import os | 89 | import os |
90 | import re | 90 | import re |
91 | import readline | ||
92 | import subprocess | 91 | import subprocess |
93 | import sys | 92 | import sys |
94 | import urllib2 | 93 | import 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 | ||
16 | import sys, re | 16 | import re |
17 | import sys | ||
17 | from command import Command | 18 | from command import Command |
18 | from git_command import GitCommand | 19 | from 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 | ||
16 | from sync import Sync | 16 | from subcmds.sync import Sync |
17 | 17 | ||
18 | class Smartsync(Sync): | 18 | class 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 | ||
16 | import netrc | ||
16 | from optparse import SUPPRESS_HELP | 17 | from optparse import SUPPRESS_HELP |
17 | import os | 18 | import os |
18 | import re | 19 | import re |
@@ -21,6 +22,7 @@ import socket | |||
21 | import subprocess | 22 | import subprocess |
22 | import sys | 23 | import sys |
23 | import time | 24 | import time |
25 | import urlparse | ||
24 | import xmlrpclib | 26 | import xmlrpclib |
25 | 27 | ||
26 | try: | 28 | try: |
@@ -81,6 +83,18 @@ build as specified by the manifest-server element in the current | |||
81 | manifest. The -t/--smart-tag option is similar and allows you to | 83 | manifest. The -t/--smart-tag option is similar and allows you to |
82 | specify a custom tag/label. | 84 | specify a custom tag/label. |
83 | 85 | ||
86 | The -u/--manifest-server-username and -p/--manifest-server-password | ||
87 | options can be used to specify a username and password to authenticate | ||
88 | with the manifest server when using the -s or -t option. | ||
89 | |||
90 | If -u and -p are not specified when using the -s or -t option, '%prog' | ||
91 | will attempt to read authentication credentials for the manifest server | ||
92 | from the user's .netrc file. | ||
93 | |||
94 | '%prog' will not use authentication credentials from -u/-p or .netrc | ||
95 | if the manifest server specified in the manifest file already includes | ||
96 | credentials. | ||
97 | |||
84 | The -f/--force-broken option can be used to proceed with syncing | 98 | The -f/--force-broken option can be used to proceed with syncing |
85 | other projects if a project sync fails. | 99 | other 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 @@ | |||
16 | import sys | 16 | import sys |
17 | from command import Command, MirrorSafeCommand | 17 | from command import Command, MirrorSafeCommand |
18 | from git_command import git | 18 | from git_command import git |
19 | from project import HEAD | 19 | from git_refs import HEAD |
20 | 20 | ||
21 | class Version(Command, MirrorSafeCommand): | 21 | class Version(Command, MirrorSafeCommand): |
22 | wrapper_version = None | 22 | wrapper_version = None |