migrate-history: clean up text

Rearrange to move usage first; explain missing repeat-import feature.
Adds an optimized copy from one jar file to another.

The SuperShady.java code should be attributed to scottb@squareup.com

Testing Done:
To test the updated jar-tool, I used one of our targets with about 100 jar files. The unpacked size is 303MB. The super-shady version takes under 7 seconds as compared to the default version’s time of a little over 3 minutes:

jsirois/twitter-sync ./super-shady-exemplar
real    3m4.610s
user    14m10.336s

sys    0m12.502s

zundel/super-shady-jar-tool ./super-shady-exemplar
real    0m6.256s
user    0m5.061s

sys    0m4.216s
Also, the super-shady version compression is much better.

-rw-r--r--  1 zundel  zundel  198500393 May 11 11:51 /tmp/exemplar-orig.jar
-rw-r--r--  1 zundel  zundel   84200072 May 12 04:55 /tmp/exemplar-super-shady.jar

I don’t know why that is, maybe a difference in the compression level passed to the zip algorithm. I did have to fix the unit test because it expected all entries in the zip file to be deflated. It might also be that using DEFLATE on directory entries and other zipfile entries that don’t need it is mushrooming the size of the file in the original jar-tool version. I did a check to make sure that all the extracted files were the same between both versions. I unpacked the jars with ‘unzip’ into 2 directories and ran ‘md5’ on each file in each unpacked dir

Bugs closed: 290

Reviewed at https://rbcommons.com/s/twitter/r/345/
Small style fixes and a descriptive re-name for the SuperShady
contribution after internal review.
Print bad keys when erroring out on new reviewboard creation
Remove ShutdownHook from jar-tool to prevent memory leak when running under nailgun.

This fixes a memory leak using nailgun with jar-tool caused by adding a Shutdown hook.

Testing Done:
Inspected with jvisualvm to find memory leak

In pants.ini, crank down the heap size:

 while [ t ] ; do PANTS_DEV=1 ~/Src/pants/pants goal bundle <target> --bundle-deployjar ; done

ran for a while and heap did not grow, whereas before it would die after just a few iterations with a 64 MB heap.

Bugs closed: 293

Reviewed at https://rbcommons.com/s/twitter/r/428/
Add pex_bootstrapper.bootstrap_pex_env() for simplified external pex bootstrapping.
In jar-tool, use apache commons FileUtils.moveFile to use copy when target of jar write is across filesystem boundary

This change updates File.rename() to use the apache commons FileUtils.moveFile() when writing out a jar file in JarBuilder.write().  This change uses a simple file rename when possible, or a copy if the two files can't be renamed (if the destination is on a different filesystem, for example.)

Testing Done:
Ran ./pants goal test tests/java/com/twitter/common/jar/tool

It would be great if Patrick could test out in their environment where this is a problem:

1.) in twitter/commons use `./pants goal binary --binary-deployjar src/java/com/twitter/common/jar/tool/:main` to produce a self-contained tool jar at dist/jar-tool.jar
2.) in pantsbuild/pants edit like so adapted for your local paths:
$ git diff
diff --git a/BUILD.tools b/BUILD.tools
index 0e39737..0562831 100644
--- a/BUILD.tools
+++ b/BUILD.tools
@@ -95,6 +95,7 @@ jar_library(name = 'scrooge-legacy-gen',

 jar_library(name = 'jar-tool',
             jars = [
-              jar(org = 'com.twitter.common', name = 'jar-tool', rev = '0.1.5')
+              jar(org = 'com.twitter.common', name = 'jar-tool', rev = '0.1.6-SNAPSHOT',
+                  mutable=True, url="file:///home/<your path here>/commons/dist/jar-tool.jar")
             ])

Bugs closed: 295

Reviewed at https://rbcommons.com/s/twitter/r/440/
In jar-tool, use apache commons FileUtils.moveFile to use copy when target of jar write is across filesystem boundary

This change updates File.rename() to use the apache commons FileUtils.moveFile() when writing out a jar file in JarBuilder.write().  This change uses a simple file rename when possible, or a copy if the two files can't be renamed (if the destination is on a different filesystem, for example.)

Testing Done:
Ran ./pants goal test tests/java/com/twitter/common/jar/tool

Bugs closed: 295

Reviewed at https://rbcommons.com/s/twitter/r/440/

Signed-off-by: John Sirois <jsirois@twitter.com>

RB_ID=376301
Close the open files before trying to move them
Merge pull request #298 from ericzundel/zundel/fix-corrupt-across-filesystems

Close the open files before trying to move them