Bug 1399100, enhance client.py to warn when a local patch is registered for nspr/nss, based on feedback from glandium, r=fkiefer
authorKai Engert <kaie@kuix.de>
Mon, 18 Sep 2017 19:05:45 +0200
changeset 381555 6f71235ab648e765dfe898a730b197b5cc46f6e3
parent 381554 63281179bfe0ddbdfc3e03b746252a52e2f8ce3b
child 381556 7ee0accd38eefc04b056b83562685aa472300be3
push id51502
push userkwierso@gmail.com
push dateMon, 18 Sep 2017 23:25:22 +0000
treeherderautoland@cb2b8b4f4e04 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfkiefer
bugs1399100
milestone57.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1399100, enhance client.py to warn when a local patch is registered for nspr/nss, based on feedback from glandium, r=fkiefer
client.py
--- a/client.py
+++ b/client.py
@@ -99,28 +99,53 @@ def get_trailing_blank_line_state(depnam
       return "no blank line"
 
   if not lines[-1].strip():
       return "has blank line"
   else:
       return "no blank line"
 
 def update_nspr_or_nss(tag, depfile, destination, hgpath):
+  destination = destination.rstrip('/')
+  permanent_patch_dir = destination + '/patches'
+  temporary_patch_dir = destination + '.patches'
+  if os.path.exists(temporary_patch_dir):
+    print "please clean up leftover directory " + temporary_patch_dir
+    sys.exit(2)
+  warn_if_patch_exists(permanent_patch_dir)
+  # protect patch directory from being removed by do_hg_replace
+  shutil.move(permanent_patch_dir, temporary_patch_dir)
+  # now update the destination
   print "reverting to HG version of %s to get its blank line state" % depfile
   check_call_noisy([options.hg, 'revert', depfile])
   old_state = get_trailing_blank_line_state(depfile)
   print "old state of %s is: %s" % (depfile, old_state)
   do_hg_replace(destination, hgpath, tag, HG_EXCLUSIONS, options.hg)
   new_state = get_trailing_blank_line_state(depfile)
   print "new state of %s is: %s" % (depfile, new_state)
   if old_state == new_state:
     print "toggling blank line in: ", depfile
     toggle_trailing_blank_line(depfile)
   tag_file = destination + "/TAG-INFO"
   print >>file(tag_file, "w"), tag
+  # move patch directory back to a subdirectory
+  shutil.move(temporary_patch_dir, permanent_patch_dir)
+
+def warn_if_patch_exists(path):
+  # If the given patch directory exists and contains at least one file,
+  # then print warning and wait for the user to acknowledge.
+  if os.path.isdir(path) and os.listdir(path):
+    print "========================================"
+    print "WARNING: At least one patch file exists"
+    print "in directory: " + path
+    print "You must manually re-apply all patches"
+    print "after this script has completed!"
+    print "========================================"
+    raw_input("Press Enter to continue...")
+    return
 
 o = OptionParser(usage="client.py [options] update_nspr tagname | update_nss tagname | update_libffi tagname")
 o.add_option("--skip-mozilla", dest="skip_mozilla",
              action="store_true", default=False,
              help="Obsolete")
 
 o.add_option("--cvs", dest="cvs", default=os.environ.get('CVS', 'cvs'),
              help="The location of the cvs binary")