From e12c85c4d43e4e1d31cc816befcf25f8f6d63004 Mon Sep 17 00:00:00 2001 From: Gareth Rees Date: Tue, 13 Sep 2016 12:41:52 +0100 Subject: [PATCH] Support for customer task branches. Copied from Perforce Change: 192340 ServerID: perforce.ravenbrook.com --- mps/tool/branch | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/mps/tool/branch b/mps/tool/branch index c8456ea3362..081274209ad 100755 --- a/mps/tool/branch +++ b/mps/tool/branch @@ -40,9 +40,7 @@ PARENT_FILESPEC_RE = r'{}({})(?:/|$)'.format(PROJECT_FILESPEC_RE, PARENT_RE) TASK_RE = r'[a-zA-Z][a-zA-Z0-9._-]*' TASK_BRANCH_RE = r'branch/(\d\d\d\d-\d\d-\d\d)/({})'.format(TASK_RE) VERSION_RE = r'\d+\.\d+' -VERSION_BRANCH_RE = (r'(?:custom/({})/)?version/({})' - .format(CUSTOMER_RE, VERSION_RE)) -CHILD_RE = r'(?:{}|{})$'.format(TASK_BRANCH_RE, VERSION_BRANCH_RE) +CHILD_RE = r'(?:custom/({})/)?(?:{}|version/({}))$'.format(CUSTOMER_RE, TASK_BRANCH_RE, VERSION_RE) TASK_BRANCH_ENTRY = ''' @@ -151,7 +149,10 @@ def main(argv): if args.task: if not re.match(TASK_RE, args.task): raise Error(fmt("Invalid task: {task}")) - args.child = fmt('branch/{date}/{task}') + if args.parent == 'master': + args.child = fmt('branch/{date}/{task}') + else: + args.child = fmt('custom/{customer}/branch/{date}/{task}') print(fmt("child={child}")) elif args.version: # Deduce version number from code/version.c. @@ -170,9 +171,9 @@ def main(argv): m = re.match(CHILD_RE, args.child) if not m: raise Error(fmt("Invalid child: {child}")) - if not args.task and args.customer != m.group(3): + if args.customer != m.group(1): raise Error(fmt("Customer mismatch between {parent} and {child}.")) - args.date, args.task, _, args.version = m.groups() + _, args.date, args.task, args.version = m.groups() if not args.description: args.description = fmt("Branching {parent} to {child}.") @@ -254,8 +255,8 @@ def main(argv): return ''.join([d['data'] for d in p4.run('print', filespec) if d['code'] == 'text']) - if not args.version: - # Task branch + if not args.version and not args.customer: + # Public task branch register('{depot}/project/{project}/branch/index.html', '(?=\n)', TASK_BRANCH_ENTRY) args.git_name = fmt('{project}-{task}') @@ -312,6 +313,8 @@ if __name__ == '__main__': # # 2016-02-13 RB Adapting to Git Fusion 2. # +# 2016-09-13 GDR Support for customer task branches. +# # # C. COPYRIGHT AND LICENCE #