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

Side by Side Diff: gclient-new-workdir.py

Issue 68213010: Clearer help in gclient-new-workdir.py (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Created 7 years, 1 month 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 2013 The Chromium Authors. All rights reserved. 2 # Copyright 2013 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 # Usage: 6 # Usage:
7 # gclient-new-workdir.py <repository> <new_workdir> [<branch>] 7 # gclient-new-workdir.py <repository> <new_workdir> [<branch>]
8 # 8 #
9 9
10 import os 10 import os
11 import os.path
M-A Ruel 2013/11/12 17:40:07 Not needed.
11 import shutil 12 import shutil
12 import subprocess 13 import subprocess
13 import sys 14 import sys
14 15
15 16
16 def parse_options(argv): 17 def parse_options(argv):
17 assert not sys.platform.startswith("win") 18 if sys.platform.startswith("win"):
M-A Ruel 2013/11/12 17:40:07 On windows, it'll always be 'win32', so use: if sy
19 print("This script cannot run on Windows because it uses symlinks.")
M-A Ruel 2013/11/12 17:40:07 you should print to sys.stderr. I see the rest of
20 sys.exit(1)
18 21
19 if len(argv) != 3: 22 if len(argv) != 3:
20 print("usage: gclient-new-workdir.py <repository> <new_workdir>") 23 print("""usage: gclient-new-workdir.py <repository> <new_workdir>
24
25 <repository> must be a absolute path
26 <new_workdir> must not exist
27 """)
21 sys.exit(1) 28 sys.exit(1)
22 29
23 repository = argv[1] 30 repository = argv[1]
24 new_workdir = argv[2] 31 new_workdir = argv[2]
25 32
33 if not os.path.isabs(argv[1]):
34 print("First argument (repository) must be an absolute path.")
M-A Ruel 2013/11/12 17:40:07 Why not argv[1] = os.path.abspath(argv[1]) ?
35 sys.exit(1)
36
26 if not os.path.exists(repository): 37 if not os.path.exists(repository):
27 print("Repository does not exist: " + repository) 38 print("Repository does not exist: " + repository)
28 sys.exit(1) 39 sys.exit(1)
29 40
30 if os.path.exists(new_workdir): 41 if os.path.exists(new_workdir):
31 print("New workdir already exists: " + new_workdir) 42 print("New workdir already exists: " + new_workdir)
32 sys.exit(1) 43 sys.exit(1)
33 44
34 return repository, new_workdir 45 return repository, new_workdir
35 46
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 if not os.path.exists(os.path.join(repository, link)): 97 if not os.path.exists(os.path.join(repository, link)):
87 return 98 return
88 link_dir = os.path.dirname(os.path.join(new_workdir, link)) 99 link_dir = os.path.dirname(os.path.join(new_workdir, link))
89 if not os.path.exists(link_dir): 100 if not os.path.exists(link_dir):
90 os.makedirs(link_dir) 101 os.makedirs(link_dir)
91 os.symlink(os.path.join(repository, link), os.path.join(new_workdir, link)) 102 os.symlink(os.path.join(repository, link), os.path.join(new_workdir, link))
92 103
93 104
94 if __name__ == '__main__': 105 if __name__ == '__main__':
95 sys.exit(main(sys.argv)) 106 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
This is Rietveld 408576698