Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(523)

Side by Side Diff: third_party/WebKit/Tools/Scripts/webkitpy/common/checkout/scm/git.py

Issue 2590693002: Only add unstaged baseline changes to the git index when rebaselining. (Closed)
Patch Set: rebaseline-cl: Abort if there are unstaged baseline changes. Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Tools/Scripts/webkitpy/common/checkout/scm/scm.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 command.extend(['--', pathspec]) 105 command.extend(['--', pathspec])
106 return self._run_git(command) != '' 106 return self._run_git(command) != ''
107 107
108 def _discard_working_directory_changes(self): 108 def _discard_working_directory_changes(self):
109 # Could run git clean here too, but that wouldn't match subversion 109 # Could run git clean here too, but that wouldn't match subversion
110 self._run_git(['reset', 'HEAD', '--hard']) 110 self._run_git(['reset', 'HEAD', '--hard'])
111 # Aborting rebase even though this does not match subversion 111 # Aborting rebase even though this does not match subversion
112 if self._rebase_in_progress(): 112 if self._rebase_in_progress():
113 self._run_git(['rebase', '--abort']) 113 self._run_git(['rebase', '--abort'])
114 114
115 def unstaged_changes(self):
116 """Lists files with unstaged changes, including untracked files.
117
118 Returns a dict mapping modified file paths (relative to checkout root)
119 to one-character codes identifying the change, e.g. 'M' for modified,
120 'D' for deleted, '?' for untracked.
121 """
122 # `git status -z` is a version of `git status -s`, that's recommended
123 # for machine parsing. Lines are terminated with NUL rather than LF.
124 unstaged_changes = {}
125 change_lines = self._run_git(['status', '-z']).rstrip('\x00').split('\x0 0')
126 for line in change_lines:
127 if line[1] == ' ':
128 continue # Already staged for commit.
129 path = line[3:]
130 unstaged_changes[path] = line[1]
131 return unstaged_changes
132
115 def status_command(self): 133 def status_command(self):
116 # git status returns non-zero when there are changes, so we use git diff name --name-status HEAD instead. 134 # git status returns non-zero when there are changes, so we use git diff name --name-status HEAD instead.
117 # No file contents printed, thus utf-8 autodecoding in self.run is fine. 135 # No file contents printed, thus utf-8 autodecoding in self.run is fine.
118 return [self.executable_name, "diff", "--name-status", "--no-renames", " HEAD"] 136 return [self.executable_name, "diff", "--name-status", "--no-renames", " HEAD"]
119 137
120 def _status_regexp(self, expected_types): 138 def _status_regexp(self, expected_types):
121 return '^(?P<status>[%s])\t(?P<filename>.+)$' % expected_types 139 return '^(?P<status>[%s])\t(?P<filename>.+)$' % expected_types
122 140
123 def add_all(self, pathspec=None): 141 def add_all(self, pathspec=None):
124 command = ['add', '--all'] 142 command = ['add', '--all']
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 if self.current_branch() != self._branch_tracking_remote_master(): 348 if self.current_branch() != self._branch_tracking_remote_master():
331 return False 349 return False
332 if len(self._local_commits(self._branch_tracking_remote_master())) > 0: 350 if len(self._local_commits(self._branch_tracking_remote_master())) > 0:
333 return False 351 return False
334 return True 352 return True
335 353
336 def ensure_cleanly_tracking_remote_master(self): 354 def ensure_cleanly_tracking_remote_master(self):
337 self._discard_working_directory_changes() 355 self._discard_working_directory_changes()
338 self._run_git(['checkout', '-q', self._branch_tracking_remote_master()]) 356 self._run_git(['checkout', '-q', self._branch_tracking_remote_master()])
339 self._discard_local_commits() 357 self._discard_local_commits()
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Tools/Scripts/webkitpy/common/checkout/scm/scm.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698