OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # | 2 # |
3 # Copyright 2008 Google Inc. All Rights Reserved. | 3 # Copyright 2008 Google Inc. All Rights Reserved. |
4 # | 4 # |
5 # Licensed under the Apache License, Version 2.0 (the "License"); | 5 # Licensed under the Apache License, Version 2.0 (the "License"); |
6 # you may not use this file except in compliance with the License. | 6 # you may not use this file except in compliance with the License. |
7 # You may obtain a copy of the License at | 7 # You may obtain a copy of the License at |
8 # | 8 # |
9 # http://www.apache.org/licenses/LICENSE-2.0 | 9 # http://www.apache.org/licenses/LICENSE-2.0 |
10 # | 10 # |
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
468 |entries| is a list of paths to check.""" | 468 |entries| is a list of paths to check.""" |
469 for path in paths: | 469 for path in paths: |
470 if os.path.exists(os.path.join(root, path, '.git')): | 470 if os.path.exists(os.path.join(root, path, '.git')): |
471 return True | 471 return True |
472 return False | 472 return False |
473 | 473 |
474 # ----------------------------------------------------------------------------- | 474 # ----------------------------------------------------------------------------- |
475 # SVN utils: | 475 # SVN utils: |
476 | 476 |
477 | 477 |
478 def RunSVN(args, in_directory): | 478 def RunSVN(options, args, in_directory): |
479 """Runs svn, sending output to stdout. | 479 """Runs svn, sending output to stdout. |
480 | 480 |
481 Args: | 481 Args: |
482 args: A sequence of command line parameters to be passed to svn. | 482 args: A sequence of command line parameters to be passed to svn. |
483 in_directory: The directory where svn is to be run. | 483 in_directory: The directory where svn is to be run. |
484 | 484 |
485 Raises: | 485 Raises: |
486 Error: An error occurred while running the svn command. | 486 Error: An error occurred while running the svn command. |
487 """ | 487 """ |
488 c = [SVN_COMMAND] | 488 c = [SVN_COMMAND] |
489 c.extend(args) | 489 c.extend(args) |
490 | 490 |
491 SubprocessCall(c, in_directory, options.stdout) | 491 SubprocessCall(c, in_directory, options.stdout) |
492 | 492 |
493 | 493 |
494 def CaptureSVN(args, in_directory=None, print_error=True): | 494 def CaptureSVN(options, args, in_directory): |
495 """Runs svn, capturing output sent to stdout as a string. | 495 """Runs svn, capturing output sent to stdout as a string. |
496 | 496 |
497 Args: | 497 Args: |
498 args: A sequence of command line parameters to be passed to svn. | 498 args: A sequence of command line parameters to be passed to svn. |
499 in_directory: The directory where svn is to be run. | 499 in_directory: The directory where svn is to be run. |
500 | 500 |
501 Returns: | 501 Returns: |
502 The output sent to stdout as a string. | 502 The output sent to stdout as a string. |
503 """ | 503 """ |
504 c = [SVN_COMMAND] | 504 c = [SVN_COMMAND] |
505 c.extend(args) | 505 c.extend(args) |
506 | 506 |
507 # *Sigh*: Windows needs shell=True, or else it won't search %PATH% for | 507 # *Sigh*: Windows needs shell=True, or else it won't search %PATH% for |
508 # the svn.exe executable, but shell=True makes subprocess on Linux fail | 508 # the svn.exe executable, but shell=True makes subprocess on Linux fail |
509 # when it's called with a list because it only tries to execute the | 509 # when it's called with a list because it only tries to execute the |
510 # first string ("svn"). | 510 # first string ("svn"). |
511 stderr = None | 511 return subprocess.Popen(c, cwd=in_directory, shell=(sys.platform == 'win32'), |
512 if print_error: | 512 stdout=subprocess.PIPE).communicate()[0] |
513 stderr = subprocess.PIPE | |
514 return subprocess.Popen(c, | |
515 cwd=in_directory, | |
516 shell=(sys.platform == 'win32'), | |
517 stdout=subprocess.PIPE, | |
518 stderr=stderr).communicate()[0] | |
519 | 513 |
520 | 514 |
521 def RunSVNAndGetFileList(options, args, in_directory, file_list): | 515 def RunSVNAndGetFileList(options, args, in_directory, file_list): |
522 """Runs svn checkout, update, or status, output to stdout. | 516 """Runs svn checkout, update, or status, output to stdout. |
523 | 517 |
524 The first item in args must be either "checkout", "update", or "status". | 518 The first item in args must be either "checkout", "update", or "status". |
525 | 519 |
526 svn's stdout is parsed to collect a list of files checked out or updated. | 520 svn's stdout is parsed to collect a list of files checked out or updated. |
527 These files are appended to file_list. svn's stdout is also printed to | 521 These files are appended to file_list. svn's stdout is also printed to |
528 sys.stdout as in RunSVN. | 522 sys.stdout as in RunSVN. |
(...skipping 26 matching lines...) Expand all Loading... |
555 pattern = { | 549 pattern = { |
556 'checkout': update_pattern, | 550 'checkout': update_pattern, |
557 'status': status_pattern, | 551 'status': status_pattern, |
558 'update': update_pattern, | 552 'update': update_pattern, |
559 }[args[0]] | 553 }[args[0]] |
560 | 554 |
561 SubprocessCallAndCapture(command, in_directory, options.stdout, | 555 SubprocessCallAndCapture(command, in_directory, options.stdout, |
562 pattern=pattern, capture_list=file_list) | 556 pattern=pattern, capture_list=file_list) |
563 | 557 |
564 | 558 |
565 def CaptureSVNInfo(relpath, in_directory=None, print_error=True): | 559 def CaptureSVNInfo(options, relpath, in_directory): |
566 """Returns a dictionary from the svn info output for the given file. | 560 """Returns a dictionary from the svn info output for the given file. |
567 | 561 |
568 Args: | 562 Args: |
569 relpath: The directory where the working copy resides relative to | 563 relpath: The directory where the working copy resides relative to |
570 the directory given by in_directory. | 564 the directory given by in_directory. |
571 in_directory: The directory where svn is to be run. | 565 in_directory: The directory where svn is to be run. |
572 """ | 566 """ |
573 output = CaptureSVN(["info", "--xml", relpath], in_directory, print_error) | 567 dom = ParseXML(CaptureSVN(options, ["info", "--xml", relpath], in_directory)) |
574 dom = ParseXML(output) | |
575 result = {} | 568 result = {} |
576 if dom: | 569 if dom: |
577 def C(item, f): | 570 def C(item, f): |
578 if item is not None: return f(item) | 571 if item is not None: return f(item) |
579 # /info/entry/ | 572 # /info/entry/ |
580 # url | 573 # url |
581 # reposityory/(root|uuid) | 574 # reposityory/(root|uuid) |
582 # wc-info/(schedule|depth) | 575 # wc-info/(schedule|depth) |
583 # commit/(author|date) | 576 # commit/(author|date) |
584 # str() the results because they may be returned as Unicode, which | 577 # str() the results because they may be returned as Unicode, which |
585 # interferes with the higher layers matching up things in the deps | 578 # interferes with the higher layers matching up things in the deps |
586 # dictionary. | 579 # dictionary. |
587 # TODO(maruel): Fix at higher level instead (!) | 580 # TODO(maruel): Fix at higher level instead (!) |
588 result['Repository Root'] = C(GetNamedNodeText(dom, 'root'), str) | 581 result['Repository Root'] = C(GetNamedNodeText(dom, 'root'), str) |
589 result['URL'] = C(GetNamedNodeText(dom, 'url'), str) | 582 result['URL'] = C(GetNamedNodeText(dom, 'url'), str) |
590 result['UUID'] = C(GetNamedNodeText(dom, 'uuid'), str) | 583 result['UUID'] = C(GetNamedNodeText(dom, 'uuid'), str) |
591 result['Revision'] = C(GetNodeNamedAttributeText(dom, 'entry', 'revision'), | 584 result['Revision'] = C(GetNodeNamedAttributeText(dom, 'entry', 'revision'), |
592 int) | 585 int) |
593 result['Node Kind'] = C(GetNodeNamedAttributeText(dom, 'entry', 'kind'), | 586 result['Node Kind'] = C(GetNodeNamedAttributeText(dom, 'entry', 'kind'), |
594 str) | 587 str) |
595 result['Schedule'] = C(GetNamedNodeText(dom, 'schedule'), str) | 588 result['Schedule'] = C(GetNamedNodeText(dom, 'schedule'), str) |
596 result['Path'] = C(GetNodeNamedAttributeText(dom, 'entry', 'path'), str) | 589 result['Path'] = C(GetNodeNamedAttributeText(dom, 'entry', 'path'), str) |
597 result['Copied From URL'] = C(GetNamedNodeText(dom, 'copy-from-url'), str) | 590 result['Copied From URL'] = C(GetNamedNodeText(dom, 'copy-from-url'), str) |
598 result['Copied From Rev'] = C(GetNamedNodeText(dom, 'copy-from-rev'), str) | 591 result['Copied From Rev'] = C(GetNamedNodeText(dom, 'copy-from-rev'), str) |
599 return result | 592 return result |
600 | 593 |
601 | 594 |
602 def CaptureSVNHeadRevision(url): | 595 def CaptureSVNHeadRevision(options, url): |
603 """Get the head revision of a SVN repository. | 596 """Get the head revision of a SVN repository. |
604 | 597 |
605 Returns: | 598 Returns: |
606 Int head revision | 599 Int head revision |
607 """ | 600 """ |
608 info = CaptureSVN(["info", "--xml", url], os.getcwd()) | 601 info = CaptureSVN(options, ["info", "--xml", url], os.getcwd()) |
609 dom = xml.dom.minidom.parseString(info) | 602 dom = xml.dom.minidom.parseString(info) |
610 return int(dom.getElementsByTagName('entry')[0].getAttribute('revision')) | 603 return int(dom.getElementsByTagName('entry')[0].getAttribute('revision')) |
611 | 604 |
612 | 605 |
613 class FileStatus: | 606 class FileStatus: |
614 def __init__(self, path, text_status, props, lock, history): | 607 def __init__(self, path, text_status, props, lock, history): |
615 self.path = path | 608 self.path = path |
616 self.text_status = text_status | 609 self.text_status = text_status |
617 self.props = props | 610 self.props = props |
618 self.lock = lock | 611 self.lock = lock |
619 self.history = history | 612 self.history = history |
620 | 613 |
621 def __str__(self): | 614 def __str__(self): |
622 # Emulate svn status 1.5 output. | 615 # Emulate svn status 1.5 output. |
623 return (self.text_status + self.props + self.lock + self.history + ' ' + | 616 return (self.text_status + self.props + self.lock + self.history + ' ' + |
624 self.path) | 617 self.path) |
625 | 618 |
626 | 619 |
627 def CaptureSVNStatus(path): | 620 def CaptureSVNStatus(options, path): |
628 """Runs 'svn status' on an existing path. | 621 """Runs 'svn status' on an existing path. |
629 | 622 |
630 Args: | 623 Args: |
631 path: The directory to run svn status. | 624 path: The directory to run svn status. |
632 | 625 |
633 Returns: | 626 Returns: |
634 An array of FileStatus corresponding to the emulated output of 'svn status' | 627 An array of FileStatus corresponding to the emulated output of 'svn status' |
635 version 1.5.""" | 628 version 1.5.""" |
636 dom = ParseXML(CaptureSVN(["status", "--xml"], path)) | 629 dom = ParseXML(CaptureSVN(options, ["status", "--xml"], path)) |
637 results = [] | 630 results = [] |
638 if dom: | 631 if dom: |
639 # /status/target/entry/(wc-status|commit|author|date) | 632 # /status/target/entry/(wc-status|commit|author|date) |
640 for target in dom.getElementsByTagName('target'): | 633 for target in dom.getElementsByTagName('target'): |
641 base_path = target.getAttribute('path') | 634 base_path = target.getAttribute('path') |
642 for entry in target.getElementsByTagName('entry'): | 635 for entry in target.getElementsByTagName('entry'): |
643 file = entry.getAttribute('path') | 636 file = entry.getAttribute('path') |
644 wc_status = entry.getElementsByTagName('wc-status') | 637 wc_status = entry.getElementsByTagName('wc-status') |
645 assert len(wc_status) == 1 | 638 assert len(wc_status) == 1 |
646 # Emulate svn 1.5 status ouput... | 639 # Emulate svn 1.5 status ouput... |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
728 | 721 |
729 if not command in commands: | 722 if not command in commands: |
730 raise Error('Unknown command %s' % command) | 723 raise Error('Unknown command %s' % command) |
731 | 724 |
732 return commands[command](options, args, file_list) | 725 return commands[command](options, args, file_list) |
733 | 726 |
734 def cleanup(self, options, args, file_list): | 727 def cleanup(self, options, args, file_list): |
735 """Cleanup working copy.""" | 728 """Cleanup working copy.""" |
736 command = ['cleanup'] | 729 command = ['cleanup'] |
737 command.extend(args) | 730 command.extend(args) |
738 RunSVN(command, os.path.join(self._root_dir, self.relpath)) | 731 RunSVN(options, command, os.path.join(self._root_dir, self.relpath)) |
739 | 732 |
740 def diff(self, options, args, file_list): | 733 def diff(self, options, args, file_list): |
741 # NOTE: This function does not currently modify file_list. | 734 # NOTE: This function does not currently modify file_list. |
742 command = ['diff'] | 735 command = ['diff'] |
743 command.extend(args) | 736 command.extend(args) |
744 RunSVN(command, os.path.join(self._root_dir, self.relpath)) | 737 RunSVN(options, command, os.path.join(self._root_dir, self.relpath)) |
745 | 738 |
746 def update(self, options, args, file_list): | 739 def update(self, options, args, file_list): |
747 """Runs SCM to update or transparently checkout the working copy. | 740 """Runs SCM to update or transparently checkout the working copy. |
748 | 741 |
749 All updated files will be appended to file_list. | 742 All updated files will be appended to file_list. |
750 | 743 |
751 Raises: | 744 Raises: |
752 Error: if can't get URL for relative path. | 745 Error: if can't get URL for relative path. |
753 """ | 746 """ |
754 # Only update if git is not controlling the directory. | 747 # Only update if git is not controlling the directory. |
(...skipping 25 matching lines...) Expand all Loading... |
780 | 773 |
781 if not options.path_exists(os.path.join(self._root_dir, self.relpath)): | 774 if not options.path_exists(os.path.join(self._root_dir, self.relpath)): |
782 # We need to checkout. | 775 # We need to checkout. |
783 command = ['checkout', url, os.path.join(self._root_dir, self.relpath)] | 776 command = ['checkout', url, os.path.join(self._root_dir, self.relpath)] |
784 if revision: | 777 if revision: |
785 command.extend(['--revision', str(revision)]) | 778 command.extend(['--revision', str(revision)]) |
786 RunSVNAndGetFileList(options, command, self._root_dir, file_list) | 779 RunSVNAndGetFileList(options, command, self._root_dir, file_list) |
787 return | 780 return |
788 | 781 |
789 # Get the existing scm url and the revision number of the current checkout. | 782 # Get the existing scm url and the revision number of the current checkout. |
790 from_info = CaptureSVNInfo(os.path.join(self._root_dir, self.relpath, '.'), | 783 from_info = CaptureSVNInfo(options, |
| 784 os.path.join(self._root_dir, self.relpath, '.'), |
791 '.') | 785 '.') |
792 | 786 |
793 if options.manually_grab_svn_rev: | 787 if options.manually_grab_svn_rev: |
794 # Retrieve the current HEAD version because svn is slow at null updates. | 788 # Retrieve the current HEAD version because svn is slow at null updates. |
795 if not revision: | 789 if not revision: |
796 from_info_live = CaptureSVNInfo(from_info['URL'], '.') | 790 from_info_live = CaptureSVNInfo(options, from_info['URL'], '.') |
797 revision = int(from_info_live['Revision']) | 791 revision = int(from_info_live['Revision']) |
798 rev_str = ' at %d' % revision | 792 rev_str = ' at %d' % revision |
799 | 793 |
800 if from_info['URL'] != components[0]: | 794 if from_info['URL'] != components[0]: |
801 to_info = CaptureSVNInfo(url, '.') | 795 to_info = CaptureSVNInfo(options, url, '.') |
802 if from_info['Repository Root'] != to_info['Repository Root']: | 796 if from_info['Repository Root'] != to_info['Repository Root']: |
803 # We have different roots, so check if we can switch --relocate. | 797 # We have different roots, so check if we can switch --relocate. |
804 # Subversion only permits this if the repository UUIDs match. | 798 # Subversion only permits this if the repository UUIDs match. |
805 if from_info['UUID'] != to_info['UUID']: | 799 if from_info['UUID'] != to_info['UUID']: |
806 raise Error("Can't switch the checkout to %s; UUID don't match. That " | 800 raise Error("Can't switch the checkout to %s; UUID don't match. That " |
807 "simply means in theory, gclient should verify you don't " | 801 "simply means in theory, gclient should verify you don't " |
808 "have a local change, remove the old checkout and do a " | 802 "have a local change, remove the old checkout and do a " |
809 "fresh new checkout of the new repo. Contributions are " | 803 "fresh new checkout of the new repo. Contributions are " |
810 "welcome." % url) | 804 "welcome." % url) |
811 | 805 |
812 # Perform the switch --relocate, then rewrite the from_url | 806 # Perform the switch --relocate, then rewrite the from_url |
813 # to reflect where we "are now." (This is the same way that | 807 # to reflect where we "are now." (This is the same way that |
814 # Subversion itself handles the metadata when switch --relocate | 808 # Subversion itself handles the metadata when switch --relocate |
815 # is used.) This makes the checks below for whether we | 809 # is used.) This makes the checks below for whether we |
816 # can update to a revision or have to switch to a different | 810 # can update to a revision or have to switch to a different |
817 # branch work as expected. | 811 # branch work as expected. |
818 # TODO(maruel): TEST ME ! | 812 # TODO(maruel): TEST ME ! |
819 command = ["switch", "--relocate", | 813 command = ["switch", "--relocate", |
820 from_info['Repository Root'], | 814 from_info['Repository Root'], |
821 to_info['Repository Root'], | 815 to_info['Repository Root'], |
822 self.relpath] | 816 self.relpath] |
823 RunSVN(command, self._root_dir) | 817 RunSVN(options, command, self._root_dir) |
824 from_info['URL'] = from_info['URL'].replace( | 818 from_info['URL'] = from_info['URL'].replace( |
825 from_info['Repository Root'], | 819 from_info['Repository Root'], |
826 to_info['Repository Root']) | 820 to_info['Repository Root']) |
827 | 821 |
828 # If the provided url has a revision number that matches the revision | 822 # If the provided url has a revision number that matches the revision |
829 # number of the existing directory, then we don't need to bother updating. | 823 # number of the existing directory, then we don't need to bother updating. |
830 if not options.force and from_info['Revision'] == revision: | 824 if not options.force and from_info['Revision'] == revision: |
831 if options.verbose or not forced_revision: | 825 if options.verbose or not forced_revision: |
832 print >>options.stdout, ("\n_____ %s%s" % ( | 826 print >>options.stdout, ("\n_____ %s%s" % ( |
833 self.relpath, rev_str)) | 827 self.relpath, rev_str)) |
(...skipping 12 matching lines...) Expand all Loading... |
846 """ | 840 """ |
847 path = os.path.join(self._root_dir, self.relpath) | 841 path = os.path.join(self._root_dir, self.relpath) |
848 if not os.path.isdir(path): | 842 if not os.path.isdir(path): |
849 # 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 |
850 # checkout instead. | 844 # checkout instead. |
851 print >>options.stdout, ("\n_____ %s is missing, synching instead" % | 845 print >>options.stdout, ("\n_____ %s is missing, synching instead" % |
852 self.relpath) | 846 self.relpath) |
853 # Don't reuse the args. | 847 # Don't reuse the args. |
854 return self.update(options, [], file_list) | 848 return self.update(options, [], file_list) |
855 | 849 |
856 files = CaptureSVNStatus(path) | 850 files = CaptureSVNStatus(options, path) |
857 # Batch the command. | 851 # Batch the command. |
858 files_to_revert = [] | 852 files_to_revert = [] |
859 for file in files: | 853 for file in files: |
860 file_path = os.path.join(path, file.path) | 854 file_path = os.path.join(path, file.path) |
861 print >>options.stdout, file_path | 855 print >>options.stdout, file_path |
862 # Unversioned file or unexpected unversioned file. | 856 # Unversioned file or unexpected unversioned file. |
863 if file.text_status in ('?', '~'): | 857 if file.text_status in ('?', '~'): |
864 # Remove extraneous file. Also remove unexpected unversioned | 858 # Remove extraneous file. Also remove unexpected unversioned |
865 # directories. svn won't touch them but we want to delete these. | 859 # directories. svn won't touch them but we want to delete these. |
866 file_list.append(file_path) | 860 file_list.append(file_path) |
867 try: | 861 try: |
868 os.remove(file_path) | 862 os.remove(file_path) |
869 except EnvironmentError: | 863 except EnvironmentError: |
870 RemoveDirectory(file_path) | 864 RemoveDirectory(file_path) |
871 | 865 |
872 if file.text_status != '?': | 866 if file.text_status != '?': |
873 # For any other status, svn revert will work. | 867 # For any other status, svn revert will work. |
874 file_list.append(file_path) | 868 file_list.append(file_path) |
875 files_to_revert.append(file.path) | 869 files_to_revert.append(file.path) |
876 | 870 |
877 # Revert them all at once. | 871 # Revert them all at once. |
878 if files_to_revert: | 872 if files_to_revert: |
879 accumulated_paths = [] | 873 accumulated_paths = [] |
880 accumulated_length = 0 | 874 accumulated_length = 0 |
881 command = ['revert'] | 875 command = ['revert'] |
882 for p in files_to_revert: | 876 for p in files_to_revert: |
883 # Some shell have issues with command lines too long. | 877 # Some shell have issues with command lines too long. |
884 if accumulated_length and accumulated_length + len(p) > 3072: | 878 if accumulated_length and accumulated_length + len(p) > 3072: |
885 RunSVN(command + accumulated_paths, | 879 RunSVN(options, command + accumulated_paths, |
886 os.path.join(self._root_dir, self.relpath)) | 880 os.path.join(self._root_dir, self.relpath)) |
887 accumulated_paths = [] | 881 accumulated_paths = [] |
888 accumulated_length = 0 | 882 accumulated_length = 0 |
889 else: | 883 else: |
890 accumulated_paths.append(p) | 884 accumulated_paths.append(p) |
891 accumulated_length += len(p) | 885 accumulated_length += len(p) |
892 if accumulated_paths: | 886 if accumulated_paths: |
893 RunSVN(command + accumulated_paths, | 887 RunSVN(options, command + accumulated_paths, |
894 os.path.join(self._root_dir, self.relpath)) | 888 os.path.join(self._root_dir, self.relpath)) |
895 | 889 |
896 def status(self, options, args, file_list): | 890 def status(self, options, args, file_list): |
897 """Display status information.""" | 891 """Display status information.""" |
898 path = os.path.join(self._root_dir, self.relpath) | 892 path = os.path.join(self._root_dir, self.relpath) |
899 command = ['status'] | 893 command = ['status'] |
900 command.extend(args) | 894 command.extend(args) |
901 if not os.path.isdir(path): | 895 if not os.path.isdir(path): |
902 # svn status won't work if the directory doesn't exist. | 896 # svn status won't work if the directory doesn't exist. |
903 print >> options.stdout, ( | 897 print >> options.stdout, ( |
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1324 self._RunHooks(command, file_list, is_using_git) | 1318 self._RunHooks(command, file_list, is_using_git) |
1325 | 1319 |
1326 if command == 'update': | 1320 if command == 'update': |
1327 # notify the user if there is an orphaned entry in their working copy. | 1321 # notify the user if there is an orphaned entry in their working copy. |
1328 # TODO(darin): we should delete this directory manually if it doesn't | 1322 # TODO(darin): we should delete this directory manually if it doesn't |
1329 # have any changes in it. | 1323 # have any changes in it. |
1330 prev_entries = self._ReadEntries() | 1324 prev_entries = self._ReadEntries() |
1331 for entry in prev_entries: | 1325 for entry in prev_entries: |
1332 e_dir = os.path.join(self._root_dir, entry) | 1326 e_dir = os.path.join(self._root_dir, entry) |
1333 if entry not in entries and self._options.path_exists(e_dir): | 1327 if entry not in entries and self._options.path_exists(e_dir): |
1334 if CaptureSVNStatus(e_dir): | 1328 if CaptureSVNStatus(self._options, e_dir): |
1335 # There are modified files in this entry | 1329 # There are modified files in this entry |
1336 entries[entry] = None # Keep warning until removed. | 1330 entries[entry] = None # Keep warning until removed. |
1337 print >> self._options.stdout, ( | 1331 print >> self._options.stdout, ( |
1338 "\nWARNING: \"%s\" is no longer part of this client. " | 1332 "\nWARNING: \"%s\" is no longer part of this client. " |
1339 "It is recommended that you manually remove it.\n") % entry | 1333 "It is recommended that you manually remove it.\n") % entry |
1340 else: | 1334 else: |
1341 # Delete the entry | 1335 # Delete the entry |
1342 print >> self._options.stdout, ("\n________ deleting \'%s\' " + | 1336 print >> self._options.stdout, ("\n________ deleting \'%s\' " + |
1343 "in \'%s\'") % (entry, self._root_dir) | 1337 "in \'%s\'") % (entry, self._root_dir) |
1344 RemoveDirectory(e_dir) | 1338 RemoveDirectory(e_dir) |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1382 entries_deps_content = {} | 1376 entries_deps_content = {} |
1383 | 1377 |
1384 # Inner helper to generate base url and rev tuple (including honoring | 1378 # Inner helper to generate base url and rev tuple (including honoring |
1385 # |revision_overrides|) | 1379 # |revision_overrides|) |
1386 def GetURLAndRev(name, original_url): | 1380 def GetURLAndRev(name, original_url): |
1387 if original_url.find("@") < 0: | 1381 if original_url.find("@") < 0: |
1388 if revision_overrides.has_key(name): | 1382 if revision_overrides.has_key(name): |
1389 return (original_url, int(revision_overrides[name])) | 1383 return (original_url, int(revision_overrides[name])) |
1390 else: | 1384 else: |
1391 # TODO(aharper): SVN/SCMWrapper cleanup (non-local commandset) | 1385 # TODO(aharper): SVN/SCMWrapper cleanup (non-local commandset) |
1392 return (original_url, CaptureSVNHeadRevision(original_url)) | 1386 return (original_url, CaptureSVNHeadRevision(self._options, |
| 1387 original_url)) |
1393 else: | 1388 else: |
1394 url_components = original_url.split("@") | 1389 url_components = original_url.split("@") |
1395 if revision_overrides.has_key(name): | 1390 if revision_overrides.has_key(name): |
1396 return (url_components[0], int(revision_overrides[name])) | 1391 return (url_components[0], int(revision_overrides[name])) |
1397 else: | 1392 else: |
1398 return (url_components[0], int(url_components[1])) | 1393 return (url_components[0], int(url_components[1])) |
1399 | 1394 |
1400 # Run on the base solutions first. | 1395 # Run on the base solutions first. |
1401 for solution in solutions: | 1396 for solution in solutions: |
1402 name = solution["name"] | 1397 name = solution["name"] |
1403 if name in entries: | 1398 if name in entries: |
1404 raise Error("solution %s specified more than once" % name) | 1399 raise Error("solution %s specified more than once" % name) |
1405 (url, rev) = GetURLAndRev(name, solution["url"]) | 1400 (url, rev) = GetURLAndRev(name, solution["url"]) |
1406 entries[name] = "%s@%d" % (url, rev) | 1401 entries[name] = "%s@%d" % (url, rev) |
1407 # TODO(aharper): SVN/SCMWrapper cleanup (non-local commandset) | 1402 # TODO(aharper): SVN/SCMWrapper cleanup (non-local commandset) |
1408 entries_deps_content[name] = CaptureSVN( | 1403 entries_deps_content[name] = CaptureSVN( |
| 1404 self._options, |
1409 ["cat", | 1405 ["cat", |
1410 "%s/%s@%d" % (url, | 1406 "%s/%s@%d" % (url, |
1411 self._options.deps_file, | 1407 self._options.deps_file, |
1412 rev)], | 1408 rev)], |
1413 os.getcwd()) | 1409 os.getcwd()) |
1414 | 1410 |
1415 # Process the dependencies next (sort alphanumerically to ensure that | 1411 # Process the dependencies next (sort alphanumerically to ensure that |
1416 # containing directories get populated first and for readability) | 1412 # containing directories get populated first and for readability) |
1417 deps = self._ParseAllDeps(entries, entries_deps_content) | 1413 deps = self._ParseAllDeps(entries, entries_deps_content) |
1418 deps_to_process = deps.keys() | 1414 deps_to_process = deps.keys() |
1419 deps_to_process.sort() | 1415 deps_to_process.sort() |
1420 | 1416 |
1421 # First pass for direct dependencies. | 1417 # First pass for direct dependencies. |
1422 for d in deps_to_process: | 1418 for d in deps_to_process: |
1423 if type(deps[d]) == str: | 1419 if type(deps[d]) == str: |
1424 (url, rev) = GetURLAndRev(d, deps[d]) | 1420 (url, rev) = GetURLAndRev(d, deps[d]) |
1425 entries[d] = "%s@%d" % (url, rev) | 1421 entries[d] = "%s@%d" % (url, rev) |
1426 | 1422 |
1427 # Second pass for inherited deps (via the From keyword) | 1423 # Second pass for inherited deps (via the From keyword) |
1428 for d in deps_to_process: | 1424 for d in deps_to_process: |
1429 if type(deps[d]) != str: | 1425 if type(deps[d]) != str: |
1430 deps_parent_url = entries[deps[d].module_name] | 1426 deps_parent_url = entries[deps[d].module_name] |
1431 if deps_parent_url.find("@") < 0: | 1427 if deps_parent_url.find("@") < 0: |
1432 raise Error("From %s missing revisioned url" % deps[d].module_name) | 1428 raise Error("From %s missing revisioned url" % deps[d].module_name) |
1433 deps_parent_url_components = deps_parent_url.split("@") | 1429 deps_parent_url_components = deps_parent_url.split("@") |
1434 # TODO(aharper): SVN/SCMWrapper cleanup (non-local commandset) | 1430 # TODO(aharper): SVN/SCMWrapper cleanup (non-local commandset) |
1435 deps_parent_content = CaptureSVN( | 1431 deps_parent_content = CaptureSVN( |
| 1432 self._options, |
1436 ["cat", | 1433 ["cat", |
1437 "%s/%s@%s" % (deps_parent_url_components[0], | 1434 "%s/%s@%s" % (deps_parent_url_components[0], |
1438 self._options.deps_file, | 1435 self._options.deps_file, |
1439 deps_parent_url_components[1])], | 1436 deps_parent_url_components[1])], |
1440 os.getcwd()) | 1437 os.getcwd()) |
1441 sub_deps = self._ParseSolutionDeps( | 1438 sub_deps = self._ParseSolutionDeps( |
1442 deps[d].module_name, | 1439 deps[d].module_name, |
1443 FileRead(os.path.join(self._root_dir, | 1440 FileRead(os.path.join(self._root_dir, |
1444 deps[d].module_name, | 1441 deps[d].module_name, |
1445 self._options.deps_file)), | 1442 self._options.deps_file)), |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1719 | 1716 |
1720 if "__main__" == __name__: | 1717 if "__main__" == __name__: |
1721 try: | 1718 try: |
1722 result = Main(sys.argv) | 1719 result = Main(sys.argv) |
1723 except Error, e: | 1720 except Error, e: |
1724 print "Error: %s" % str(e) | 1721 print "Error: %s" % str(e) |
1725 result = 1 | 1722 result = 1 |
1726 sys.exit(result) | 1723 sys.exit(result) |
1727 | 1724 |
1728 # vim: ts=2:sw=2:tw=80:et: | 1725 # vim: ts=2:sw=2:tw=80:et: |
OLD | NEW |