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

Side by Side Diff: git_cl.py

Issue 258983004: git cl push -> git cl land (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Improved messages Created 6 years, 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
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 5
6 # Copyright (C) 2008 Evan Martin <martine@danga.com> 6 # Copyright (C) 2008 Evan Martin <martine@danga.com>
7 7
8 """A git-command for integrating reviews on Rietveld.""" 8 """A git-command for integrating reviews on Rietveld."""
9 9
10 import datetime
10 from distutils.version import LooseVersion 11 from distutils.version import LooseVersion
11 import glob 12 import glob
12 import json 13 import json
13 import logging 14 import logging
14 import optparse 15 import optparse
15 import os 16 import os
16 import Queue 17 import Queue
17 import re 18 import re
18 import stat 19 import stat
19 import sys 20 import sys
20 import textwrap 21 import textwrap
22 import time
21 import threading 23 import threading
22 import urllib2 24 import urllib2
23 import urlparse 25 import urlparse
24 import webbrowser 26 import webbrowser
25 27
26 try: 28 try:
27 import readline # pylint: disable=F0401,W0611 29 import readline # pylint: disable=F0401,W0611
28 except ImportError: 30 except ImportError:
29 pass 31 pass
30 32
(...skipping 1709 matching lines...) Expand 10 before | Expand all | Expand 10 after
1740 1742
1741 def IsSubmoduleMergeCommit(ref): 1743 def IsSubmoduleMergeCommit(ref):
1742 # When submodules are added to the repo, we expect there to be a single 1744 # When submodules are added to the repo, we expect there to be a single
1743 # non-git-svn merge commit at remote HEAD with a signature comment. 1745 # non-git-svn merge commit at remote HEAD with a signature comment.
1744 pattern = '^SVN changes up to revision [0-9]*$' 1746 pattern = '^SVN changes up to revision [0-9]*$'
1745 cmd = ['rev-list', '--merges', '--grep=%s' % pattern, '%s^!' % ref] 1747 cmd = ['rev-list', '--merges', '--grep=%s' % pattern, '%s^!' % ref]
1746 return RunGit(cmd) != '' 1748 return RunGit(cmd) != ''
1747 1749
1748 1750
1749 def SendUpstream(parser, args, cmd): 1751 def SendUpstream(parser, args, cmd):
1750 """Common code for CmdPush and CmdDCommit 1752 """Common code for CMDland and CmdDCommit
1751 1753
1752 Squashes branch into a single commit. 1754 Squashes branch into a single commit.
1753 Updates changelog with metadata (e.g. pointer to review). 1755 Updates changelog with metadata (e.g. pointer to review).
1754 Pushes/dcommits the code upstream. 1756 Pushes/dcommits the code upstream.
1755 Updates review and closes. 1757 Updates review and closes.
1756 """ 1758 """
1757 parser.add_option('--bypass-hooks', action='store_true', dest='bypass_hooks', 1759 parser.add_option('--bypass-hooks', action='store_true', dest='bypass_hooks',
1758 help='bypass upload presubmit hook') 1760 help='bypass upload presubmit hook')
1759 parser.add_option('-m', dest='message', 1761 parser.add_option('-m', dest='message',
1760 help="override review description") 1762 help="override review description")
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
1999 If your project has a true writeable upstream repository, you probably want 2001 If your project has a true writeable upstream repository, you probably want
2000 to run 'git cl push' instead. 2002 to run 'git cl push' instead.
2001 Choose wisely, if you get this wrong, your commit might appear to succeed but 2003 Choose wisely, if you get this wrong, your commit might appear to succeed but
2002 will instead be silently ignored.""" 2004 will instead be silently ignored."""
2003 print(message) 2005 print(message)
2004 ask_for_data('[Press enter to dcommit or ctrl-C to quit]') 2006 ask_for_data('[Press enter to dcommit or ctrl-C to quit]')
2005 return SendUpstream(parser, args, 'dcommit') 2007 return SendUpstream(parser, args, 'dcommit')
2006 2008
2007 2009
2008 @subcommand.usage('[upstream branch to apply against]') 2010 @subcommand.usage('[upstream branch to apply against]')
2009 def CMDpush(parser, args): 2011 def CMDland(parser, args):
2010 """Commits the current changelist via git.""" 2012 """Commits the current changelist via git."""
2011 if settings.GetIsGitSvn(): 2013 if settings.GetIsGitSvn():
2012 print('This appears to be an SVN repository.') 2014 print('This appears to be an SVN repository.')
2013 print('Are you sure you didn\'t mean \'git cl dcommit\'?') 2015 print('Are you sure you didn\'t mean \'git cl dcommit\'?')
2014 ask_for_data('[Press enter to push or ctrl-C to quit]') 2016 ask_for_data('[Press enter to push or ctrl-C to quit]')
2015 return SendUpstream(parser, args, 'push') 2017 return SendUpstream(parser, args, 'push')
2016 2018
2017 2019
2020 @subcommand.usage('[upstream branch to apply against]')
2021 def CMDpush(parser, args):
2022 """Temporary alias for 'land'.
szager1 2014/05/01 21:11:11 One-line comment (move trailing """ up).
2023 """
2024 print(
2025 "\n=======\n"
2026 "'git cl push' has been renamed to 'git cl land'.\n"
2027 "Currently they are treated as synonyms, but 'git cl push' will stop\n"
2028 "working after 2014/07/01.\n"
Nico 2014/07/16 17:53:52 Why stop supporting the old thing, and why print t
2029 "=======\n")
2030 now = datetime.datetime.utcfromtimestamp(time.time())
2031 if now > datetime.datetime(2014, 7, 1):
2032 print('******\nReally, you should not use this command anymore... \n'
2033 'Pausing 10 sec to help you remember :-)')
szager1 2014/05/01 21:11:11 Better, I think, to hang at the terminal: sys.std
2034 for n in xrange(10):
2035 time.sleep(1)
2036 print('%s seconds...' % (n+1))
2037 print('******')
2038 return CMDland(parser, args)
2039
2040
2018 @subcommand.usage('<patch url or issue id>') 2041 @subcommand.usage('<patch url or issue id>')
2019 def CMDpatch(parser, args): 2042 def CMDpatch(parser, args):
2020 """Patches in a code review.""" 2043 """Patches in a code review."""
2021 parser.add_option('-b', dest='newbranch', 2044 parser.add_option('-b', dest='newbranch',
2022 help='create a new branch off trunk for the patch') 2045 help='create a new branch off trunk for the patch')
2023 parser.add_option('-f', '--force', action='store_true', 2046 parser.add_option('-f', '--force', action='store_true',
2024 help='with -b, clobber any existing branch') 2047 help='with -b, clobber any existing branch')
2025 parser.add_option('-d', '--directory', action='store', metavar='DIR', 2048 parser.add_option('-d', '--directory', action='store', metavar='DIR',
2026 help='Change to the directory DIR immediately, ' 2049 help='Change to the directory DIR immediately, '
2027 'before doing anything else.') 2050 'before doing anything else.')
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after
2566 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' 2589 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith '
2567 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) 2590 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e)))
2568 2591
2569 2592
2570 if __name__ == '__main__': 2593 if __name__ == '__main__':
2571 # These affect sys.stdout so do it outside of main() to simplify mocks in 2594 # These affect sys.stdout so do it outside of main() to simplify mocks in
2572 # unit testing. 2595 # unit testing.
2573 fix_encoding.fix_encoding() 2596 fix_encoding.fix_encoding()
2574 colorama.init() 2597 colorama.init()
2575 sys.exit(main(sys.argv[1:])) 2598 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698