summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--manifest_xml.py2
-rw-r--r--project.py46
-rw-r--r--subcmds/forall.py7
-rw-r--r--subcmds/sync.py9
-rw-r--r--subcmds/upload.py2
5 files changed, 55 insertions, 11 deletions
diff --git a/manifest_xml.py b/manifest_xml.py
index 817a1c80..b6f75477 100644
--- a/manifest_xml.py
+++ b/manifest_xml.py
@@ -27,7 +27,7 @@ else:
27 import imp 27 import imp
28 import urlparse 28 import urlparse
29 urllib = imp.new_module('urllib') 29 urllib = imp.new_module('urllib')
30 urllib.parse = urlparse 30 urllib.parse = urlparse.urlparse
31 31
32from git_config import GitConfig 32from git_config import GitConfig
33from git_refs import R_HEADS, HEAD 33from git_refs import R_HEADS, HEAD
diff --git a/project.py b/project.py
index 5a7a6ca8..679dccc1 100644
--- a/project.py
+++ b/project.py
@@ -1728,9 +1728,8 @@ class Project(object):
1728 remote = self.GetRemote(self.remote.name) 1728 remote = self.GetRemote(self.remote.name)
1729 bundle_url = remote.url + '/clone.bundle' 1729 bundle_url = remote.url + '/clone.bundle'
1730 bundle_url = GitConfig.ForUser().UrlInsteadOf(bundle_url) 1730 bundle_url = GitConfig.ForUser().UrlInsteadOf(bundle_url)
1731 if GetSchemeFromUrl(bundle_url) in ('persistent-http', 'persistent-https'): 1731 if GetSchemeFromUrl(bundle_url) not in (
1732 bundle_url = bundle_url[len('persistent-'):] 1732 'http', 'https', 'persistent-http', 'persistent-https'):
1733 if GetSchemeFromUrl(bundle_url) not in ('http', 'https'):
1734 return False 1733 return False
1735 1734
1736 bundle_dst = os.path.join(self.gitdir, 'clone.bundle') 1735 bundle_dst = os.path.join(self.gitdir, 'clone.bundle')
@@ -1779,9 +1778,11 @@ class Project(object):
1779 os.remove(tmpPath) 1778 os.remove(tmpPath)
1780 if 'http_proxy' in os.environ and 'darwin' == sys.platform: 1779 if 'http_proxy' in os.environ and 'darwin' == sys.platform:
1781 cmd += ['--proxy', os.environ['http_proxy']] 1780 cmd += ['--proxy', os.environ['http_proxy']]
1782 cookiefile = GitConfig.ForUser().GetString('http.cookiefile') 1781 cookiefile = self._GetBundleCookieFile(srcUrl)
1783 if cookiefile: 1782 if cookiefile:
1784 cmd += ['--cookie', cookiefile] 1783 cmd += ['--cookie', cookiefile]
1784 if srcUrl.startswith('persistent-'):
1785 srcUrl = srcUrl[len('persistent-'):]
1785 cmd += [srcUrl] 1786 cmd += [srcUrl]
1786 1787
1787 if IsTrace(): 1788 if IsTrace():
@@ -1804,7 +1805,7 @@ class Project(object):
1804 return False 1805 return False
1805 1806
1806 if os.path.exists(tmpPath): 1807 if os.path.exists(tmpPath):
1807 if curlret == 0 and os.stat(tmpPath).st_size > 16: 1808 if curlret == 0 and self._IsValidBundle(tmpPath):
1808 os.rename(tmpPath, dstPath) 1809 os.rename(tmpPath, dstPath)
1809 return True 1810 return True
1810 else: 1811 else:
@@ -1813,6 +1814,41 @@ class Project(object):
1813 else: 1814 else:
1814 return False 1815 return False
1815 1816
1817 def _IsValidBundle(self, path):
1818 try:
1819 with open(path) as f:
1820 if f.read(16) == '# v2 git bundle\n':
1821 return True
1822 else:
1823 print("Invalid clone.bundle file; ignoring.", file=sys.stderr)
1824 return False
1825 except OSError:
1826 return False
1827
1828 def _GetBundleCookieFile(self, url):
1829 if url.startswith('persistent-'):
1830 try:
1831 p = subprocess.Popen(
1832 ['git-remote-persistent-https', '-print_config', url],
1833 stdin=subprocess.PIPE, stdout=subprocess.PIPE,
1834 stderr=subprocess.PIPE)
1835 prefix = 'http.cookiefile='
1836 for line in p.stdout:
1837 line = line.strip()
1838 if line.startswith(prefix):
1839 return line[len(prefix):]
1840 if p.wait():
1841 line = iter(p.stderr).next()
1842 if ' -print_config' in line:
1843 pass # Persistent proxy doesn't support -print_config.
1844 else:
1845 print(line + p.stderr.read(), file=sys.stderr)
1846 except OSError as e:
1847 if e.errno == errno.ENOENT:
1848 pass # No persistent proxy.
1849 raise
1850 return GitConfig.ForUser().GetString('http.cookiefile')
1851
1816 def _Checkout(self, rev, quiet=False): 1852 def _Checkout(self, rev, quiet=False):
1817 cmd = ['checkout'] 1853 cmd = ['checkout']
1818 if quiet: 1854 if quiet:
diff --git a/subcmds/forall.py b/subcmds/forall.py
index 7d5f7794..e2a420a9 100644
--- a/subcmds/forall.py
+++ b/subcmds/forall.py
@@ -260,7 +260,12 @@ without iterating through the remaining projects.
260 first = False 260 first = False
261 else: 261 else:
262 out.nl() 262 out.nl()
263 out.project('project %s/', project.relpath) 263
264 if mirror:
265 project_header_path = project.name
266 else:
267 project_header_path = project.relpath
268 out.project('project %s/', project_header_path)
264 out.nl() 269 out.nl()
265 out.flush() 270 out.flush()
266 if errbuf: 271 if errbuf:
diff --git a/subcmds/sync.py b/subcmds/sync.py
index b34787d2..930211c1 100644
--- a/subcmds/sync.py
+++ b/subcmds/sync.py
@@ -34,7 +34,7 @@ else:
34 import urlparse 34 import urlparse
35 import xmlrpclib 35 import xmlrpclib
36 urllib = imp.new_module('urllib') 36 urllib = imp.new_module('urllib')
37 urllib.parse = urlparse 37 urllib.parse = urlparse.urlparse
38 xmlrpc = imp.new_module('xmlrpc') 38 xmlrpc = imp.new_module('xmlrpc')
39 xmlrpc.client = xmlrpclib 39 xmlrpc.client = xmlrpclib
40 40
@@ -526,6 +526,7 @@ later is required to fix a server side protocol bug.
526 (username, password), 526 (username, password),
527 1) 527 1)
528 528
529 manifest_name = opt.manifest_name
529 try: 530 try:
530 server = xmlrpc.client.Server(manifest_server) 531 server = xmlrpc.client.Server(manifest_server)
531 if opt.smart_sync: 532 if opt.smart_sync:
@@ -560,7 +561,7 @@ later is required to fix a server side protocol bug.
560 print('error: cannot write manifest to %s' % manifest_path, 561 print('error: cannot write manifest to %s' % manifest_path,
561 file=sys.stderr) 562 file=sys.stderr)
562 sys.exit(1) 563 sys.exit(1)
563 self.manifest.Override(manifest_name) 564 self._ReloadManifest(manifest_name)
564 else: 565 else:
565 print('error: %s' % manifest_str, file=sys.stderr) 566 print('error: %s' % manifest_str, file=sys.stderr)
566 sys.exit(1) 567 sys.exit(1)
@@ -593,7 +594,7 @@ later is required to fix a server side protocol bug.
593 mp.Sync_LocalHalf(syncbuf) 594 mp.Sync_LocalHalf(syncbuf)
594 if not syncbuf.Finish(): 595 if not syncbuf.Finish():
595 sys.exit(1) 596 sys.exit(1)
596 self._ReloadManifest(opt.manifest_name) 597 self._ReloadManifest(manifest_name)
597 if opt.jobs is None: 598 if opt.jobs is None:
598 self.jobs = self.manifest.default.sync_j 599 self.jobs = self.manifest.default.sync_j
599 all_projects = self.GetProjects(args, 600 all_projects = self.GetProjects(args,
@@ -618,7 +619,7 @@ later is required to fix a server side protocol bug.
618 # Iteratively fetch missing and/or nested unregistered submodules 619 # Iteratively fetch missing and/or nested unregistered submodules
619 previously_missing_set = set() 620 previously_missing_set = set()
620 while True: 621 while True:
621 self._ReloadManifest(opt.manifest_name) 622 self._ReloadManifest(manifest_name)
622 all_projects = self.GetProjects(args, 623 all_projects = self.GetProjects(args,
623 missing_ok=True, 624 missing_ok=True,
624 submodules_ok=opt.fetch_submodules) 625 submodules_ok=opt.fetch_submodules)
diff --git a/subcmds/upload.py b/subcmds/upload.py
index 0c74738c..fc17670c 100644
--- a/subcmds/upload.py
+++ b/subcmds/upload.py
@@ -224,6 +224,8 @@ Gerrit Code Review: http://code.google.com/p/gerrit/
224 224
225 b = {} 225 b = {}
226 for branch in avail: 226 for branch in avail:
227 if branch is None:
228 continue
227 name = branch.name 229 name = branch.name
228 date = branch.date 230 date = branch.date
229 commit_list = branch.commits 231 commit_list = branch.commits