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 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
579 dest="send_patch", default=False, | 579 dest="send_patch", default=False, |
580 help="Same as --send_mail, but include diff as an " | 580 help="Same as --send_mail, but include diff as an " |
581 "attachment, and prepend email subject with 'PATCH:'.") | 581 "attachment, and prepend email subject with 'PATCH:'.") |
582 group.add_option("--vcs", action="store", dest="vcs", | 582 group.add_option("--vcs", action="store", dest="vcs", |
583 metavar="VCS", default=None, | 583 metavar="VCS", default=None, |
584 help=("Version control system (optional, usually upload.py " | 584 help=("Version control system (optional, usually upload.py " |
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 |
| 590 group = parser.add_option_group("Git-specific options") |
| 591 group.add_option("--git_similarity", action="store", dest="git_similarity", |
| 592 metavar="SIM", type="int", default=50, |
| 593 help=("Set the minimum similarity index for detecting renames " |
| 594 "and copies. See `git diff -C`. (default 50).")) |
589 # Perforce-specific | 595 # Perforce-specific |
590 group = parser.add_option_group("Perforce-specific options " | 596 group = parser.add_option_group("Perforce-specific options " |
591 "(overrides P4 environment variables)") | 597 "(overrides P4 environment variables)") |
592 group.add_option("--p4_port", action="store", dest="p4_port", | 598 group.add_option("--p4_port", action="store", dest="p4_port", |
593 metavar="P4_PORT", default=None, | 599 metavar="P4_PORT", default=None, |
594 help=("Perforce server and port (optional)")) | 600 help=("Perforce server and port (optional)")) |
595 group.add_option("--p4_changelist", action="store", dest="p4_changelist", | 601 group.add_option("--p4_changelist", action="store", dest="p4_changelist", |
596 metavar="P4_CHANGELIST", default=None, | 602 metavar="P4_CHANGELIST", default=None, |
597 help=("Perforce changelist id")) | 603 help=("Perforce changelist id")) |
598 group.add_option("--p4_client", action="store", dest="p4_client", | 604 group.add_option("--p4_client", action="store", dest="p4_client", |
(...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1322 # review when a file is renamed. So, get a diff with ONLY deletes, then | 1328 # review when a file is renamed. So, get a diff with ONLY deletes, then |
1323 # append a diff (with rename detection), without deletes. | 1329 # append a diff (with rename detection), without deletes. |
1324 cmd = [ | 1330 cmd = [ |
1325 "git", "diff", "--no-color", "--no-ext-diff", "--full-index", | 1331 "git", "diff", "--no-color", "--no-ext-diff", "--full-index", |
1326 "--ignore-submodules", | 1332 "--ignore-submodules", |
1327 ] | 1333 ] |
1328 diff = RunShell( | 1334 diff = RunShell( |
1329 cmd + ["--no-renames", "--diff-filter=D"] + extra_args, | 1335 cmd + ["--no-renames", "--diff-filter=D"] + extra_args, |
1330 env=env, silent_ok=True) | 1336 env=env, silent_ok=True) |
1331 diff += RunShell( | 1337 diff += RunShell( |
1332 cmd + ["--find-copies-harder", "-l100000", "--diff-filter=AMCRT"] | 1338 cmd + ["--find-copies-harder", "-l100000", "--diff-filter=AMCRT", |
1333 + extra_args, | 1339 "-C%s" % self.options.git_similarity ] + extra_args, |
1334 env=env, silent_ok=True) | 1340 env=env, silent_ok=True) |
1335 | 1341 |
1336 # The CL could be only file deletion or not. So accept silent diff for both | 1342 # The CL could be only file deletion or not. So accept silent diff for both |
1337 # commands then check for an empty diff manually. | 1343 # commands then check for an empty diff manually. |
1338 if not diff: | 1344 if not diff: |
1339 ErrorExit("No output from %s" % (cmd + extra_args)) | 1345 ErrorExit("No output from %s" % (cmd + extra_args)) |
1340 return diff | 1346 return diff |
1341 | 1347 |
1342 def GetUnknownFiles(self): | 1348 def GetUnknownFiles(self): |
1343 status = RunShell(["git", "ls-files", "--exclude-standard", "--others"], | 1349 status = RunShell(["git", "ls-files", "--exclude-standard", "--others"], |
(...skipping 1027 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2371 os.environ['LC_ALL'] = 'C' | 2377 os.environ['LC_ALL'] = 'C' |
2372 RealMain(sys.argv) | 2378 RealMain(sys.argv) |
2373 except KeyboardInterrupt: | 2379 except KeyboardInterrupt: |
2374 print | 2380 print |
2375 StatusUpdate("Interrupted.") | 2381 StatusUpdate("Interrupted.") |
2376 sys.exit(1) | 2382 sys.exit(1) |
2377 | 2383 |
2378 | 2384 |
2379 if __name__ == "__main__": | 2385 if __name__ == "__main__": |
2380 main() | 2386 main() |
OLD | NEW |