Add format string option to git cl archive

This option lets users specify a format of the archive tags. E.g.
  git cl archive -p 'archived/{issue}-{branch}'
makes tags in the format
  archived/1234-foo-feature

Change-Id: Icb74cc68781cda21a70c802bd640543e92ae97a9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2116723
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
Commit-Queue: Tibor Goldschwendt <tiborg@chromium.org>
diff --git a/git_cl.py b/git_cl.py
index 84eaa97..36fd989 100755
--- a/git_cl.py
+++ b/git_cl.py
@@ -3515,12 +3515,12 @@
   return 0
 
 
-def GetArchiveTagForBranch(issue_num, branch_name, existing_tags):
+def GetArchiveTagForBranch(issue_num, branch_name, existing_tags, pattern):
   """Given a proposed tag name, returns a tag name that is guaranteed to be
   unique. If 'foo' is proposed but already exists, then 'foo-2' is used,
   or 'foo-3', and so on."""
 
-  proposed_tag = 'git-cl-archived-%s-%s' % (issue_num, branch_name)
+  proposed_tag = pattern.format(**{'issue': issue_num, 'branch': branch_name})
   for suffix_num in itertools.count(1):
     if suffix_num == 1:
       to_check = proposed_tag
@@ -3547,6 +3547,12 @@
       '-t', '--notags', action='store_true',
       help='Do not tag archived branches. '
            'Note: local commit history may be lost.')
+  parser.add_option(
+      '-p',
+      '--pattern',
+      default='git-cl-archived-{issue}-{branch}',
+      help='Format string for archive tags. '
+      'E.g. \'archived-{issue}-{branch}\'.')
 
   options, args = parser.parse_args(args)
   if args:
@@ -3568,8 +3574,8 @@
                              fine_grained=True,
                              max_processes=options.maxjobs)
   proposal = [(cl.GetBranch(),
-               GetArchiveTagForBranch(cl.GetIssue(), cl.GetBranch(),
-                                      tags))
+               GetArchiveTagForBranch(cl.GetIssue(), cl.GetBranch(), tags,
+                                      options.pattern))
               for cl, status in statuses
               if status in ('closed', 'rietveld-not-supported')]
   proposal.sort()