OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # coding: utf-8 | 2 # coding: utf-8 |
3 # | 3 # |
4 # Copyright 2007 Google Inc. | 4 # Copyright 2007 Google Inc. |
5 # | 5 # |
6 # Licensed under the Apache License, Version 2.0 (the "License"); | 6 # Licensed under the Apache License, Version 2.0 (the "License"); |
7 # you may not use this file except in compliance with the License. | 7 # you may not use this file except in compliance with the License. |
8 # You may obtain a copy of the License at | 8 # You may obtain a copy of the License at |
9 # | 9 # |
10 # http://www.apache.org/licenses/LICENSE-2.0 | 10 # http://www.apache.org/licenses/LICENSE-2.0 |
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
585 "already guesses the right VCS).")) | 585 "already guesses the right VCS).")) |
586 group.add_option("--emulate_svn_auto_props", action="store_true", | 586 group.add_option("--emulate_svn_auto_props", action="store_true", |
587 dest="emulate_svn_auto_props", default=False, | 587 dest="emulate_svn_auto_props", default=False, |
588 help=("Emulate Subversion's auto properties feature.")) | 588 help=("Emulate Subversion's auto properties feature.")) |
589 # Git-specific | 589 # Git-specific |
590 group = parser.add_option_group("Git-specific options") | 590 group = parser.add_option_group("Git-specific options") |
591 group.add_option("--git_similarity", action="store", dest="git_similarity", | 591 group.add_option("--git_similarity", action="store", dest="git_similarity", |
592 metavar="SIM", type="int", default=50, | 592 metavar="SIM", type="int", default=50, |
593 help=("Set the minimum similarity index for detecting renames " | 593 help=("Set the minimum similarity index for detecting renames " |
594 "and copies. See `git diff -C`. (default 50).")) | 594 "and copies. See `git diff -C`. (default 50).")) |
| 595 group.add_option("--git_no_find_copies", action="store_false", default=True, |
| 596 dest="git_find_copies", |
| 597 help=("Prevents git from looking for copies (default off).")) |
595 # Perforce-specific | 598 # Perforce-specific |
596 group = parser.add_option_group("Perforce-specific options " | 599 group = parser.add_option_group("Perforce-specific options " |
597 "(overrides P4 environment variables)") | 600 "(overrides P4 environment variables)") |
598 group.add_option("--p4_port", action="store", dest="p4_port", | 601 group.add_option("--p4_port", action="store", dest="p4_port", |
599 metavar="P4_PORT", default=None, | 602 metavar="P4_PORT", default=None, |
600 help=("Perforce server and port (optional)")) | 603 help=("Perforce server and port (optional)")) |
601 group.add_option("--p4_changelist", action="store", dest="p4_changelist", | 604 group.add_option("--p4_changelist", action="store", dest="p4_changelist", |
602 metavar="P4_CHANGELIST", default=None, | 605 metavar="P4_CHANGELIST", default=None, |
603 help=("Perforce changelist id")) | 606 help=("Perforce changelist id")) |
604 group.add_option("--p4_client", action="store", dest="p4_client", | 607 group.add_option("--p4_client", action="store", dest="p4_client", |
(...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1327 # This is confusing because the original file will not be shown on the | 1330 # This is confusing because the original file will not be shown on the |
1328 # review when a file is renamed. So, get a diff with ONLY deletes, then | 1331 # review when a file is renamed. So, get a diff with ONLY deletes, then |
1329 # append a diff (with rename detection), without deletes. | 1332 # append a diff (with rename detection), without deletes. |
1330 cmd = [ | 1333 cmd = [ |
1331 "git", "diff", "--no-color", "--no-ext-diff", "--full-index", | 1334 "git", "diff", "--no-color", "--no-ext-diff", "--full-index", |
1332 "--ignore-submodules", | 1335 "--ignore-submodules", |
1333 ] | 1336 ] |
1334 diff = RunShell( | 1337 diff = RunShell( |
1335 cmd + ["--no-renames", "--diff-filter=D"] + extra_args, | 1338 cmd + ["--no-renames", "--diff-filter=D"] + extra_args, |
1336 env=env, silent_ok=True) | 1339 env=env, silent_ok=True) |
| 1340 if self.options.git_find_copies: |
| 1341 similarity_options = ["--find-copies-harder", "-l100000", |
| 1342 "-C%s" % self.options.git_similarity ] |
| 1343 else: |
| 1344 similarity_options = ["-M%s" % self.options.git_similarity ] |
1337 diff += RunShell( | 1345 diff += RunShell( |
1338 cmd + ["--find-copies-harder", "-l100000", "--diff-filter=AMCRT", | 1346 cmd + ["--diff-filter=AMCRT"] + similarity_options + extra_args, |
1339 "-C%s" % self.options.git_similarity ] + extra_args, | |
1340 env=env, silent_ok=True) | 1347 env=env, silent_ok=True) |
1341 | 1348 |
1342 # The CL could be only file deletion or not. So accept silent diff for both | 1349 # The CL could be only file deletion or not. So accept silent diff for both |
1343 # commands then check for an empty diff manually. | 1350 # commands then check for an empty diff manually. |
1344 if not diff: | 1351 if not diff: |
1345 ErrorExit("No output from %s" % (cmd + extra_args)) | 1352 ErrorExit("No output from %s" % (cmd + extra_args)) |
1346 return diff | 1353 return diff |
1347 | 1354 |
1348 def GetUnknownFiles(self): | 1355 def GetUnknownFiles(self): |
1349 status = RunShell(["git", "ls-files", "--exclude-standard", "--others"], | 1356 status = RunShell(["git", "ls-files", "--exclude-standard", "--others"], |
(...skipping 1027 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2377 os.environ['LC_ALL'] = 'C' | 2384 os.environ['LC_ALL'] = 'C' |
2378 RealMain(sys.argv) | 2385 RealMain(sys.argv) |
2379 except KeyboardInterrupt: | 2386 except KeyboardInterrupt: |
2380 print | 2387 print |
2381 StatusUpdate("Interrupted.") | 2388 StatusUpdate("Interrupted.") |
2382 sys.exit(1) | 2389 sys.exit(1) |
2383 | 2390 |
2384 | 2391 |
2385 if __name__ == "__main__": | 2392 if __name__ == "__main__": |
2386 main() | 2393 main() |
OLD | NEW |