| OLD | NEW |
| 1 # Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 """Gclient-specific SCM-specific operations.""" | 5 """Gclient-specific SCM-specific operations.""" |
| 6 | 6 |
| 7 import logging | 7 import logging |
| 8 import os | 8 import os |
| 9 import posixpath | 9 import posixpath |
| 10 import re | 10 import re |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 original_prefix = "--- " | 23 original_prefix = "--- " |
| 24 working_prefix = "+++ " | 24 working_prefix = "+++ " |
| 25 | 25 |
| 26 def __init__(self, relpath): | 26 def __init__(self, relpath): |
| 27 # Note that we always use '/' as the path separator to be | 27 # Note that we always use '/' as the path separator to be |
| 28 # consistent with svn's cygwin-style output on Windows | 28 # consistent with svn's cygwin-style output on Windows |
| 29 self._relpath = relpath.replace("\\", "/") | 29 self._relpath = relpath.replace("\\", "/") |
| 30 self._current_file = "" | 30 self._current_file = "" |
| 31 self._replacement_file = "" | 31 self._replacement_file = "" |
| 32 | 32 |
| 33 def SetCurrentFile(self, file): | 33 def SetCurrentFile(self, current_file): |
| 34 self._current_file = file | 34 self._current_file = current_file |
| 35 # Note that we always use '/' as the path separator to be | 35 # Note that we always use '/' as the path separator to be |
| 36 # consistent with svn's cygwin-style output on Windows | 36 # consistent with svn's cygwin-style output on Windows |
| 37 self._replacement_file = posixpath.join(self._relpath, file) | 37 self._replacement_file = posixpath.join(self._relpath, current_file) |
| 38 | 38 |
| 39 def ReplaceAndPrint(self, line): | 39 def ReplaceAndPrint(self, line): |
| 40 print(line.replace(self._current_file, self._replacement_file)) | 40 print(line.replace(self._current_file, self._replacement_file)) |
| 41 | 41 |
| 42 def Filter(self, line): | 42 def Filter(self, line): |
| 43 if (line.startswith(self.index_string)): | 43 if (line.startswith(self.index_string)): |
| 44 self.SetCurrentFile(line[len(self.index_string):]) | 44 self.SetCurrentFile(line[len(self.index_string):]) |
| 45 self.ReplaceAndPrint(line) | 45 self.ReplaceAndPrint(line) |
| 46 else: | 46 else: |
| 47 if (line.startswith(self.original_prefix) or | 47 if (line.startswith(self.original_prefix) or |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 if not command in dir(self): | 107 if not command in dir(self): |
| 108 raise gclient_utils.Error('Command %s not implemented in %s wrapper' % ( | 108 raise gclient_utils.Error('Command %s not implemented in %s wrapper' % ( |
| 109 command, self.scm_name)) | 109 command, self.scm_name)) |
| 110 | 110 |
| 111 return getattr(self, command)(options, args, file_list) | 111 return getattr(self, command)(options, args, file_list) |
| 112 | 112 |
| 113 | 113 |
| 114 class GitWrapper(SCMWrapper): | 114 class GitWrapper(SCMWrapper): |
| 115 """Wrapper for Git""" | 115 """Wrapper for Git""" |
| 116 | 116 |
| 117 def cleanup(self, options, args, file_list): | 117 @staticmethod |
| 118 def cleanup(options, args, file_list): |
| 118 """'Cleanup' the repo. | 119 """'Cleanup' the repo. |
| 119 | 120 |
| 120 There's no real git equivalent for the svn cleanup command, do a no-op. | 121 There's no real git equivalent for the svn cleanup command, do a no-op. |
| 121 """ | 122 """ |
| 122 __pychecker__ = 'unusednames=options,args,file_list' | |
| 123 | 123 |
| 124 def diff(self, options, args, file_list): | 124 def diff(self, options, args, file_list): |
| 125 __pychecker__ = 'unusednames=options,args,file_list' | |
| 126 merge_base = self._Run(['merge-base', 'HEAD', 'origin']) | 125 merge_base = self._Run(['merge-base', 'HEAD', 'origin']) |
| 127 self._Run(['diff', merge_base], redirect_stdout=False) | 126 self._Run(['diff', merge_base], redirect_stdout=False) |
| 128 | 127 |
| 129 def export(self, options, args, file_list): | 128 def export(self, options, args, file_list): |
| 130 """Export a clean directory tree into the given path. | 129 """Export a clean directory tree into the given path. |
| 131 | 130 |
| 132 Exports into the specified directory, creating the path if it does | 131 Exports into the specified directory, creating the path if it does |
| 133 already exist. | 132 already exist. |
| 134 """ | 133 """ |
| 135 __pychecker__ = 'unusednames=options,file_list' | |
| 136 assert len(args) == 1 | 134 assert len(args) == 1 |
| 137 export_path = os.path.abspath(os.path.join(args[0], self.relpath)) | 135 export_path = os.path.abspath(os.path.join(args[0], self.relpath)) |
| 138 if not os.path.exists(export_path): | 136 if not os.path.exists(export_path): |
| 139 os.makedirs(export_path) | 137 os.makedirs(export_path) |
| 140 self._Run(['checkout-index', '-a', '--prefix=%s/' % export_path], | 138 self._Run(['checkout-index', '-a', '--prefix=%s/' % export_path], |
| 141 redirect_stdout=False) | 139 redirect_stdout=False) |
| 142 | 140 |
| 143 def pack(self, options, args, file_list): | 141 def pack(self, options, args, file_list): |
| 144 """Generates a patch file which can be applied to the root of the | 142 """Generates a patch file which can be applied to the root of the |
| 145 repository. | 143 repository. |
| 146 | 144 |
| 147 The patch file is generated from a diff of the merge base of HEAD and | 145 The patch file is generated from a diff of the merge base of HEAD and |
| 148 its upstream branch. | 146 its upstream branch. |
| 149 """ | 147 """ |
| 150 __pychecker__ = 'unusednames=options,args,file_list' | |
| 151 path = os.path.join(self._root_dir, self.relpath) | 148 path = os.path.join(self._root_dir, self.relpath) |
| 152 merge_base = self._Run(['merge-base', 'HEAD', 'origin']) | 149 merge_base = self._Run(['merge-base', 'HEAD', 'origin']) |
| 153 command = ['diff', merge_base] | 150 command = ['diff', merge_base] |
| 154 filterer = DiffFilterer(self.relpath) | 151 filterer = DiffFilterer(self.relpath) |
| 155 scm.GIT.RunAndFilterOutput(command, path, False, False, filterer.Filter) | 152 scm.GIT.RunAndFilterOutput(command, path, False, False, filterer.Filter) |
| 156 | 153 |
| 157 def update(self, options, args, file_list): | 154 def update(self, options, args, file_list): |
| 158 """Runs git to update or transparently checkout the working copy. | 155 """Runs git to update or transparently checkout the working copy. |
| 159 | 156 |
| 160 All updated files will be appended to file_list. | 157 All updated files will be appended to file_list. |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 % (self.relpath, rev_str)) | 393 % (self.relpath, rev_str)) |
| 397 | 394 |
| 398 if verbose: | 395 if verbose: |
| 399 print "Checked out revision %s" % self.revinfo(options, (), None) | 396 print "Checked out revision %s" % self.revinfo(options, (), None) |
| 400 | 397 |
| 401 def revert(self, options, args, file_list): | 398 def revert(self, options, args, file_list): |
| 402 """Reverts local modifications. | 399 """Reverts local modifications. |
| 403 | 400 |
| 404 All reverted files will be appended to file_list. | 401 All reverted files will be appended to file_list. |
| 405 """ | 402 """ |
| 406 __pychecker__ = 'unusednames=args' | |
| 407 path = os.path.join(self._root_dir, self.relpath) | 403 path = os.path.join(self._root_dir, self.relpath) |
| 408 if not os.path.isdir(path): | 404 if not os.path.isdir(path): |
| 409 # revert won't work if the directory doesn't exist. It needs to | 405 # revert won't work if the directory doesn't exist. It needs to |
| 410 # checkout instead. | 406 # checkout instead. |
| 411 print("\n_____ %s is missing, synching instead" % self.relpath) | 407 print("\n_____ %s is missing, synching instead" % self.relpath) |
| 412 # Don't reuse the args. | 408 # Don't reuse the args. |
| 413 return self.update(options, [], file_list) | 409 return self.update(options, [], file_list) |
| 414 | 410 |
| 415 default_rev = "refs/heads/master" | 411 default_rev = "refs/heads/master" |
| 416 url, deps_revision = gclient_utils.SplitUrlRevision(self.url) | 412 _, deps_revision = gclient_utils.SplitUrlRevision(self.url) |
| 417 if not deps_revision: | 413 if not deps_revision: |
| 418 deps_revision = default_rev | 414 deps_revision = default_rev |
| 419 if deps_revision.startswith('refs/heads/'): | 415 if deps_revision.startswith('refs/heads/'): |
| 420 deps_revision = deps_revision.replace('refs/heads/', 'origin/') | 416 deps_revision = deps_revision.replace('refs/heads/', 'origin/') |
| 421 | 417 |
| 422 files = self._Run(['diff', deps_revision, '--name-only']).split() | 418 files = self._Run(['diff', deps_revision, '--name-only']).split() |
| 423 self._Run(['reset', '--hard', deps_revision], redirect_stdout=False) | 419 self._Run(['reset', '--hard', deps_revision], redirect_stdout=False) |
| 424 file_list.extend([os.path.join(self.checkout_path, f) for f in files]) | 420 file_list.extend([os.path.join(self.checkout_path, f) for f in files]) |
| 425 | 421 |
| 426 def revinfo(self, options, args, file_list): | 422 def revinfo(self, options, args, file_list): |
| 427 """Display revision""" | 423 """Display revision""" |
| 428 __pychecker__ = 'unusednames=options,args,file_list' | |
| 429 return self._Run(['rev-parse', 'HEAD']) | 424 return self._Run(['rev-parse', 'HEAD']) |
| 430 | 425 |
| 431 def runhooks(self, options, args, file_list): | 426 def runhooks(self, options, args, file_list): |
| 432 self.status(options, args, file_list) | 427 self.status(options, args, file_list) |
| 433 | 428 |
| 434 def status(self, options, args, file_list): | 429 def status(self, options, args, file_list): |
| 435 """Display status information.""" | 430 """Display status information.""" |
| 436 __pychecker__ = 'unusednames=options,args' | |
| 437 if not os.path.isdir(self.checkout_path): | 431 if not os.path.isdir(self.checkout_path): |
| 438 print('\n________ couldn\'t run status in %s:\nThe directory ' | 432 print('\n________ couldn\'t run status in %s:\nThe directory ' |
| 439 'does not exist.' % self.checkout_path) | 433 'does not exist.' % self.checkout_path) |
| 440 else: | 434 else: |
| 441 merge_base = self._Run(['merge-base', 'HEAD', 'origin']) | 435 merge_base = self._Run(['merge-base', 'HEAD', 'origin']) |
| 442 self._Run(['diff', '--name-status', merge_base], redirect_stdout=False) | 436 self._Run(['diff', '--name-status', merge_base], redirect_stdout=False) |
| 443 files = self._Run(['diff', '--name-only', merge_base]).split() | 437 files = self._Run(['diff', '--name-only', merge_base]).split() |
| 444 file_list.extend([os.path.join(self.checkout_path, f) for f in files]) | 438 file_list.extend([os.path.join(self.checkout_path, f) for f in files]) |
| 445 | 439 |
| 446 def FullUrlForRelativeUrl(self, url): | 440 def FullUrlForRelativeUrl(self, url): |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 567 + "%s" % ' '.join(rebase_cmd)) | 561 + "%s" % ' '.join(rebase_cmd)) |
| 568 | 562 |
| 569 print rebase_output.strip() | 563 print rebase_output.strip() |
| 570 if rebase_err: | 564 if rebase_err: |
| 571 print "Rebase produced error output:\n%s" % rebase_err.strip() | 565 print "Rebase produced error output:\n%s" % rebase_err.strip() |
| 572 if not verbose: | 566 if not verbose: |
| 573 # Make the output a little prettier. It's nice to have some | 567 # Make the output a little prettier. It's nice to have some |
| 574 # whitespace between projects when syncing. | 568 # whitespace between projects when syncing. |
| 575 print "" | 569 print "" |
| 576 | 570 |
| 577 def _CheckMinVersion(self, min_version): | 571 @staticmethod |
| 572 def _CheckMinVersion(min_version): |
| 578 (ok, current_version) = scm.GIT.AssertVersion(min_version) | 573 (ok, current_version) = scm.GIT.AssertVersion(min_version) |
| 579 if not ok: | 574 if not ok: |
| 580 raise gclient_utils.Error('git version %s < minimum required %s' % | 575 raise gclient_utils.Error('git version %s < minimum required %s' % |
| 581 (current_version, min_version)) | 576 (current_version, min_version)) |
| 582 | 577 |
| 583 def _IsRebasing(self): | 578 def _IsRebasing(self): |
| 584 # Check for any of REBASE-i/REBASE-m/REBASE/AM. Unfortunately git doesn't | 579 # Check for any of REBASE-i/REBASE-m/REBASE/AM. Unfortunately git doesn't |
| 585 # have a plumbing command to determine whether a rebase is in progress, so | 580 # have a plumbing command to determine whether a rebase is in progress, so |
| 586 # for now emualate (more-or-less) git-rebase.sh / git-completion.bash | 581 # for now emualate (more-or-less) git-rebase.sh / git-completion.bash |
| 587 g = os.path.join(self.checkout_path, '.git') | 582 g = os.path.join(self.checkout_path, '.git') |
| 588 return ( | 583 return ( |
| 589 os.path.isdir(os.path.join(g, "rebase-merge")) or | 584 os.path.isdir(os.path.join(g, "rebase-merge")) or |
| 590 os.path.isdir(os.path.join(g, "rebase-apply"))) | 585 os.path.isdir(os.path.join(g, "rebase-apply"))) |
| 591 | 586 |
| 592 def _CheckClean(self, rev_str): | 587 def _CheckClean(self, rev_str): |
| 593 # Make sure the tree is clean; see git-rebase.sh for reference | 588 # Make sure the tree is clean; see git-rebase.sh for reference |
| 594 try: | 589 try: |
| 595 scm.GIT.Capture(['update-index', '--ignore-submodules', '--refresh'], | 590 scm.GIT.Capture(['update-index', '--ignore-submodules', '--refresh'], |
| 596 self.checkout_path, print_error=False) | 591 self.checkout_path, print_error=False) |
| 597 except gclient_utils.CheckCallError, e: | 592 except gclient_utils.CheckCallError: |
| 598 raise gclient_utils.Error('\n____ %s%s\n' | 593 raise gclient_utils.Error('\n____ %s%s\n' |
| 599 '\tYou have unstaged changes.\n' | 594 '\tYou have unstaged changes.\n' |
| 600 '\tPlease commit, stash, or reset.\n' | 595 '\tPlease commit, stash, or reset.\n' |
| 601 % (self.relpath, rev_str)) | 596 % (self.relpath, rev_str)) |
| 602 try: | 597 try: |
| 603 scm.GIT.Capture(['diff-index', '--cached', '--name-status', '-r', | 598 scm.GIT.Capture(['diff-index', '--cached', '--name-status', '-r', |
| 604 '--ignore-submodules', 'HEAD', '--'], self.checkout_path, | 599 '--ignore-submodules', 'HEAD', '--'], self.checkout_path, |
| 605 print_error=False) | 600 print_error=False) |
| 606 except gclient_utils.CheckCallError, e: | 601 except gclient_utils.CheckCallError: |
| 607 raise gclient_utils.Error('\n____ %s%s\n' | 602 raise gclient_utils.Error('\n____ %s%s\n' |
| 608 '\tYour index contains uncommitted changes\n' | 603 '\tYour index contains uncommitted changes\n' |
| 609 '\tPlease commit, stash, or reset.\n' | 604 '\tPlease commit, stash, or reset.\n' |
| 610 % (self.relpath, rev_str)) | 605 % (self.relpath, rev_str)) |
| 611 | 606 |
| 612 def _CheckDetachedHead(self, rev_str): | 607 def _CheckDetachedHead(self, rev_str): |
| 613 # HEAD is detached. Make sure it is safe to move away from (i.e., it is | 608 # HEAD is detached. Make sure it is safe to move away from (i.e., it is |
| 614 # reference by a commit). If not, error out -- most likely a rebase is | 609 # reference by a commit). If not, error out -- most likely a rebase is |
| 615 # in progress, try to detect so we can give a better error. | 610 # in progress, try to detect so we can give a better error. |
| 616 try: | 611 try: |
| 617 out, err = scm.GIT.Capture( | 612 _, _ = scm.GIT.Capture( |
| 618 ['name-rev', '--no-undefined', 'HEAD'], | 613 ['name-rev', '--no-undefined', 'HEAD'], |
| 619 self.checkout_path, | 614 self.checkout_path, |
| 620 print_error=False) | 615 print_error=False) |
| 621 except gclient_utils.CheckCallError, e: | 616 except gclient_utils.CheckCallError: |
| 622 # Commit is not contained by any rev. See if the user is rebasing: | 617 # Commit is not contained by any rev. See if the user is rebasing: |
| 623 if self._IsRebasing(): | 618 if self._IsRebasing(): |
| 624 # Punt to the user | 619 # Punt to the user |
| 625 raise gclient_utils.Error('\n____ %s%s\n' | 620 raise gclient_utils.Error('\n____ %s%s\n' |
| 626 '\tAlready in a conflict, i.e. (no branch).\n' | 621 '\tAlready in a conflict, i.e. (no branch).\n' |
| 627 '\tFix the conflict and run gclient again.\n' | 622 '\tFix the conflict and run gclient again.\n' |
| 628 '\tOr to abort run:\n\t\tgit-rebase --abort\n' | 623 '\tOr to abort run:\n\t\tgit-rebase --abort\n' |
| 629 '\tSee man git-rebase for details.\n' | 624 '\tSee man git-rebase for details.\n' |
| 630 % (self.relpath, rev_str)) | 625 % (self.relpath, rev_str)) |
| 631 # Let's just save off the commit so we can proceed. | 626 # Let's just save off the commit so we can proceed. |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 663 (args[0], sp.returncode)) | 658 (args[0], sp.returncode)) |
| 664 if output is not None: | 659 if output is not None: |
| 665 return output.strip() | 660 return output.strip() |
| 666 | 661 |
| 667 | 662 |
| 668 class SVNWrapper(SCMWrapper): | 663 class SVNWrapper(SCMWrapper): |
| 669 """ Wrapper for SVN """ | 664 """ Wrapper for SVN """ |
| 670 | 665 |
| 671 def cleanup(self, options, args, file_list): | 666 def cleanup(self, options, args, file_list): |
| 672 """Cleanup working copy.""" | 667 """Cleanup working copy.""" |
| 673 __pychecker__ = 'unusednames=file_list,options' | |
| 674 command = ['cleanup'] | 668 command = ['cleanup'] |
| 675 command.extend(args) | 669 command.extend(args) |
| 676 scm.SVN.Run(command, os.path.join(self._root_dir, self.relpath)) | 670 scm.SVN.Run(command, os.path.join(self._root_dir, self.relpath)) |
| 677 | 671 |
| 678 def diff(self, options, args, file_list): | 672 def diff(self, options, args, file_list): |
| 679 # NOTE: This function does not currently modify file_list. | 673 # NOTE: This function does not currently modify file_list. |
| 680 __pychecker__ = 'unusednames=file_list,options' | |
| 681 command = ['diff'] | 674 command = ['diff'] |
| 682 command.extend(args) | 675 command.extend(args) |
| 683 scm.SVN.Run(command, os.path.join(self._root_dir, self.relpath)) | 676 scm.SVN.Run(command, os.path.join(self._root_dir, self.relpath)) |
| 684 | 677 |
| 685 def export(self, options, args, file_list): | 678 def export(self, options, args, file_list): |
| 686 """Export a clean directory tree into the given path.""" | 679 """Export a clean directory tree into the given path.""" |
| 687 __pychecker__ = 'unusednames=file_list,options' | |
| 688 assert len(args) == 1 | 680 assert len(args) == 1 |
| 689 export_path = os.path.abspath(os.path.join(args[0], self.relpath)) | 681 export_path = os.path.abspath(os.path.join(args[0], self.relpath)) |
| 690 try: | 682 try: |
| 691 os.makedirs(export_path) | 683 os.makedirs(export_path) |
| 692 except OSError: | 684 except OSError: |
| 693 pass | 685 pass |
| 694 assert os.path.exists(export_path) | 686 assert os.path.exists(export_path) |
| 695 command = ['export', '--force', '.'] | 687 command = ['export', '--force', '.'] |
| 696 command.append(export_path) | 688 command.append(export_path) |
| 697 scm.SVN.Run(command, os.path.join(self._root_dir, self.relpath)) | 689 scm.SVN.Run(command, os.path.join(self._root_dir, self.relpath)) |
| 698 | 690 |
| 699 def pack(self, options, args, file_list): | 691 def pack(self, options, args, file_list): |
| 700 """Generates a patch file which can be applied to the root of the | 692 """Generates a patch file which can be applied to the root of the |
| 701 repository.""" | 693 repository.""" |
| 702 __pychecker__ = 'unusednames=file_list,options' | |
| 703 path = os.path.join(self._root_dir, self.relpath) | 694 path = os.path.join(self._root_dir, self.relpath) |
| 704 command = ['diff'] | 695 command = ['diff'] |
| 705 command.extend(args) | 696 command.extend(args) |
| 706 | 697 |
| 707 filterer = DiffFilterer(self.relpath) | 698 filterer = DiffFilterer(self.relpath) |
| 708 scm.SVN.RunAndFilterOutput(command, path, False, False, filterer.Filter) | 699 scm.SVN.RunAndFilterOutput(command, path, False, False, filterer.Filter) |
| 709 | 700 |
| 710 def update(self, options, args, file_list): | 701 def update(self, options, args, file_list): |
| 711 """Runs svn to update or transparently checkout the working copy. | 702 """Runs svn to update or transparently checkout the working copy. |
| 712 | 703 |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 840 os.path.join(checkout_path, filename)] | 831 os.path.join(checkout_path, filename)] |
| 841 command = self.AddAdditionalFlags(command, options, options.revision) | 832 command = self.AddAdditionalFlags(command, options, options.revision) |
| 842 scm.SVN.Run(command, self._root_dir) | 833 scm.SVN.Run(command, self._root_dir) |
| 843 | 834 |
| 844 def revert(self, options, args, file_list): | 835 def revert(self, options, args, file_list): |
| 845 """Reverts local modifications. Subversion specific. | 836 """Reverts local modifications. Subversion specific. |
| 846 | 837 |
| 847 All reverted files will be appended to file_list, even if Subversion | 838 All reverted files will be appended to file_list, even if Subversion |
| 848 doesn't know about them. | 839 doesn't know about them. |
| 849 """ | 840 """ |
| 850 __pychecker__ = 'unusednames=args' | |
| 851 path = os.path.join(self._root_dir, self.relpath) | 841 path = os.path.join(self._root_dir, self.relpath) |
| 852 if not os.path.isdir(path): | 842 if not os.path.isdir(path): |
| 853 # svn revert won't work if the directory doesn't exist. It needs to | 843 # svn revert won't work if the directory doesn't exist. It needs to |
| 854 # checkout instead. | 844 # checkout instead. |
| 855 print("\n_____ %s is missing, synching instead" % self.relpath) | 845 print("\n_____ %s is missing, synching instead" % self.relpath) |
| 856 # Don't reuse the args. | 846 # Don't reuse the args. |
| 857 return self.update(options, [], file_list) | 847 return self.update(options, [], file_list) |
| 858 | 848 |
| 859 for file_status in scm.SVN.CaptureStatus(path): | 849 for file_status in scm.SVN.CaptureStatus(path): |
| 860 file_path = os.path.join(path, file_status[1]) | 850 file_path = os.path.join(path, file_status[1]) |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 893 # "svn up --revision BASE" achieve the same effect. | 883 # "svn up --revision BASE" achieve the same effect. |
| 894 scm.SVN.RunAndGetFileList(options, ['update', '--revision', 'BASE'], path, | 884 scm.SVN.RunAndGetFileList(options, ['update', '--revision', 'BASE'], path, |
| 895 file_list) | 885 file_list) |
| 896 except OSError, e: | 886 except OSError, e: |
| 897 # Maybe the directory disapeared meanwhile. We don't want it to throw an | 887 # Maybe the directory disapeared meanwhile. We don't want it to throw an |
| 898 # exception. | 888 # exception. |
| 899 logging.error('Failed to update:\n%s' % str(e)) | 889 logging.error('Failed to update:\n%s' % str(e)) |
| 900 | 890 |
| 901 def revinfo(self, options, args, file_list): | 891 def revinfo(self, options, args, file_list): |
| 902 """Display revision""" | 892 """Display revision""" |
| 903 __pychecker__ = 'unusednames=args,file_list,options' | |
| 904 return scm.SVN.CaptureBaseRevision(self.checkout_path) | 893 return scm.SVN.CaptureBaseRevision(self.checkout_path) |
| 905 | 894 |
| 906 def runhooks(self, options, args, file_list): | 895 def runhooks(self, options, args, file_list): |
| 907 self.status(options, args, file_list) | 896 self.status(options, args, file_list) |
| 908 | 897 |
| 909 def status(self, options, args, file_list): | 898 def status(self, options, args, file_list): |
| 910 """Display status information.""" | 899 """Display status information.""" |
| 911 path = os.path.join(self._root_dir, self.relpath) | 900 path = os.path.join(self._root_dir, self.relpath) |
| 912 command = ['status'] | 901 command = ['status'] |
| 913 command.extend(args) | 902 command.extend(args) |
| 914 if not os.path.isdir(path): | 903 if not os.path.isdir(path): |
| 915 # svn status won't work if the directory doesn't exist. | 904 # svn status won't work if the directory doesn't exist. |
| 916 print("\n________ couldn't run \'%s\' in \'%s\':\nThe directory " | 905 print("\n________ couldn't run \'%s\' in \'%s\':\nThe directory " |
| 917 "does not exist." | 906 "does not exist." |
| 918 % (' '.join(command), path)) | 907 % (' '.join(command), path)) |
| 919 # There's no file list to retrieve. | 908 # There's no file list to retrieve. |
| 920 else: | 909 else: |
| 921 scm.SVN.RunAndGetFileList(options, command, path, file_list) | 910 scm.SVN.RunAndGetFileList(options, command, path, file_list) |
| 922 | 911 |
| 923 def FullUrlForRelativeUrl(self, url): | 912 def FullUrlForRelativeUrl(self, url): |
| 924 # Find the forth '/' and strip from there. A bit hackish. | 913 # Find the forth '/' and strip from there. A bit hackish. |
| 925 return '/'.join(self.url.split('/')[:4]) + url | 914 return '/'.join(self.url.split('/')[:4]) + url |
| 926 | 915 |
| 927 def AddAdditionalFlags(self, command, options, revision): | 916 @staticmethod |
| 917 def AddAdditionalFlags(command, options, revision): |
| 928 """Add additional flags to command depending on what options are set. | 918 """Add additional flags to command depending on what options are set. |
| 929 command should be a list of strings that represents an svn command. | 919 command should be a list of strings that represents an svn command. |
| 930 | 920 |
| 931 This method returns a new list to be used as a command.""" | 921 This method returns a new list to be used as a command.""" |
| 932 new_command = command[:] | 922 new_command = command[:] |
| 933 if revision: | 923 if revision: |
| 934 new_command.extend(['--revision', str(revision).strip()]) | 924 new_command.extend(['--revision', str(revision).strip()]) |
| 935 # --force was added to 'svn update' in svn 1.5. | 925 # --force was added to 'svn update' in svn 1.5. |
| 936 if options.force and scm.SVN.AssertVersion("1.5")[0]: | 926 if options.force and scm.SVN.AssertVersion("1.5")[0]: |
| 937 new_command.append('--force') | 927 new_command.append('--force') |
| 938 return new_command | 928 return new_command |
| OLD | NEW |