OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/env python |
| 2 # Copyright 2016 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. |
| 5 |
| 6 """Clang-format 3-way merge driver. |
| 7 |
| 8 """ |
| 9 |
| 10 import subprocess |
| 11 import sys |
| 12 |
| 13 import clang_format |
| 14 |
| 15 def main(): |
| 16 if len(sys.argv) < 6: |
| 17 print('usage: %s <base> <current> <others> <ignored> <path in the tree>' % |
| 18 sys.argv[0]) |
| 19 sys.exit(1) |
| 20 |
| 21 base, current, others, _, file_name_in_tree = sys.argv[1:6] |
| 22 print '\nRunning clang-format 3-way merge driver on ' + file_name_in_tree |
| 23 |
| 24 try: |
| 25 tool = clang_format.FindClangFormatToolInChromiumTree() |
| 26 for fpath in base, current, others: |
| 27 subprocess.call([tool, '-i', '--style=chromium', fpath]) |
| 28 except clang_format.NotFoundError, e: |
| 29 print e |
| 30 print 'Failed to find clang-format. Falling-back on standard 3-way merge' |
| 31 |
| 32 return subprocess.call(['git', 'merge-file', '-Lcurrent', '-Lbase', '-Lother', |
| 33 current, base, others]) |
| 34 |
| 35 if __name__ == '__main__': |
| 36 sys.exit(main()) |
OLD | NEW |