Add git cl split.

`git cl split` splits a branch into smaller branches and
uploads CLs.

Change-Id: Ic41cdabdd6241008ff48766e31a8d9d07995f2b0
Reviewed-on: https://chromium-review.googlesource.com/439706
Commit-Queue: Francois Pierre Doray <fdoray@chromium.org>
Reviewed-by: Aaron Gable <agable@chromium.org>
diff --git a/git_cl.py b/git_cl.py
index 72694d9..bd9b479 100755
--- a/git_cl.py
+++ b/git_cl.py
@@ -59,6 +59,7 @@
 import presubmit_support
 import rietveld
 import scm
+import split_cl
 import subcommand
 import subprocess2
 import watchlists
@@ -4819,6 +4820,31 @@
   return cl.CMDUpload(options, args, orig_args)
 
 
+@subcommand.usage('--description=<description file>')
+def CMDsplit(parser, args):
+  """Splits a branch into smaller branches and uploads CLs.
+
+  Creates a branch and uploads a CL for each group of files modified in the
+  current branch that share a common OWNERS file. In the CL description and
+  commment, the string '$directory', is replaced with the directory containing
+  the shared OWNERS file.
+  """
+  parser.add_option("-d", "--description", dest="description_file",
+                    help="A text file containing a CL description. ")
+  parser.add_option("-c", "--comment", dest="comment_file",
+                    help="A text file containing a CL comment.")
+  options, _ = parser.parse_args(args)
+
+  if not options.description_file:
+    parser.error('No --description flag specified.')
+
+  def WrappedCMDupload(args):
+    return CMDupload(OptionParser(), args)
+
+  return split_cl.SplitCl(options.description_file, options.comment_file,
+                          Changelist, WrappedCMDupload)
+
+
 @subcommand.usage('DEPRECATED')
 def CMDdcommit(parser, args):
   """DEPRECATED: Used to commit the current changelist via git-svn."""