Merge "manifest: record the original revision when in -r mode."
diff --git a/manifest_xml.py b/manifest_xml.py
index be18547..a6364a7 100644
--- a/manifest_xml.py
+++ b/manifest_xml.py
@@ -21,7 +21,8 @@
import xml.dom.minidom
from git_config import GitConfig
-from project import RemoteSpec, Project, MetaProject, R_HEADS, HEAD
+from git_refs import R_HEADS, HEAD
+from project import RemoteSpec, Project, MetaProject
from error import ManifestParseError
MANIFEST_FILE_NAME = 'manifest.xml'
@@ -584,7 +585,7 @@
groups = node.getAttribute('groups')
groups = [x for x in re.split('[,\s]+', groups) if x]
- default_groups = ['default', 'name:%s' % name, 'path:%s' % path]
+ default_groups = ['all', 'name:%s' % name, 'path:%s' % path]
groups.extend(set(default_groups).difference(groups))
if self.IsMirror:
diff --git a/repo b/repo
index d6b46c8..f540cbb 100755
--- a/repo
+++ b/repo
@@ -88,7 +88,6 @@
import optparse
import os
import re
-import readline
import subprocess
import sys
import urllib2
diff --git a/subcmds/cherry_pick.py b/subcmds/cherry_pick.py
index 7890af4..7a6d4c2 100644
--- a/subcmds/cherry_pick.py
+++ b/subcmds/cherry_pick.py
@@ -13,7 +13,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-import sys, re
+import re
+import sys
from command import Command
from git_command import GitCommand
diff --git a/subcmds/smartsync.py b/subcmds/smartsync.py
index 1edbd35..e164859 100644
--- a/subcmds/smartsync.py
+++ b/subcmds/smartsync.py
@@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from sync import Sync
+from subcmds.sync import Sync
class Smartsync(Sync):
common = True
diff --git a/subcmds/sync.py b/subcmds/sync.py
index cbf0dec..f573b98 100644
--- a/subcmds/sync.py
+++ b/subcmds/sync.py
@@ -13,6 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+import netrc
from optparse import SUPPRESS_HELP
import os
import re
@@ -21,6 +22,7 @@
import subprocess
import sys
import time
+import urlparse
import xmlrpclib
try:
@@ -81,6 +83,18 @@
manifest. The -t/--smart-tag option is similar and allows you to
specify a custom tag/label.
+The -u/--manifest-server-username and -p/--manifest-server-password
+options can be used to specify a username and password to authenticate
+with the manifest server when using the -s or -t option.
+
+If -u and -p are not specified when using the -s or -t option, '%prog'
+will attempt to read authentication credentials for the manifest server
+from the user's .netrc file.
+
+'%prog' will not use authentication credentials from -u/-p or .netrc
+if the manifest server specified in the manifest file already includes
+credentials.
+
The -f/--force-broken option can be used to proceed with syncing
other projects if a project sync fails.
@@ -157,6 +171,12 @@
p.add_option('-t', '--smart-tag',
dest='smart_tag', action='store',
help='smart sync using manifest from a known tag')
+ p.add_option('-u', '--manifest-server-username', action='store',
+ dest='manifest_server_username',
+ help='username to authenticate with the manifest server')
+ p.add_option('-p', '--manifest-server-password', action='store',
+ dest='manifest_server_password',
+ help='password to authenticate with the manifest server')
g = p.add_option_group('repo Version options')
g.add_option('--no-repo-verify',
@@ -356,6 +376,14 @@
if opt.manifest_name and opt.smart_tag:
print >>sys.stderr, 'error: cannot combine -m and -t'
sys.exit(1)
+ if opt.manifest_server_username or opt.manifest_server_password:
+ if not (opt.smart_sync or opt.smart_tag):
+ print >>sys.stderr, 'error: -u and -p may only be combined with ' \
+ '-s or -t'
+ sys.exit(1)
+ if None in [opt.manifest_server_username, opt.manifest_server_password]:
+ print >>sys.stderr, 'error: both -u and -p must be given'
+ sys.exit(1)
if opt.manifest_name:
self.manifest.Override(opt.manifest_name)
@@ -365,8 +393,41 @@
print >>sys.stderr, \
'error: cannot smart sync: no manifest server defined in manifest'
sys.exit(1)
+
+ manifest_server = self.manifest.manifest_server
+
+ if not '@' in manifest_server:
+ username = None
+ password = None
+ if opt.manifest_server_username and opt.manifest_server_password:
+ username = opt.manifest_server_username
+ password = opt.manifest_server_password
+ else:
+ try:
+ info = netrc.netrc()
+ except IOError:
+ print >>sys.stderr, '.netrc file does not exist or could not be opened'
+ else:
+ try:
+ parse_result = urlparse.urlparse(manifest_server)
+ if parse_result.hostname:
+ username, _account, password = \
+ info.authenticators(parse_result.hostname)
+ except TypeError:
+ # TypeError is raised when the given hostname is not present
+ # in the .netrc file.
+ print >>sys.stderr, 'No credentials found for %s in .netrc' % \
+ parse_result.hostname
+ except netrc.NetrcParseError, e:
+ print >>sys.stderr, 'Error parsing .netrc file: %s' % e
+
+ if (username and password):
+ manifest_server = manifest_server.replace('://', '://%s:%s@' %
+ (username, password),
+ 1)
+
try:
- server = xmlrpclib.Server(self.manifest.manifest_server)
+ server = xmlrpclib.Server(manifest_server)
if opt.smart_sync:
p = self.manifest.manifestProject
b = p.GetBranch(p.CurrentBranch)
diff --git a/subcmds/version.py b/subcmds/version.py
index 03195f8..243e367 100644
--- a/subcmds/version.py
+++ b/subcmds/version.py
@@ -16,7 +16,7 @@
import sys
from command import Command, MirrorSafeCommand
from git_command import git
-from project import HEAD
+from git_refs import HEAD
class Version(Command, MirrorSafeCommand):
wrapper_version = None