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

Unified Diff: git_rebase_update.py

Issue 1180673003: Make git-rebase-update a bit more robust (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 5 years, 6 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « git_common.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: git_rebase_update.py
diff --git a/git_rebase_update.py b/git_rebase_update.py
index 10c10d151ac41189f9dbe4c95b998388bf7041c7..63d050306a11503333699e85af84390c8289a51b 100755
--- a/git_rebase_update.py
+++ b/git_rebase_update.py
@@ -12,6 +12,7 @@ import collections
import logging
import sys
import textwrap
+import os
from fnmatch import fnmatch
from pprint import pformat
@@ -20,21 +21,26 @@ import git_common as git
STARTING_BRANCH_KEY = 'depot-tools.rebase-update.starting-branch'
+STARTING_WORKDIR_KEY = 'depot-tools.rebase-update.starting-workdir'
-def find_return_branch():
- """Finds the branch which we should return to after rebase-update completes.
+def find_return_branch_workdir():
+ """Finds the branch and working directory which we should return to after
+ rebase-update completes.
- This value may persist across multiple invocations of rebase-update, if
+ These values may persist across multiple invocations of rebase-update, if
rebase-update runs into a conflict mid-way.
"""
return_branch = git.config(STARTING_BRANCH_KEY)
+ workdir = git.config(STARTING_WORKDIR_KEY)
if not return_branch:
+ workdir = os.getcwd()
+ git.set_config(STARTING_WORKDIR_KEY, workdir)
return_branch = git.current_branch()
if return_branch != 'HEAD':
git.set_config(STARTING_BRANCH_KEY, return_branch)
- return return_branch
+ return return_branch, workdir
def fetch_remotes(branch_tree):
@@ -214,7 +220,8 @@ def main(args=None):
)
return 1
- return_branch = find_return_branch()
+ return_branch, return_workdir = find_return_branch_workdir()
+ os.chdir(git.run('rev-parse', '--show-toplevel'))
if git.current_branch() == 'HEAD':
if git.run('status', '--porcelain'):
@@ -264,7 +271,9 @@ def main(args=None):
% (return_branch, root_branch)
)
git.run('checkout', root_branch)
+ os.chdir(return_workdir)
git.set_config(STARTING_BRANCH_KEY, '')
+ git.set_config(STARTING_WORKDIR_KEY, '')
return retcode
« no previous file with comments | « git_common.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698