OLD | NEW |
---|---|
1 # coding=utf8 | 1 # coding=utf8 |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 """Manages a project checkout. | 5 """Manages a project checkout. |
6 | 6 |
7 Includes support for svn, git-svn and git. | 7 Includes support for svn, git-svn and git. |
8 """ | 8 """ |
9 | 9 |
10 import ConfigParser | 10 import ConfigParser |
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
555 | 555 |
556 class GitCheckout(CheckoutBase): | 556 class GitCheckout(CheckoutBase): |
557 """Manages a git checkout.""" | 557 """Manages a git checkout.""" |
558 def __init__(self, root_dir, project_name, remote_branch, git_url, | 558 def __init__(self, root_dir, project_name, remote_branch, git_url, |
559 commit_user, post_processors=None, base_ref=None): | 559 commit_user, post_processors=None, base_ref=None): |
560 super(GitCheckout, self).__init__(root_dir, project_name, post_processors) | 560 super(GitCheckout, self).__init__(root_dir, project_name, post_processors) |
561 self.base_ref = base_ref | 561 self.base_ref = base_ref |
562 self.git_url = git_url | 562 self.git_url = git_url |
563 self.commit_user = commit_user | 563 self.commit_user = commit_user |
564 self.remote_branch = remote_branch | 564 self.remote_branch = remote_branch |
565 assert self.remote_branch | |
565 # The working branch where patches will be applied. It will track the | 566 # The working branch where patches will be applied. It will track the |
566 # remote branch. | 567 # remote branch. |
567 self.working_branch = 'working_branch' | 568 self.working_branch = 'working_branch' |
568 # There is no reason to not hardcode origin. | 569 # There is no reason to not hardcode origin. |
569 self.pull_remote = 'origin' | 570 self.pull_remote = 'origin' |
570 self.push_remote = 'upstream' | 571 self.push_remote = 'upstream' |
571 | 572 |
572 def prepare(self, revision): | 573 def prepare(self, revision): |
573 """Resets the git repository in a clean state. | 574 """Resets the git repository in a clean state. |
574 | 575 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
615 name=None, email=None): | 616 name=None, email=None): |
616 """Applies a patch on 'working_branch' and switches to it. | 617 """Applies a patch on 'working_branch' and switches to it. |
617 | 618 |
618 Also commits the changes on the local branch. | 619 Also commits the changes on the local branch. |
619 | 620 |
620 Ignores svn properties and raise an exception on unexpected ones. | 621 Ignores svn properties and raise an exception on unexpected ones. |
621 """ | 622 """ |
622 post_processors = post_processors or self.post_processors or [] | 623 post_processors = post_processors or self.post_processors or [] |
623 # It this throws, the checkout is corrupted. Maybe worth deleting it and | 624 # It this throws, the checkout is corrupted. Maybe worth deleting it and |
624 # trying again? | 625 # trying again? |
625 if self.remote_branch: | 626 if self.remote_branch: |
Ryan Tseng
2014/03/19 01:54:28
Maybe "if self.remote_branch and not self.base_ref
| |
626 self._check_call_git( | 627 self._check_call_git( |
627 ['checkout', '-b', self.working_branch, '-t', self.remote_branch, | 628 ['checkout', |
629 '-b', self.working_branch, | |
630 '-t', '%s/%s' % (self.pull_remote, self.remote_branch), | |
agable
2014/03/18 21:19:09
Ravi: apply_issue was checking out a branch tracki
| |
628 '--quiet']) | 631 '--quiet']) |
629 | 632 |
630 for index, p in enumerate(patches): | 633 for index, p in enumerate(patches): |
631 stdout = [] | 634 stdout = [] |
632 try: | 635 try: |
633 filepath = os.path.join(self.project_path, p.filename) | 636 filepath = os.path.join(self.project_path, p.filename) |
634 if p.is_delete: | 637 if p.is_delete: |
635 if (not os.path.exists(filepath) and | 638 if (not os.path.exists(filepath) and |
636 any(p1.source_filename == p.filename for p1 in patches[0:index])): | 639 any(p1.source_filename == p.filename for p1 in patches[0:index])): |
637 # The file was already deleted if a prior patch with file rename | 640 # The file was already deleted if a prior patch with file rename |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
819 def revisions(self, rev1, rev2): | 822 def revisions(self, rev1, rev2): |
820 return self.checkout.revisions(rev1, rev2) | 823 return self.checkout.revisions(rev1, rev2) |
821 | 824 |
822 @property | 825 @property |
823 def project_name(self): | 826 def project_name(self): |
824 return self.checkout.project_name | 827 return self.checkout.project_name |
825 | 828 |
826 @property | 829 @property |
827 def project_path(self): | 830 def project_path(self): |
828 return self.checkout.project_path | 831 return self.checkout.project_path |
OLD | NEW |