Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright (c) 2009, 2010, 2011 Google Inc. All rights reserved. | 1 # Copyright (c) 2009, 2010, 2011 Google Inc. All rights reserved. |
| 2 # Copyright (c) 2009 Apple Inc. All rights reserved. | 2 # Copyright (c) 2009 Apple Inc. All rights reserved. |
| 3 # | 3 # |
| 4 # Redistribution and use in source and binary forms, with or without | 4 # Redistribution and use in source and binary forms, with or without |
| 5 # modification, are permitted provided that the following conditions are | 5 # modification, are permitted provided that the following conditions are |
| 6 # met: | 6 # met: |
| 7 # | 7 # |
| 8 # * Redistributions of source code must retain the above copyright | 8 # * Redistributions of source code must retain the above copyright |
| 9 # notice, this list of conditions and the following disclaimer. | 9 # notice, this list of conditions and the following disclaimer. |
| 10 # * Redistributions in binary form must reproduce the above | 10 # * Redistributions in binary form must reproduce the above |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 127 return self._run_git(["mv", "-f", origin, destination]) | 127 return self._run_git(["mv", "-f", origin, destination]) |
| 128 | 128 |
| 129 def exists(self, path): | 129 def exists(self, path): |
| 130 return_code = self._run_git(["show", "HEAD:%s" % path], return_exit_code =True, decode_output=False) | 130 return_code = self._run_git(["show", "HEAD:%s" % path], return_exit_code =True, decode_output=False) |
| 131 return return_code != self.ERROR_FILE_IS_MISSING | 131 return return_code != self.ERROR_FILE_IS_MISSING |
| 132 | 132 |
| 133 def _branch_from_ref(self, ref): | 133 def _branch_from_ref(self, ref): |
| 134 return ref.replace('refs/heads/', '') | 134 return ref.replace('refs/heads/', '') |
| 135 | 135 |
| 136 def current_branch(self): | 136 def current_branch(self): |
| 137 return self._branch_from_ref(self._run_git(['symbolic-ref', '-q', 'HEAD' ]).strip()) | 137 # Returns an empty string if HEAD is detached. |
|
Xianzhu
2015/07/16 22:01:19
The following code will return 'HEAD' when HEAD is
joelo
2015/07/16 23:00:11
Whoops, you're right. I meant to check for that an
| |
| 138 ref = self._run_git(['rev-parse', '--symbolic-full-name', 'HEAD']).strip () | |
| 139 return self._branch_from_ref(ref) | |
| 138 | 140 |
| 139 def _upstream_branch(self): | 141 def _upstream_branch(self): |
| 140 current_branch = self.current_branch() | 142 current_branch = self.current_branch() |
| 141 return self._branch_from_ref(self.read_git_config('branch.%s.merge' % cu rrent_branch, cwd=self.checkout_root, executive=self._executive).strip()) | 143 return self._branch_from_ref(self.read_git_config('branch.%s.merge' % cu rrent_branch, cwd=self.checkout_root, executive=self._executive).strip()) |
| 142 | 144 |
| 143 def _merge_base(self, git_commit=None): | 145 def _merge_base(self, git_commit=None): |
| 144 if git_commit: | 146 if git_commit: |
| 145 # Rewrite UPSTREAM to the upstream branch | 147 # Rewrite UPSTREAM to the upstream branch |
| 146 if 'UPSTREAM' in git_commit: | 148 if 'UPSTREAM' in git_commit: |
| 147 upstream = self._upstream_branch() | 149 upstream = self._upstream_branch() |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 311 if self.current_branch() != self._branch_tracking_remote_master(): | 313 if self.current_branch() != self._branch_tracking_remote_master(): |
| 312 return False | 314 return False |
| 313 if len(self._local_commits(self._branch_tracking_remote_master())) > 0: | 315 if len(self._local_commits(self._branch_tracking_remote_master())) > 0: |
| 314 return False | 316 return False |
| 315 return True | 317 return True |
| 316 | 318 |
| 317 def ensure_cleanly_tracking_remote_master(self): | 319 def ensure_cleanly_tracking_remote_master(self): |
| 318 self._discard_working_directory_changes() | 320 self._discard_working_directory_changes() |
| 319 self._run_git(['checkout', '-q', self._branch_tracking_remote_master()]) | 321 self._run_git(['checkout', '-q', self._branch_tracking_remote_master()]) |
| 320 self._discard_local_commits() | 322 self._discard_local_commits() |
| OLD | NEW |