Bug 1369156 - Bump the minimum allowed version of cargo-vendor. r?froydnj draft
authorKartikaya Gupta <kgupta@mozilla.com>
Tue, 20 Jun 2017 16:04:07 -0400
changeset 597680 7fbac0a28c14b056398abe799cd4454337260ebf
parent 597679 de305ad8a8ee6749851369913173b9cf9657e35d
child 597681 f098f7cdbf12d373ee2f9b308f57bf904f4fa217
push id64992
push userkgupta@mozilla.com
push dateTue, 20 Jun 2017 20:06:07 +0000
reviewersfroydnj
bugs1369156
milestone56.0a1
Bug 1369156 - Bump the minimum allowed version of cargo-vendor. r?froydnj MozReview-Commit-ID: 2W7og1U8LBv
python/mozbuild/mozbuild/vendor_rust.py
--- a/python/mozbuild/mozbuild/vendor_rust.py
+++ b/python/mozbuild/mozbuild/vendor_rust.py
@@ -34,25 +34,28 @@ class VendorRust(MozbuildObject):
         '''
         out = subprocess.check_output([cargo, '--version']).splitlines()[0]
         if not out.startswith('cargo'):
             return False
         return LooseVersion(out.split()[1]) >= b'0.13'
 
     def check_cargo_vendor_version(self, cargo):
         '''
-        Ensure that cargo-vendor is new enough. cargo-vendor 0.1.3 and newer
-        strips out .gitattributes files which we want.
+        Ensure that cargo-vendor is new enough. cargo-vendor 0.1.11 and newer
+        strips out .orig and .rej files which we want.
         '''
         for l in subprocess.check_output([cargo, 'install', '--list']).splitlines():
-            # The line looks like `cargo-vendor v0.1.3:`
-            m = re.match('cargo-vendor v((\d\.)*\d):', l)
+            # The line looks like one of the following:
+            #  cargo-vendor v0.1.11:
+            #  cargo-vendor v0.1.11 (file:///path/to/local/build/cargo-vendor):
+            # and we want to extract the version part of it
+            m = re.match('cargo-vendor v((\d+\.)*\d+)', l)
             if m:
                 version = m.group(1)
-                return LooseVersion(version) >= b'0.1.3'
+                return LooseVersion(version) >= b'0.1.11'
         return False
 
     def check_modified_files(self):
         '''
         Ensure that there aren't any uncommitted changes to files
         in the working copy, since we're going to change some state
         on the user. Allow changes to Cargo.{toml,lock} since that's
         likely to be a common use case.
@@ -109,17 +112,17 @@ Please commit or stash these changes bef
             self.log(logging.DEBUG, 'cargo_version', {}, 'cargo is new enough')
         have_vendor = any(l.strip() == 'vendor' for l in subprocess.check_output([cargo, '--list']).splitlines())
         if not have_vendor:
             self.log(logging.INFO, 'installing', {}, 'Installing cargo-vendor (this may take a few minutes)...')
             env = self.check_openssl()
             self.run_process(args=[cargo, 'install', 'cargo-vendor'],
                              append_env=env)
         elif not self.check_cargo_vendor_version(cargo):
-            self.log(logging.INFO, 'cargo_vendor', {}, 'cargo-vendor >= 0.1.3 required; force-reinstalling (this may take a few minutes)...')
+            self.log(logging.INFO, 'cargo_vendor', {}, 'cargo-vendor >= 0.1.11 required; force-reinstalling (this may take a few minutes)...')
             env = self.check_openssl()
             self.run_process(args=[cargo, 'install', '--force', 'cargo-vendor'],
                              append_env=env)
         else:
             self.log(logging.DEBUG, 'cargo_vendor', {}, 'sufficiently new cargo-vendor is already installed')
 
         return cargo
 
@@ -269,17 +272,17 @@ license file's hash.
             ('gkrust-gtest', 'toolkit/library/gtest/rust'),
             ('mozjs_sys', 'js/src'),
             ('geckodriver', 'testing/geckodriver'),
         )
         for (lib, crate_root) in crates_and_roots:
             path = mozpath.join(self.topsrcdir, crate_root)
             # We do an |update -p| here to regenerate the Cargo.lock file with minimal changes. See bug 1324462
             self._run_command_in_srcdir(args=[cargo, 'update', '--manifest-path', mozpath.join(path, 'Cargo.toml'), '-p', lib])
-            self._run_command_in_srcdir(args=[cargo, 'vendor', '--sync', mozpath.join(path, 'Cargo.lock'), vendor_dir])
+            self._run_command_in_srcdir(args=[cargo, 'vendor', '--no-delete', '--sync', mozpath.join(path, 'Cargo.lock'), vendor_dir])
 
         if not self._check_licenses(vendor_dir):
             self.log(logging.ERROR, 'license_check_failed', {},
                      '''The changes from `mach vendor rust` will NOT be added to version control.''')
             sys.exit(1)
 
         self.repository.add_remove_files(vendor_dir)