1 #
2 # This program is free software; you can redistribute it and/or modify
3 # it under the terms of the GNU General Public License version 2
4 # as published by the Free Software Foundation.
5 #
6 # This program is distributed in the hope that it will be useful,
7 # but WITHOUT ANY WARRANTY; without even the implied warranty of
8 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 # GNU General Public License for more details.
10 #
11 # You should have received a copy of the GNU General Public License
12 # along with this program; if not, write to the Free Software
13 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
14 #
15
16 #
17 # Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
18 # Copyright 2008, 2011 Richard Lowe
19 #
20
21 '''OpenSolaris extensions to Mercurial
22
23 This extension contains a number of commands to help you work with
24 the OpenSolaris consolidations. It provides commands to check your
25 changes against the various style rules used for OpenSolaris, to
26 backup and restore your changes, to generate code reviews, and to
27 prepare your changes for integration.
28
29
30 The Parent
31
32 To provide a uniform notion of parent workspace regardless of
33 filesystem-based access, Cadmium uses the highest numbered changeset
34 on the current branch that is also in the parent workspace to
35 represent the parent workspace.
36
37
38 The Active List
75 # of python into which it is being loaded. This assumes the normal
76 # onbld directory structure, where cdm.py is in
77 # lib/python(version)?/onbld/hgext/. If that changes so too must
78 # this.
79 #
80 # This and the case below are not equivalent. In this case we may be
81 # loading a cdm.py in python2.X/ via the lib/python/ symlink but need
82 # python2.Y in sys.path.
83 #
84 sys.path.insert(1, os.path.join(os.path.dirname(__file__), "..", "..", "..",
85 "python%d.%d" % sys.version_info[:2]))
86
87 #
88 # Add the relative path from cdm.py to usr/src/tools to the load path,
89 # such that a cdm.py loaded from the source tree uses the modules also
90 # within the source tree.
91 #
92 sys.path.insert(2, os.path.join(os.path.dirname(__file__), "..", ".."))
93
94 from onbld.Scm import Version
95 from mercurial import util
96
97 try:
98 Version.check_version()
99 except Version.VersionMismatch, badversion:
100 raise util.Abort("Version Mismatch:\n %s\n" % badversion)
101
102 from mercurial import cmdutil, ignore, node, patch
103
104 from onbld.Scm.WorkSpace import WorkSpace, WorkList
105 from onbld.Scm.Backup import CdmBackup
106 from onbld.Checks import Cddl, Comments, Copyright, CStyle, HdrChk
107 from onbld.Checks import JStyle, Keywords, Mapfile
108
109
110 def yes_no(ui, msg, default):
111 if default:
112 prompt = ' [Y/n]:'
113 defanswer = 'y'
114 else:
115 prompt = ' [y/N]:'
116 defanswer = 'n'
117
118 if Version.at_least("1.4"):
119 index = ui.promptchoice(msg + prompt, ['&yes', '&no'],
120 default=['y', 'n'].index(defanswer))
121 resp = ('y', 'n')[index]
122 else:
150 #
151 # The ignore routines need a canonical path to the file (relative to the
152 # repo root), whereas the check commands get paths relative to the cwd.
153 #
154 # Wrap our argument such that the path is canonified before it is checked.
155 #
156 def canonified_check(ignfunc):
157 def f(path):
158 cpath = util.canonpath(repo.root, repo.getcwd(), path)
159 return ignfunc(cpath)
160 return f
161
162 ignorefiles = []
163
164 for f in [repo.join('cdm/%s.NOT' % cmd),
165 repo.wjoin('exception_lists/%s' % cmd)]:
166 if os.path.exists(f):
167 ignorefiles.append(f)
168
169 if ignorefiles:
170 ign = ignore.ignore(repo.root, ignorefiles, repo.ui.warn)
171 return canonified_check(ign)
172 else:
173 return util.never
174
175
176 def abort_if_dirty(ws):
177 '''Abort if the workspace has uncommitted changes, merges,
178 branches, or has Mq patches applied'''
179
180 if ws.modified():
181 raise util.Abort('workspace has uncommitted changes')
182 if ws.merged():
183 raise util.Abort('workspace contains uncommitted merge')
184 if ws.branched():
185 raise util.Abort('workspace contains uncommitted branch')
186 if ws.mq_applied():
187 raise util.Abort('workspace has Mq patches applied')
188
189
190 #
|
1 #
2 # This program is free software; you can redistribute it and/or modify
3 # it under the terms of the GNU General Public License version 2
4 # as published by the Free Software Foundation.
5 #
6 # This program is distributed in the hope that it will be useful,
7 # but WITHOUT ANY WARRANTY; without even the implied warranty of
8 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 # GNU General Public License for more details.
10 #
11 # You should have received a copy of the GNU General Public License
12 # along with this program; if not, write to the Free Software
13 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
14 #
15
16 #
17 # Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
18 # Copyright 2008, 2011 Richard Lowe
19 # Copyright (c) 2013, Joyent Inc. All rights reserved.
20 #
21
22 '''OpenSolaris extensions to Mercurial
23
24 This extension contains a number of commands to help you work with
25 the OpenSolaris consolidations. It provides commands to check your
26 changes against the various style rules used for OpenSolaris, to
27 backup and restore your changes, to generate code reviews, and to
28 prepare your changes for integration.
29
30
31 The Parent
32
33 To provide a uniform notion of parent workspace regardless of
34 filesystem-based access, Cadmium uses the highest numbered changeset
35 on the current branch that is also in the parent workspace to
36 represent the parent workspace.
37
38
39 The Active List
76 # of python into which it is being loaded. This assumes the normal
77 # onbld directory structure, where cdm.py is in
78 # lib/python(version)?/onbld/hgext/. If that changes so too must
79 # this.
80 #
81 # This and the case below are not equivalent. In this case we may be
82 # loading a cdm.py in python2.X/ via the lib/python/ symlink but need
83 # python2.Y in sys.path.
84 #
85 sys.path.insert(1, os.path.join(os.path.dirname(__file__), "..", "..", "..",
86 "python%d.%d" % sys.version_info[:2]))
87
88 #
89 # Add the relative path from cdm.py to usr/src/tools to the load path,
90 # such that a cdm.py loaded from the source tree uses the modules also
91 # within the source tree.
92 #
93 sys.path.insert(2, os.path.join(os.path.dirname(__file__), "..", ".."))
94
95 from onbld.Scm import Version
96 from onbld.Scm import Ignore
97 from mercurial import util
98
99 try:
100 Version.check_version()
101 except Version.VersionMismatch, badversion:
102 raise util.Abort("Version Mismatch:\n %s\n" % badversion)
103
104 from mercurial import cmdutil, node, patch
105
106 from onbld.Scm.WorkSpace import WorkSpace, WorkList
107 from onbld.Scm.Backup import CdmBackup
108 from onbld.Checks import Cddl, Comments, Copyright, CStyle, HdrChk
109 from onbld.Checks import JStyle, Keywords, Mapfile
110
111
112 def yes_no(ui, msg, default):
113 if default:
114 prompt = ' [Y/n]:'
115 defanswer = 'y'
116 else:
117 prompt = ' [y/N]:'
118 defanswer = 'n'
119
120 if Version.at_least("1.4"):
121 index = ui.promptchoice(msg + prompt, ['&yes', '&no'],
122 default=['y', 'n'].index(defanswer))
123 resp = ('y', 'n')[index]
124 else:
152 #
153 # The ignore routines need a canonical path to the file (relative to the
154 # repo root), whereas the check commands get paths relative to the cwd.
155 #
156 # Wrap our argument such that the path is canonified before it is checked.
157 #
158 def canonified_check(ignfunc):
159 def f(path):
160 cpath = util.canonpath(repo.root, repo.getcwd(), path)
161 return ignfunc(cpath)
162 return f
163
164 ignorefiles = []
165
166 for f in [repo.join('cdm/%s.NOT' % cmd),
167 repo.wjoin('exception_lists/%s' % cmd)]:
168 if os.path.exists(f):
169 ignorefiles.append(f)
170
171 if ignorefiles:
172 ign = Ignore.ignore(repo.root, ignorefiles)
173 return canonified_check(ign)
174 else:
175 return util.never
176
177
178 def abort_if_dirty(ws):
179 '''Abort if the workspace has uncommitted changes, merges,
180 branches, or has Mq patches applied'''
181
182 if ws.modified():
183 raise util.Abort('workspace has uncommitted changes')
184 if ws.merged():
185 raise util.Abort('workspace contains uncommitted merge')
186 if ws.branched():
187 raise util.Abort('workspace contains uncommitted branch')
188 if ws.mq_applied():
189 raise util.Abort('workspace has Mq patches applied')
190
191
192 #
|