[go: up one dir, main page]

Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(47)
Side by Side Diff: git-cl
Issue 160058: Verify git and git-svn are 1.6 or later.
Patch Set: address comments Created 16 years, 2 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
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/python 1 #!/usr/bin/python
2 # git-cl -- a git-command for integrating reviews on Rietveld 2 # git-cl -- a git-command for integrating reviews on Rietveld
3 # Copyright (C) 2008 Evan Martin <martine@danga.com> 3 # Copyright (C) 2008 Evan Martin <martine@danga.com>
4 4
5 import getpass 5 import getpass
6 import optparse 6 import optparse
7 import os 7 import os
8 import re 8 import re
9 import readline 9 import readline
10 import string
10 import subprocess 11 import subprocess
11 import sys 12 import sys
12 import tempfile 13 import tempfile
13 import textwrap 14 import textwrap
14 import upload 15 import upload
15 import urllib2 16 import urllib2
16 17
17 try: 18 try:
18 import readline 19 import readline
19 except ImportError: 20 except ImportError:
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 class Settings: 55 class Settings:
55 def __init__(self): 56 def __init__(self):
56 self.server = None 57 self.server = None
57 self.cc = None 58 self.cc = None
58 self.root = None 59 self.root = None
59 self.is_git_svn = None 60 self.is_git_svn = None
60 self.svn_branch = None 61 self.svn_branch = None
61 self.tree_status_url = None 62 self.tree_status_url = None
62 self.viewvc_url = None 63 self.viewvc_url = None
63 64
65 def VerifyGitSvnVersion(self):
66 git_svn_version = string.strip(RunGit(['svn', '--version']))
67 match = re.match(r'^git-svn version (\d+)\.(\d+)\.(\S*) \([^\)]+\)',
68 git_svn_version)
69 if not match:
70 DieWithError('git-svn --version is broken, please check your git-svn '
71 'install.')
72 if int(match.group(1)) == 1 and int(match.group(2)) < 6:
73 DieWithError('git-svn version is "%s", please update to a version later '
74 'than 1.5.x' % match.group(0))
75
64 def GetServer(self, error_ok=False): 76 def GetServer(self, error_ok=False):
65 if not self.server: 77 if not self.server:
66 if not error_ok: 78 if not error_ok:
67 error_message = ('You must configure your review setup by running ' 79 error_message = ('You must configure your review setup by running '
68 '"git cl config".') 80 '"git cl config".')
69 self.server = self._GetConfig('rietveld.server', 81 self.server = self._GetConfig('rietveld.server',
70 error_message=error_message) 82 error_message=error_message)
71 else: 83 else:
72 self.server = self._GetConfig('rietveld.server', error_ok=True) 84 self.server = self._GetConfig('rietveld.server', error_ok=True)
73 return self.server 85 return self.server
74 86
75 def GetCCList(self): 87 def GetCCList(self):
76 if self.cc is None: 88 if self.cc is None:
77 self.cc = self._GetConfig('rietveld.cc', error_ok=True) 89 self.cc = self._GetConfig('rietveld.cc', error_ok=True)
78 return self.cc 90 return self.cc
79 91
80 def GetRoot(self): 92 def GetRoot(self):
81 if not self.root: 93 if not self.root:
82 self.root = os.path.abspath(RunGit(['rev-parse', '--show-cdup']).strip()) 94 self.root = os.path.abspath(RunGit(['rev-parse', '--show-cdup']).strip())
83 return self.root 95 return self.root
84 96
85 def GetIsGitSvn(self): 97 def GetIsGitSvn(self):
86 """Return true if this repo looks like it's using git-svn.""" 98 """Return true if this repo looks like it's using git-svn."""
87 if self.is_git_svn is None: 99 if self.is_git_svn is None:
88 # If you have any "svn-remote.*" config keys, we think you're using svn. 100 # If you have any "svn-remote.*" config keys, we think you're using svn.
89 self.is_git_svn = RunGit(['config', '--get-regexp', r'^svn-remote\.'], 101 self.is_git_svn = RunGit(['config', '--get-regexp', r'^svn-remote\.'],
90 exit_code=True) == 0 102 exit_code=True) == 0
103 if self.is_git_svn:
104 self.VerifyGitSvnVersion()
91 return self.is_git_svn 105 return self.is_git_svn
92 106
93 def GetSVNBranch(self): 107 def GetSVNBranch(self):
94 if self.svn_branch is None: 108 if self.svn_branch is None:
95 if not self.GetIsGitSvn(): 109 if not self.GetIsGitSvn():
96 raise "Repo doesn't appear to be a git-svn repo." 110 raise "Repo doesn't appear to be a git-svn repo."
97 111
98 # Try to figure out which remote branch we're based on. 112 # Try to figure out which remote branch we're based on.
99 # Strategy: 113 # Strategy:
100 # 1) find all git-svn branches and note their svn URLs. 114 # 1) find all git-svn branches and note their svn URLs.
(...skipping 801 matching lines...) Expand 10 before | Expand all | Expand 10 after
902 command = argv[1] 916 command = argv[1]
903 for name, _, func in COMMANDS: 917 for name, _, func in COMMANDS:
904 if name == command: 918 if name == command:
905 return func(argv[2:]) 919 return func(argv[2:])
906 print 'unknown command: %s' % command 920 print 'unknown command: %s' % command
907 Usage(argv[0]) 921 Usage(argv[0])
908 922
909 923
910 if __name__ == '__main__': 924 if __name__ == '__main__':
911 sys.exit(main(sys.argv)) 925 sys.exit(main(sys.argv))
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b