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

Side by Side Diff: git_reparent_branch.py

Issue 184253003: Add git-reup and friends (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@freeze_thaw
Patch Set: one more argparse Created 6 years, 9 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 unified diff | Download patch
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 # Copyright 2014 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
agable 2014/03/21 01:14:21 docstring
6 import sys
7
8 from git_common import upstream, current_branch, run
9 from git_common import get_or_create_merge_base
10
11 import subprocess2
12
13 def main(argv):
14 # TODO(iannucci): Add --verbose
15 # TODO(iannucci): Merge-base-tag before altering parent info.
16 # TODO(iannucci): Allow specification of the branch-to-reparent
17
18 assert len(argv) == 2, "Must supply new parent"
agable 2014/03/21 01:14:21 use argparse
19 branch = current_branch()
20 new_parent = argv[1]
21 cur_parent = upstream(branch)
22 assert branch != 'HEAD', 'Must be on the branch you want to reparent'
23 assert cur_parent != new_parent
24
25 get_or_create_merge_base(branch, cur_parent)
26
27 print "Reparenting %s to track %s (was %s)" % (branch, new_parent, cur_parent)
28 run('branch', '--set-upstream-to', new_parent, branch)
29 try:
30 subprocess2.check_call(['git', 'rebase-update'])
31 except:
32 print "Resetting parent back to %s" % (cur_parent)
agable 2014/03/21 01:14:21 Print failure message in between; otherwise not cl
iannucci 2014/03/22 04:17:35 The rebase-update command already prints a lot of
33 run('branch', '--set-upstream-to', cur_parent, branch)
34 raise
35
36 return 0
37
38
39 if __name__ == '__main__':
40 sys.exit(main(sys.argv))
41
42
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698