Show More
@@ -1,429 +1,430 b'' | |||
|
1 | 1 | #!/usr/bin/env python |
|
2 | 2 | # |
|
3 | 3 | # check-code - a style and portability checker for Mercurial |
|
4 | 4 | # |
|
5 | 5 | # Copyright 2010 Matt Mackall <mpm@selenic.com> |
|
6 | 6 | # |
|
7 | 7 | # This software may be used and distributed according to the terms of the |
|
8 | 8 | # GNU General Public License version 2 or any later version. |
|
9 | 9 | |
|
10 | 10 | import re, glob, os, sys |
|
11 | 11 | import keyword |
|
12 | 12 | import optparse |
|
13 | 13 | |
|
14 | 14 | def repquote(m): |
|
15 | 15 | t = re.sub(r"\w", "x", m.group('text')) |
|
16 | 16 | t = re.sub(r"[^\s\nx]", "o", t) |
|
17 | 17 | return m.group('quote') + t + m.group('quote') |
|
18 | 18 | |
|
19 | 19 | def reppython(m): |
|
20 | 20 | comment = m.group('comment') |
|
21 | 21 | if comment: |
|
22 | 22 | return "#" * len(comment) |
|
23 | 23 | return repquote(m) |
|
24 | 24 | |
|
25 | 25 | def repcomment(m): |
|
26 | 26 | return m.group(1) + "#" * len(m.group(2)) |
|
27 | 27 | |
|
28 | 28 | def repccomment(m): |
|
29 | 29 | t = re.sub(r"((?<=\n) )|\S", "x", m.group(2)) |
|
30 | 30 | return m.group(1) + t + "*/" |
|
31 | 31 | |
|
32 | 32 | def repcallspaces(m): |
|
33 | 33 | t = re.sub(r"\n\s+", "\n", m.group(2)) |
|
34 | 34 | return m.group(1) + t |
|
35 | 35 | |
|
36 | 36 | def repinclude(m): |
|
37 | 37 | return m.group(1) + "<foo>" |
|
38 | 38 | |
|
39 | 39 | def rephere(m): |
|
40 | 40 | t = re.sub(r"\S", "x", m.group(2)) |
|
41 | 41 | return m.group(1) + t |
|
42 | 42 | |
|
43 | 43 | |
|
44 | 44 | testpats = [ |
|
45 | 45 | [ |
|
46 | 46 | (r'(pushd|popd)', "don't use 'pushd' or 'popd', use 'cd'"), |
|
47 | 47 | (r'\W\$?\(\([^\)\n]*\)\)', "don't use (()) or $(()), use 'expr'"), |
|
48 | 48 | (r'^function', "don't use 'function', use old style"), |
|
49 | 49 | (r'grep.*-q', "don't use 'grep -q', redirect to /dev/null"), |
|
50 | 50 | (r'echo.*\\n', "don't use 'echo \\n', use printf"), |
|
51 | 51 | (r'echo -n', "don't use 'echo -n', use printf"), |
|
52 | 52 | (r'^diff.*-\w*N', "don't use 'diff -N'"), |
|
53 | 53 | (r'(^| )wc[^|]*$\n(?!.*\(re\))', "filter wc output"), |
|
54 | 54 | (r'head -c', "don't use 'head -c', use 'dd'"), |
|
55 | 55 | (r'sha1sum', "don't use sha1sum, use $TESTDIR/md5sum.py"), |
|
56 | 56 | (r'ls.*-\w*R', "don't use 'ls -R', use 'find'"), |
|
57 | 57 | (r'printf.*\\\d\d\d', "don't use 'printf \NNN', use Python"), |
|
58 | 58 | (r'printf.*\\x', "don't use printf \\x, use Python"), |
|
59 | 59 | (r'\$\(.*\)', "don't use $(expr), use `expr`"), |
|
60 | 60 | (r'rm -rf \*', "don't use naked rm -rf, target a directory"), |
|
61 | 61 | (r'(^|\|\s*)grep (-\w\s+)*[^|]*[(|]\w', |
|
62 | 62 | "use egrep for extended grep syntax"), |
|
63 | 63 | (r'/bin/', "don't use explicit paths for tools"), |
|
64 | 64 | (r'\$PWD', "don't use $PWD, use `pwd`"), |
|
65 | 65 | (r'[^\n]\Z', "no trailing newline"), |
|
66 | 66 | (r'export.*=', "don't export and assign at once"), |
|
67 | 67 | (r'^([^"\'\n]|("[^"\n]*")|(\'[^\'\n]*\'))*\\^', "^ must be quoted"), |
|
68 | 68 | (r'^source\b', "don't use 'source', use '.'"), |
|
69 | 69 | (r'touch -d', "don't use 'touch -d', use 'touch -t' instead"), |
|
70 | 70 | (r'ls +[^|\n-]+ +-', "options to 'ls' must come before filenames"), |
|
71 | 71 | (r'[^>\n]>\s*\$HGRCPATH', "don't overwrite $HGRCPATH, append to it"), |
|
72 | 72 | (r'^stop\(\)', "don't use 'stop' as a shell function name"), |
|
73 | 73 | (r'(\[|\btest\b).*-e ', "don't use 'test -e', use 'test -f'"), |
|
74 | (r'^alias\b.*=', "don't use alias, use a function"), | |
|
74 | 75 | ], |
|
75 | 76 | # warnings |
|
76 | 77 | [] |
|
77 | 78 | ] |
|
78 | 79 | |
|
79 | 80 | testfilters = [ |
|
80 | 81 | (r"( *)(#([^\n]*\S)?)", repcomment), |
|
81 | 82 | (r"<<(\S+)((.|\n)*?\n\1)", rephere), |
|
82 | 83 | ] |
|
83 | 84 | |
|
84 | 85 | uprefix = r"^ \$ " |
|
85 | 86 | uprefixc = r"^ > " |
|
86 | 87 | utestpats = [ |
|
87 | 88 | [ |
|
88 | 89 | (r'^(\S| $ ).*(\S[ \t]+|^[ \t]+)\n', "trailing whitespace on non-output"), |
|
89 | 90 | (uprefix + r'.*\|\s*sed', "use regex test output patterns instead of sed"), |
|
90 | 91 | (uprefix + r'(true|exit 0)', "explicit zero exit unnecessary"), |
|
91 | 92 | (uprefix + r'.*(?<!\[)\$\?', "explicit exit code checks unnecessary"), |
|
92 | 93 | (uprefix + r'.*\|\| echo.*(fail|error)', |
|
93 | 94 | "explicit exit code checks unnecessary"), |
|
94 | 95 | (uprefix + r'set -e', "don't use set -e"), |
|
95 | 96 | (uprefixc + r'( *)\t', "don't use tabs to indent"), |
|
96 | 97 | ], |
|
97 | 98 | # warnings |
|
98 | 99 | [] |
|
99 | 100 | ] |
|
100 | 101 | |
|
101 | 102 | for i in [0, 1]: |
|
102 | 103 | for p, m in testpats[i]: |
|
103 | 104 | if p.startswith(r'^'): |
|
104 | 105 | p = uprefix + p[1:] |
|
105 | 106 | else: |
|
106 | 107 | p = uprefix + ".*" + p |
|
107 | 108 | utestpats[i].append((p, m)) |
|
108 | 109 | |
|
109 | 110 | utestfilters = [ |
|
110 | 111 | (r"( *)(#([^\n]*\S)?)", repcomment), |
|
111 | 112 | ] |
|
112 | 113 | |
|
113 | 114 | pypats = [ |
|
114 | 115 | [ |
|
115 | 116 | (r'^\s*def\s*\w+\s*\(.*,\s*\(', |
|
116 | 117 | "tuple parameter unpacking not available in Python 3+"), |
|
117 | 118 | (r'lambda\s*\(.*,.*\)', |
|
118 | 119 | "tuple parameter unpacking not available in Python 3+"), |
|
119 | 120 | (r'(?<!def)\s+(cmp)\(', "cmp is not available in Python 3+"), |
|
120 | 121 | (r'\breduce\s*\(.*', "reduce is not available in Python 3+"), |
|
121 | 122 | (r'\.has_key\b', "dict.has_key is not available in Python 3+"), |
|
122 | 123 | (r'^\s*\t', "don't use tabs"), |
|
123 | 124 | (r'\S;\s*\n', "semicolon"), |
|
124 | 125 | (r'\w,\w', "missing whitespace after ,"), |
|
125 | 126 | (r'\w[+/*\-<>]\w', "missing whitespace in expression"), |
|
126 | 127 | (r'^\s+\w+=\w+[^,)\n]$', "missing whitespace in assignment"), |
|
127 | 128 | (r'(\s+)try:\n((?:\n|\1\s.*\n)+?)\1except.*?:\n' |
|
128 | 129 | r'((?:\n|\1\s.*\n)+?)\1finally:', 'no try/except/finally in Py2.4'), |
|
129 | 130 | (r'.{85}', "line too long"), |
|
130 | 131 | (r' x+[xo][\'"]\n\s+[\'"]x', 'string join across lines with no space'), |
|
131 | 132 | (r'[^\n]\Z', "no trailing newline"), |
|
132 | 133 | (r'(\S[ \t]+|^[ \t]+)\n', "trailing whitespace"), |
|
133 | 134 | # (r'^\s+[^_ \n][^_. \n]+_[^_\n]+\s*=', "don't use underbars in identifiers"), |
|
134 | 135 | (r'^\s+(self\.)?[A-za-z][a-z0-9]+[A-Z]\w* = ', |
|
135 | 136 | "don't use camelcase in identifiers"), |
|
136 | 137 | (r'^\s*(if|while|def|class|except|try)\s[^[\n]*:\s*[^\\n]#\s]+', |
|
137 | 138 | "linebreak after :"), |
|
138 | 139 | (r'class\s[^( \n]+:', "old-style class, use class foo(object)"), |
|
139 | 140 | (r'class\s[^( \n]+\(\):', |
|
140 | 141 | "class foo() not available in Python 2.4, use class foo(object)"), |
|
141 | 142 | (r'\b(%s)\(' % '|'.join(keyword.kwlist), |
|
142 | 143 | "Python keyword is not a function"), |
|
143 | 144 | (r',]', "unneeded trailing ',' in list"), |
|
144 | 145 | # (r'class\s[A-Z][^\(]*\((?!Exception)', |
|
145 | 146 | # "don't capitalize non-exception classes"), |
|
146 | 147 | # (r'in range\(', "use xrange"), |
|
147 | 148 | # (r'^\s*print\s+', "avoid using print in core and extensions"), |
|
148 | 149 | (r'[\x80-\xff]', "non-ASCII character literal"), |
|
149 | 150 | (r'("\')\.format\(', "str.format() not available in Python 2.4"), |
|
150 | 151 | (r'^\s*with\s+', "with not available in Python 2.4"), |
|
151 | 152 | (r'\.isdisjoint\(', "set.isdisjoint not available in Python 2.4"), |
|
152 | 153 | (r'^\s*except.* as .*:', "except as not available in Python 2.4"), |
|
153 | 154 | (r'^\s*os\.path\.relpath', "relpath not available in Python 2.4"), |
|
154 | 155 | (r'(?<!def)\s+(any|all|format)\(', |
|
155 | 156 | "any/all/format not available in Python 2.4"), |
|
156 | 157 | (r'(?<!def)\s+(callable)\(', |
|
157 | 158 | "callable not available in Python 3, use getattr(f, '__call__', None)"), |
|
158 | 159 | (r'if\s.*\selse', "if ... else form not available in Python 2.4"), |
|
159 | 160 | (r'^\s*(%s)\s\s' % '|'.join(keyword.kwlist), |
|
160 | 161 | "gratuitous whitespace after Python keyword"), |
|
161 | 162 | (r'([\(\[][ \t]\S)|(\S[ \t][\)\]])', "gratuitous whitespace in () or []"), |
|
162 | 163 | # (r'\s\s=', "gratuitous whitespace before ="), |
|
163 | 164 | (r'[^>< ](\+=|-=|!=|<>|<=|>=|<<=|>>=)\S', |
|
164 | 165 | "missing whitespace around operator"), |
|
165 | 166 | (r'[^>< ](\+=|-=|!=|<>|<=|>=|<<=|>>=)\s', |
|
166 | 167 | "missing whitespace around operator"), |
|
167 | 168 | (r'\s(\+=|-=|!=|<>|<=|>=|<<=|>>=)\S', |
|
168 | 169 | "missing whitespace around operator"), |
|
169 | 170 | (r'[^+=*/!<>&| -](\s=|=\s)[^= ]', |
|
170 | 171 | "wrong whitespace around ="), |
|
171 | 172 | (r'raise Exception', "don't raise generic exceptions"), |
|
172 | 173 | (r' is\s+(not\s+)?["\'0-9-]', "object comparison with literal"), |
|
173 | 174 | (r' [=!]=\s+(True|False|None)', |
|
174 | 175 | "comparison with singleton, use 'is' or 'is not' instead"), |
|
175 | 176 | (r'^\s*(while|if) [01]:', |
|
176 | 177 | "use True/False for constant Boolean expression"), |
|
177 | 178 | (r'(?<!def)\s+hasattr', |
|
178 | 179 | 'hasattr(foo, bar) is broken, use util.safehasattr(foo, bar) instead'), |
|
179 | 180 | (r'opener\([^)]*\).read\(', |
|
180 | 181 | "use opener.read() instead"), |
|
181 | 182 | (r'BaseException', 'not in Py2.4, use Exception'), |
|
182 | 183 | (r'os\.path\.relpath', 'os.path.relpath is not in Py2.5'), |
|
183 | 184 | (r'opener\([^)]*\).write\(', |
|
184 | 185 | "use opener.write() instead"), |
|
185 | 186 | (r'[\s\(](open|file)\([^)]*\)\.read\(', |
|
186 | 187 | "use util.readfile() instead"), |
|
187 | 188 | (r'[\s\(](open|file)\([^)]*\)\.write\(', |
|
188 | 189 | "use util.readfile() instead"), |
|
189 | 190 | (r'^[\s\(]*(open(er)?|file)\([^)]*\)', |
|
190 | 191 | "always assign an opened file to a variable, and close it afterwards"), |
|
191 | 192 | (r'[\s\(](open|file)\([^)]*\)\.', |
|
192 | 193 | "always assign an opened file to a variable, and close it afterwards"), |
|
193 | 194 | (r'(?i)descendent', "the proper spelling is descendAnt"), |
|
194 | 195 | (r'\.debug\(\_', "don't mark debug messages for translation"), |
|
195 | 196 | ], |
|
196 | 197 | # warnings |
|
197 | 198 | [ |
|
198 | 199 | (r'.{81}', "warning: line over 80 characters"), |
|
199 | 200 | (r'^\s*except:$', "warning: naked except clause"), |
|
200 | 201 | (r'ui\.(status|progress|write|note|warn)\([\'\"]x', |
|
201 | 202 | "warning: unwrapped ui message"), |
|
202 | 203 | ] |
|
203 | 204 | ] |
|
204 | 205 | |
|
205 | 206 | pyfilters = [ |
|
206 | 207 | (r"""(?msx)(?P<comment>\#.*?$)| |
|
207 | 208 | ((?P<quote>('''|\"\"\"|(?<!')'(?!')|(?<!")"(?!"))) |
|
208 | 209 | (?P<text>(([^\\]|\\.)*?)) |
|
209 | 210 | (?P=quote))""", reppython), |
|
210 | 211 | ] |
|
211 | 212 | |
|
212 | 213 | cpats = [ |
|
213 | 214 | [ |
|
214 | 215 | (r'//', "don't use //-style comments"), |
|
215 | 216 | (r'^ ', "don't use spaces to indent"), |
|
216 | 217 | (r'\S\t', "don't use tabs except for indent"), |
|
217 | 218 | (r'(\S[ \t]+|^[ \t]+)\n', "trailing whitespace"), |
|
218 | 219 | (r'.{85}', "line too long"), |
|
219 | 220 | (r'(while|if|do|for)\(', "use space after while/if/do/for"), |
|
220 | 221 | (r'return\(', "return is not a function"), |
|
221 | 222 | (r' ;', "no space before ;"), |
|
222 | 223 | (r'\w+\* \w+', "use int *foo, not int* foo"), |
|
223 | 224 | (r'\([^\)]+\) \w+', "use (int)foo, not (int) foo"), |
|
224 | 225 | (r'\S+ (\+\+|--)', "use foo++, not foo ++"), |
|
225 | 226 | (r'\w,\w', "missing whitespace after ,"), |
|
226 | 227 | (r'^[^#]\w[+/*]\w', "missing whitespace in expression"), |
|
227 | 228 | (r'^#\s+\w', "use #foo, not # foo"), |
|
228 | 229 | (r'[^\n]\Z', "no trailing newline"), |
|
229 | 230 | (r'^\s*#import\b', "use only #include in standard C code"), |
|
230 | 231 | ], |
|
231 | 232 | # warnings |
|
232 | 233 | [] |
|
233 | 234 | ] |
|
234 | 235 | |
|
235 | 236 | cfilters = [ |
|
236 | 237 | (r'(/\*)(((\*(?!/))|[^*])*)\*/', repccomment), |
|
237 | 238 | (r'''(?P<quote>(?<!")")(?P<text>([^"]|\\")+)"(?!")''', repquote), |
|
238 | 239 | (r'''(#\s*include\s+<)([^>]+)>''', repinclude), |
|
239 | 240 | (r'(\()([^)]+\))', repcallspaces), |
|
240 | 241 | ] |
|
241 | 242 | |
|
242 | 243 | inutilpats = [ |
|
243 | 244 | [ |
|
244 | 245 | (r'\bui\.', "don't use ui in util"), |
|
245 | 246 | ], |
|
246 | 247 | # warnings |
|
247 | 248 | [] |
|
248 | 249 | ] |
|
249 | 250 | |
|
250 | 251 | inrevlogpats = [ |
|
251 | 252 | [ |
|
252 | 253 | (r'\brepo\.', "don't use repo in revlog"), |
|
253 | 254 | ], |
|
254 | 255 | # warnings |
|
255 | 256 | [] |
|
256 | 257 | ] |
|
257 | 258 | |
|
258 | 259 | checks = [ |
|
259 | 260 | ('python', r'.*\.(py|cgi)$', pyfilters, pypats), |
|
260 | 261 | ('test script', r'(.*/)?test-[^.~]*$', testfilters, testpats), |
|
261 | 262 | ('c', r'.*\.c$', cfilters, cpats), |
|
262 | 263 | ('unified test', r'.*\.t$', utestfilters, utestpats), |
|
263 | 264 | ('layering violation repo in revlog', r'mercurial/revlog\.py', pyfilters, |
|
264 | 265 | inrevlogpats), |
|
265 | 266 | ('layering violation ui in util', r'mercurial/util\.py', pyfilters, |
|
266 | 267 | inutilpats), |
|
267 | 268 | ] |
|
268 | 269 | |
|
269 | 270 | class norepeatlogger(object): |
|
270 | 271 | def __init__(self): |
|
271 | 272 | self._lastseen = None |
|
272 | 273 | |
|
273 | 274 | def log(self, fname, lineno, line, msg, blame): |
|
274 | 275 | """print error related a to given line of a given file. |
|
275 | 276 | |
|
276 | 277 | The faulty line will also be printed but only once in the case |
|
277 | 278 | of multiple errors. |
|
278 | 279 | |
|
279 | 280 | :fname: filename |
|
280 | 281 | :lineno: line number |
|
281 | 282 | :line: actual content of the line |
|
282 | 283 | :msg: error message |
|
283 | 284 | """ |
|
284 | 285 | msgid = fname, lineno, line |
|
285 | 286 | if msgid != self._lastseen: |
|
286 | 287 | if blame: |
|
287 | 288 | print "%s:%d (%s):" % (fname, lineno, blame) |
|
288 | 289 | else: |
|
289 | 290 | print "%s:%d:" % (fname, lineno) |
|
290 | 291 | print " > %s" % line |
|
291 | 292 | self._lastseen = msgid |
|
292 | 293 | print " " + msg |
|
293 | 294 | |
|
294 | 295 | _defaultlogger = norepeatlogger() |
|
295 | 296 | |
|
296 | 297 | def getblame(f): |
|
297 | 298 | lines = [] |
|
298 | 299 | for l in os.popen('hg annotate -un %s' % f): |
|
299 | 300 | start, line = l.split(':', 1) |
|
300 | 301 | user, rev = start.split() |
|
301 | 302 | lines.append((line[1:-1], user, rev)) |
|
302 | 303 | return lines |
|
303 | 304 | |
|
304 | 305 | def checkfile(f, logfunc=_defaultlogger.log, maxerr=None, warnings=False, |
|
305 | 306 | blame=False, debug=False, lineno=True): |
|
306 | 307 | """checks style and portability of a given file |
|
307 | 308 | |
|
308 | 309 | :f: filepath |
|
309 | 310 | :logfunc: function used to report error |
|
310 | 311 | logfunc(filename, linenumber, linecontent, errormessage) |
|
311 | 312 | :maxerr: number of error to display before arborting. |
|
312 | 313 | Set to false (default) to report all errors |
|
313 | 314 | |
|
314 | 315 | return True if no error is found, False otherwise. |
|
315 | 316 | """ |
|
316 | 317 | blamecache = None |
|
317 | 318 | result = True |
|
318 | 319 | for name, match, filters, pats in checks: |
|
319 | 320 | if debug: |
|
320 | 321 | print name, f |
|
321 | 322 | fc = 0 |
|
322 | 323 | if not re.match(match, f): |
|
323 | 324 | if debug: |
|
324 | 325 | print "Skipping %s for %s it doesn't match %s" % ( |
|
325 | 326 | name, match, f) |
|
326 | 327 | continue |
|
327 | 328 | fp = open(f) |
|
328 | 329 | pre = post = fp.read() |
|
329 | 330 | fp.close() |
|
330 | 331 | if "no-" + "check-code" in pre: |
|
331 | 332 | if debug: |
|
332 | 333 | print "Skipping %s for %s it has no- and check-code" % ( |
|
333 | 334 | name, f) |
|
334 | 335 | break |
|
335 | 336 | for p, r in filters: |
|
336 | 337 | post = re.sub(p, r, post) |
|
337 | 338 | if warnings: |
|
338 | 339 | pats = pats[0] + pats[1] |
|
339 | 340 | else: |
|
340 | 341 | pats = pats[0] |
|
341 | 342 | # print post # uncomment to show filtered version |
|
342 | 343 | |
|
343 | 344 | if debug: |
|
344 | 345 | print "Checking %s for %s" % (name, f) |
|
345 | 346 | |
|
346 | 347 | prelines = None |
|
347 | 348 | errors = [] |
|
348 | 349 | for p, msg in pats: |
|
349 | 350 | # fix-up regexes for multiline searches |
|
350 | 351 | po = p |
|
351 | 352 | # \s doesn't match \n |
|
352 | 353 | p = re.sub(r'(?<!\\)\\s', r'[ \\t]', p) |
|
353 | 354 | # [^...] doesn't match newline |
|
354 | 355 | p = re.sub(r'(?<!\\)\[\^', r'[^\\n', p) |
|
355 | 356 | |
|
356 | 357 | #print po, '=>', p |
|
357 | 358 | |
|
358 | 359 | pos = 0 |
|
359 | 360 | n = 0 |
|
360 | 361 | for m in re.finditer(p, post, re.MULTILINE): |
|
361 | 362 | if prelines is None: |
|
362 | 363 | prelines = pre.splitlines() |
|
363 | 364 | postlines = post.splitlines(True) |
|
364 | 365 | |
|
365 | 366 | start = m.start() |
|
366 | 367 | while n < len(postlines): |
|
367 | 368 | step = len(postlines[n]) |
|
368 | 369 | if pos + step > start: |
|
369 | 370 | break |
|
370 | 371 | pos += step |
|
371 | 372 | n += 1 |
|
372 | 373 | l = prelines[n] |
|
373 | 374 | |
|
374 | 375 | if "check-code" + "-ignore" in l: |
|
375 | 376 | if debug: |
|
376 | 377 | print "Skipping %s for %s:%s (check-code -ignore)" % ( |
|
377 | 378 | name, f, n) |
|
378 | 379 | continue |
|
379 | 380 | bd = "" |
|
380 | 381 | if blame: |
|
381 | 382 | bd = 'working directory' |
|
382 | 383 | if not blamecache: |
|
383 | 384 | blamecache = getblame(f) |
|
384 | 385 | if n < len(blamecache): |
|
385 | 386 | bl, bu, br = blamecache[n] |
|
386 | 387 | if bl == l: |
|
387 | 388 | bd = '%s@%s' % (bu, br) |
|
388 | 389 | errors.append((f, lineno and n + 1, l, msg, bd)) |
|
389 | 390 | result = False |
|
390 | 391 | |
|
391 | 392 | errors.sort() |
|
392 | 393 | for e in errors: |
|
393 | 394 | logfunc(*e) |
|
394 | 395 | fc += 1 |
|
395 | 396 | if maxerr and fc >= maxerr: |
|
396 | 397 | print " (too many errors, giving up)" |
|
397 | 398 | break |
|
398 | 399 | |
|
399 | 400 | return result |
|
400 | 401 | |
|
401 | 402 | if __name__ == "__main__": |
|
402 | 403 | parser = optparse.OptionParser("%prog [options] [files]") |
|
403 | 404 | parser.add_option("-w", "--warnings", action="store_true", |
|
404 | 405 | help="include warning-level checks") |
|
405 | 406 | parser.add_option("-p", "--per-file", type="int", |
|
406 | 407 | help="max warnings per file") |
|
407 | 408 | parser.add_option("-b", "--blame", action="store_true", |
|
408 | 409 | help="use annotate to generate blame info") |
|
409 | 410 | parser.add_option("", "--debug", action="store_true", |
|
410 | 411 | help="show debug information") |
|
411 | 412 | parser.add_option("", "--nolineno", action="store_false", |
|
412 | 413 | dest='lineno', help="don't show line numbers") |
|
413 | 414 | |
|
414 | 415 | parser.set_defaults(per_file=15, warnings=False, blame=False, debug=False, |
|
415 | 416 | lineno=True) |
|
416 | 417 | (options, args) = parser.parse_args() |
|
417 | 418 | |
|
418 | 419 | if len(args) == 0: |
|
419 | 420 | check = glob.glob("*") |
|
420 | 421 | else: |
|
421 | 422 | check = args |
|
422 | 423 | |
|
423 | 424 | ret = 0 |
|
424 | 425 | for f in check: |
|
425 | 426 | if not checkfile(f, maxerr=options.per_file, warnings=options.warnings, |
|
426 | 427 | blame=options.blame, debug=options.debug, |
|
427 | 428 | lineno=options.lineno): |
|
428 | 429 | ret = 1 |
|
429 | 430 | sys.exit(ret) |
@@ -1,1018 +1,1018 b'' | |||
|
1 | 1 | $ cat >> $HGRCPATH <<EOF |
|
2 | 2 | > [extensions] |
|
3 | 3 | > graphlog= |
|
4 | 4 | > EOF |
|
5 |
$ |
|
|
5 | $ hgph() { hg log -G --template "{rev} {phase} {desc} - {node|short}\n" $*; } | |
|
6 | 6 | |
|
7 | 7 | $ mkcommit() { |
|
8 | 8 | > echo "$1" > "$1" |
|
9 | 9 | > hg add "$1" |
|
10 | 10 | > message="$1" |
|
11 | 11 | > shift |
|
12 | 12 | > hg ci -m "$message" $* |
|
13 | 13 | > } |
|
14 | 14 | |
|
15 | 15 | $ hg init alpha |
|
16 | 16 | $ cd alpha |
|
17 | 17 | $ mkcommit a-A |
|
18 | 18 | $ mkcommit a-B |
|
19 | 19 | $ mkcommit a-C |
|
20 | 20 | $ mkcommit a-D |
|
21 | 21 | $ hgph |
|
22 | 22 | @ 3 draft a-D - b555f63b6063 |
|
23 | 23 | | |
|
24 | 24 | o 2 draft a-C - 54acac6f23ab |
|
25 | 25 | | |
|
26 | 26 | o 1 draft a-B - 548a3d25dbf0 |
|
27 | 27 | | |
|
28 | 28 | o 0 draft a-A - 054250a37db4 |
|
29 | 29 | |
|
30 | 30 | |
|
31 | 31 | $ hg init ../beta |
|
32 | 32 | $ hg push -r 1 ../beta |
|
33 | 33 | pushing to ../beta |
|
34 | 34 | searching for changes |
|
35 | 35 | adding changesets |
|
36 | 36 | adding manifests |
|
37 | 37 | adding file changes |
|
38 | 38 | added 2 changesets with 2 changes to 2 files |
|
39 | 39 | $ hgph |
|
40 | 40 | @ 3 draft a-D - b555f63b6063 |
|
41 | 41 | | |
|
42 | 42 | o 2 draft a-C - 54acac6f23ab |
|
43 | 43 | | |
|
44 | 44 | o 1 public a-B - 548a3d25dbf0 |
|
45 | 45 | | |
|
46 | 46 | o 0 public a-A - 054250a37db4 |
|
47 | 47 | |
|
48 | 48 | |
|
49 | 49 | $ cd ../beta |
|
50 | 50 | $ hgph |
|
51 | 51 | o 1 public a-B - 548a3d25dbf0 |
|
52 | 52 | | |
|
53 | 53 | o 0 public a-A - 054250a37db4 |
|
54 | 54 | |
|
55 | 55 | $ hg up -q |
|
56 | 56 | $ mkcommit b-A |
|
57 | 57 | $ hgph |
|
58 | 58 | @ 2 draft b-A - f54f1bb90ff3 |
|
59 | 59 | | |
|
60 | 60 | o 1 public a-B - 548a3d25dbf0 |
|
61 | 61 | | |
|
62 | 62 | o 0 public a-A - 054250a37db4 |
|
63 | 63 | |
|
64 | 64 | $ hg pull ../alpha |
|
65 | 65 | pulling from ../alpha |
|
66 | 66 | searching for changes |
|
67 | 67 | adding changesets |
|
68 | 68 | adding manifests |
|
69 | 69 | adding file changes |
|
70 | 70 | added 2 changesets with 2 changes to 2 files (+1 heads) |
|
71 | 71 | (run 'hg heads' to see heads, 'hg merge' to merge) |
|
72 | 72 | $ hgph |
|
73 | 73 | o 4 public a-D - b555f63b6063 |
|
74 | 74 | | |
|
75 | 75 | o 3 public a-C - 54acac6f23ab |
|
76 | 76 | | |
|
77 | 77 | | @ 2 draft b-A - f54f1bb90ff3 |
|
78 | 78 | |/ |
|
79 | 79 | o 1 public a-B - 548a3d25dbf0 |
|
80 | 80 | | |
|
81 | 81 | o 0 public a-A - 054250a37db4 |
|
82 | 82 | |
|
83 | 83 | |
|
84 | 84 | pull did not updated ../alpha state. |
|
85 | 85 | push from alpha to beta should update phase even if nothing is transfered |
|
86 | 86 | |
|
87 | 87 | $ cd ../alpha |
|
88 | 88 | $ hgph # not updated by remote pull |
|
89 | 89 | @ 3 draft a-D - b555f63b6063 |
|
90 | 90 | | |
|
91 | 91 | o 2 draft a-C - 54acac6f23ab |
|
92 | 92 | | |
|
93 | 93 | o 1 public a-B - 548a3d25dbf0 |
|
94 | 94 | | |
|
95 | 95 | o 0 public a-A - 054250a37db4 |
|
96 | 96 | |
|
97 | 97 | $ hg push ../beta |
|
98 | 98 | pushing to ../beta |
|
99 | 99 | searching for changes |
|
100 | 100 | no changes found |
|
101 | 101 | $ hgph |
|
102 | 102 | @ 3 public a-D - b555f63b6063 |
|
103 | 103 | | |
|
104 | 104 | o 2 public a-C - 54acac6f23ab |
|
105 | 105 | | |
|
106 | 106 | o 1 public a-B - 548a3d25dbf0 |
|
107 | 107 | | |
|
108 | 108 | o 0 public a-A - 054250a37db4 |
|
109 | 109 | |
|
110 | 110 | |
|
111 | 111 | update must update phase of common changeset too |
|
112 | 112 | |
|
113 | 113 | $ hg pull ../beta # getting b-A |
|
114 | 114 | pulling from ../beta |
|
115 | 115 | searching for changes |
|
116 | 116 | adding changesets |
|
117 | 117 | adding manifests |
|
118 | 118 | adding file changes |
|
119 | 119 | added 1 changesets with 1 changes to 1 files (+1 heads) |
|
120 | 120 | (run 'hg heads' to see heads, 'hg merge' to merge) |
|
121 | 121 | |
|
122 | 122 | $ cd ../beta |
|
123 | 123 | $ hgph # not updated by remote pull |
|
124 | 124 | o 4 public a-D - b555f63b6063 |
|
125 | 125 | | |
|
126 | 126 | o 3 public a-C - 54acac6f23ab |
|
127 | 127 | | |
|
128 | 128 | | @ 2 draft b-A - f54f1bb90ff3 |
|
129 | 129 | |/ |
|
130 | 130 | o 1 public a-B - 548a3d25dbf0 |
|
131 | 131 | | |
|
132 | 132 | o 0 public a-A - 054250a37db4 |
|
133 | 133 | |
|
134 | 134 | $ hg pull ../alpha |
|
135 | 135 | pulling from ../alpha |
|
136 | 136 | searching for changes |
|
137 | 137 | no changes found |
|
138 | 138 | $ hgph |
|
139 | 139 | o 4 public a-D - b555f63b6063 |
|
140 | 140 | | |
|
141 | 141 | o 3 public a-C - 54acac6f23ab |
|
142 | 142 | | |
|
143 | 143 | | @ 2 public b-A - f54f1bb90ff3 |
|
144 | 144 | |/ |
|
145 | 145 | o 1 public a-B - 548a3d25dbf0 |
|
146 | 146 | | |
|
147 | 147 | o 0 public a-A - 054250a37db4 |
|
148 | 148 | |
|
149 | 149 | |
|
150 | 150 | Publish configuration option |
|
151 | 151 | ---------------------------- |
|
152 | 152 | |
|
153 | 153 | Pull |
|
154 | 154 | ```` |
|
155 | 155 | |
|
156 | 156 | changegroup are added without phase movement |
|
157 | 157 | |
|
158 | 158 | $ hg bundle -a ../base.bundle |
|
159 | 159 | 5 changesets found |
|
160 | 160 | $ cd .. |
|
161 | 161 | $ hg init mu |
|
162 | 162 | $ cd mu |
|
163 | 163 | $ cat > .hg/hgrc << EOF |
|
164 | 164 | > [phases] |
|
165 | 165 | > publish=0 |
|
166 | 166 | > EOF |
|
167 | 167 | $ hg unbundle ../base.bundle |
|
168 | 168 | adding changesets |
|
169 | 169 | adding manifests |
|
170 | 170 | adding file changes |
|
171 | 171 | added 5 changesets with 5 changes to 5 files (+1 heads) |
|
172 | 172 | (run 'hg heads' to see heads, 'hg merge' to merge) |
|
173 | 173 | $ hgph |
|
174 | 174 | o 4 draft a-D - b555f63b6063 |
|
175 | 175 | | |
|
176 | 176 | o 3 draft a-C - 54acac6f23ab |
|
177 | 177 | | |
|
178 | 178 | | o 2 draft b-A - f54f1bb90ff3 |
|
179 | 179 | |/ |
|
180 | 180 | o 1 draft a-B - 548a3d25dbf0 |
|
181 | 181 | | |
|
182 | 182 | o 0 draft a-A - 054250a37db4 |
|
183 | 183 | |
|
184 | 184 | $ cd .. |
|
185 | 185 | |
|
186 | 186 | Pulling from publish=False to publish=False does not move boundary. |
|
187 | 187 | |
|
188 | 188 | $ hg init nu |
|
189 | 189 | $ cd nu |
|
190 | 190 | $ cat > .hg/hgrc << EOF |
|
191 | 191 | > [phases] |
|
192 | 192 | > publish=0 |
|
193 | 193 | > EOF |
|
194 | 194 | $ hg pull ../mu -r 54acac6f23ab |
|
195 | 195 | pulling from ../mu |
|
196 | 196 | adding changesets |
|
197 | 197 | adding manifests |
|
198 | 198 | adding file changes |
|
199 | 199 | added 3 changesets with 3 changes to 3 files |
|
200 | 200 | (run 'hg update' to get a working copy) |
|
201 | 201 | $ hgph |
|
202 | 202 | o 2 draft a-C - 54acac6f23ab |
|
203 | 203 | | |
|
204 | 204 | o 1 draft a-B - 548a3d25dbf0 |
|
205 | 205 | | |
|
206 | 206 | o 0 draft a-A - 054250a37db4 |
|
207 | 207 | |
|
208 | 208 | |
|
209 | 209 | Even for common |
|
210 | 210 | |
|
211 | 211 | $ hg pull ../mu -r f54f1bb90ff3 |
|
212 | 212 | pulling from ../mu |
|
213 | 213 | searching for changes |
|
214 | 214 | adding changesets |
|
215 | 215 | adding manifests |
|
216 | 216 | adding file changes |
|
217 | 217 | added 1 changesets with 1 changes to 1 files (+1 heads) |
|
218 | 218 | (run 'hg heads' to see heads, 'hg merge' to merge) |
|
219 | 219 | $ hgph |
|
220 | 220 | o 3 draft b-A - f54f1bb90ff3 |
|
221 | 221 | | |
|
222 | 222 | | o 2 draft a-C - 54acac6f23ab |
|
223 | 223 | |/ |
|
224 | 224 | o 1 draft a-B - 548a3d25dbf0 |
|
225 | 225 | | |
|
226 | 226 | o 0 draft a-A - 054250a37db4 |
|
227 | 227 | |
|
228 | 228 | |
|
229 | 229 | |
|
230 | 230 | Pulling from Publish=True to Publish=False move boundary in common set. |
|
231 | 231 | we are in nu |
|
232 | 232 | |
|
233 | 233 | $ hg pull ../alpha -r b555f63b6063 |
|
234 | 234 | pulling from ../alpha |
|
235 | 235 | searching for changes |
|
236 | 236 | adding changesets |
|
237 | 237 | adding manifests |
|
238 | 238 | adding file changes |
|
239 | 239 | added 1 changesets with 1 changes to 1 files |
|
240 | 240 | (run 'hg update' to get a working copy) |
|
241 | 241 | $ hgph # f54f1bb90ff3 stay draft, not ancestor of -r |
|
242 | 242 | o 4 public a-D - b555f63b6063 |
|
243 | 243 | | |
|
244 | 244 | | o 3 draft b-A - f54f1bb90ff3 |
|
245 | 245 | | | |
|
246 | 246 | o | 2 public a-C - 54acac6f23ab |
|
247 | 247 | |/ |
|
248 | 248 | o 1 public a-B - 548a3d25dbf0 |
|
249 | 249 | | |
|
250 | 250 | o 0 public a-A - 054250a37db4 |
|
251 | 251 | |
|
252 | 252 | |
|
253 | 253 | pulling from Publish=False to publish=False with some public |
|
254 | 254 | |
|
255 | 255 | $ hg up -q f54f1bb90ff3 |
|
256 | 256 | $ mkcommit n-A |
|
257 | 257 | $ mkcommit n-B |
|
258 | 258 | $ hgph |
|
259 | 259 | @ 6 draft n-B - 145e75495359 |
|
260 | 260 | | |
|
261 | 261 | o 5 draft n-A - d6bcb4f74035 |
|
262 | 262 | | |
|
263 | 263 | | o 4 public a-D - b555f63b6063 |
|
264 | 264 | | | |
|
265 | 265 | o | 3 draft b-A - f54f1bb90ff3 |
|
266 | 266 | | | |
|
267 | 267 | | o 2 public a-C - 54acac6f23ab |
|
268 | 268 | |/ |
|
269 | 269 | o 1 public a-B - 548a3d25dbf0 |
|
270 | 270 | | |
|
271 | 271 | o 0 public a-A - 054250a37db4 |
|
272 | 272 | |
|
273 | 273 | $ cd ../mu |
|
274 | 274 | $ hg pull ../nu |
|
275 | 275 | pulling from ../nu |
|
276 | 276 | searching for changes |
|
277 | 277 | adding changesets |
|
278 | 278 | adding manifests |
|
279 | 279 | adding file changes |
|
280 | 280 | added 2 changesets with 2 changes to 2 files |
|
281 | 281 | (run 'hg update' to get a working copy) |
|
282 | 282 | $ hgph |
|
283 | 283 | o 6 draft n-B - 145e75495359 |
|
284 | 284 | | |
|
285 | 285 | o 5 draft n-A - d6bcb4f74035 |
|
286 | 286 | | |
|
287 | 287 | | o 4 public a-D - b555f63b6063 |
|
288 | 288 | | | |
|
289 | 289 | | o 3 public a-C - 54acac6f23ab |
|
290 | 290 | | | |
|
291 | 291 | o | 2 draft b-A - f54f1bb90ff3 |
|
292 | 292 | |/ |
|
293 | 293 | o 1 public a-B - 548a3d25dbf0 |
|
294 | 294 | | |
|
295 | 295 | o 0 public a-A - 054250a37db4 |
|
296 | 296 | |
|
297 | 297 | $ cd .. |
|
298 | 298 | |
|
299 | 299 | pulling into publish=True |
|
300 | 300 | |
|
301 | 301 | $ cd alpha |
|
302 | 302 | $ hgph |
|
303 | 303 | o 4 public b-A - f54f1bb90ff3 |
|
304 | 304 | | |
|
305 | 305 | | @ 3 public a-D - b555f63b6063 |
|
306 | 306 | | | |
|
307 | 307 | | o 2 public a-C - 54acac6f23ab |
|
308 | 308 | |/ |
|
309 | 309 | o 1 public a-B - 548a3d25dbf0 |
|
310 | 310 | | |
|
311 | 311 | o 0 public a-A - 054250a37db4 |
|
312 | 312 | |
|
313 | 313 | $ hg pull ../mu |
|
314 | 314 | pulling from ../mu |
|
315 | 315 | searching for changes |
|
316 | 316 | adding changesets |
|
317 | 317 | adding manifests |
|
318 | 318 | adding file changes |
|
319 | 319 | added 2 changesets with 2 changes to 2 files |
|
320 | 320 | (run 'hg update' to get a working copy) |
|
321 | 321 | $ hgph |
|
322 | 322 | o 6 draft n-B - 145e75495359 |
|
323 | 323 | | |
|
324 | 324 | o 5 draft n-A - d6bcb4f74035 |
|
325 | 325 | | |
|
326 | 326 | o 4 public b-A - f54f1bb90ff3 |
|
327 | 327 | | |
|
328 | 328 | | @ 3 public a-D - b555f63b6063 |
|
329 | 329 | | | |
|
330 | 330 | | o 2 public a-C - 54acac6f23ab |
|
331 | 331 | |/ |
|
332 | 332 | o 1 public a-B - 548a3d25dbf0 |
|
333 | 333 | | |
|
334 | 334 | o 0 public a-A - 054250a37db4 |
|
335 | 335 | |
|
336 | 336 | $ cd .. |
|
337 | 337 | |
|
338 | 338 | pulling back into original repo |
|
339 | 339 | |
|
340 | 340 | $ cd nu |
|
341 | 341 | $ hg pull ../alpha |
|
342 | 342 | pulling from ../alpha |
|
343 | 343 | searching for changes |
|
344 | 344 | no changes found |
|
345 | 345 | $ hgph |
|
346 | 346 | @ 6 public n-B - 145e75495359 |
|
347 | 347 | | |
|
348 | 348 | o 5 public n-A - d6bcb4f74035 |
|
349 | 349 | | |
|
350 | 350 | | o 4 public a-D - b555f63b6063 |
|
351 | 351 | | | |
|
352 | 352 | o | 3 public b-A - f54f1bb90ff3 |
|
353 | 353 | | | |
|
354 | 354 | | o 2 public a-C - 54acac6f23ab |
|
355 | 355 | |/ |
|
356 | 356 | o 1 public a-B - 548a3d25dbf0 |
|
357 | 357 | | |
|
358 | 358 | o 0 public a-A - 054250a37db4 |
|
359 | 359 | |
|
360 | 360 | |
|
361 | 361 | Push |
|
362 | 362 | ```` |
|
363 | 363 | |
|
364 | 364 | (inserted) |
|
365 | 365 | |
|
366 | 366 | Test that phase are pushed even when they are nothing to pus |
|
367 | 367 | (this might be tested later bu are very convenient to not alter too much test) |
|
368 | 368 | |
|
369 | 369 | Push back to alpha |
|
370 | 370 | |
|
371 | 371 | $ hg push ../alpha # from nu |
|
372 | 372 | pushing to ../alpha |
|
373 | 373 | searching for changes |
|
374 | 374 | no changes found |
|
375 | 375 | $ cd .. |
|
376 | 376 | $ cd alpha |
|
377 | 377 | $ hgph |
|
378 | 378 | o 6 public n-B - 145e75495359 |
|
379 | 379 | | |
|
380 | 380 | o 5 public n-A - d6bcb4f74035 |
|
381 | 381 | | |
|
382 | 382 | o 4 public b-A - f54f1bb90ff3 |
|
383 | 383 | | |
|
384 | 384 | | @ 3 public a-D - b555f63b6063 |
|
385 | 385 | | | |
|
386 | 386 | | o 2 public a-C - 54acac6f23ab |
|
387 | 387 | |/ |
|
388 | 388 | o 1 public a-B - 548a3d25dbf0 |
|
389 | 389 | | |
|
390 | 390 | o 0 public a-A - 054250a37db4 |
|
391 | 391 | |
|
392 | 392 | |
|
393 | 393 | (end insertion) |
|
394 | 394 | |
|
395 | 395 | |
|
396 | 396 | initial setup |
|
397 | 397 | |
|
398 | 398 | $ hg glog # of alpha |
|
399 | 399 | o changeset: 6:145e75495359 |
|
400 | 400 | | tag: tip |
|
401 | 401 | | user: test |
|
402 | 402 | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
403 | 403 | | summary: n-B |
|
404 | 404 | | |
|
405 | 405 | o changeset: 5:d6bcb4f74035 |
|
406 | 406 | | user: test |
|
407 | 407 | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
408 | 408 | | summary: n-A |
|
409 | 409 | | |
|
410 | 410 | o changeset: 4:f54f1bb90ff3 |
|
411 | 411 | | parent: 1:548a3d25dbf0 |
|
412 | 412 | | user: test |
|
413 | 413 | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
414 | 414 | | summary: b-A |
|
415 | 415 | | |
|
416 | 416 | | @ changeset: 3:b555f63b6063 |
|
417 | 417 | | | user: test |
|
418 | 418 | | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
419 | 419 | | | summary: a-D |
|
420 | 420 | | | |
|
421 | 421 | | o changeset: 2:54acac6f23ab |
|
422 | 422 | |/ user: test |
|
423 | 423 | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
424 | 424 | | summary: a-C |
|
425 | 425 | | |
|
426 | 426 | o changeset: 1:548a3d25dbf0 |
|
427 | 427 | | user: test |
|
428 | 428 | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
429 | 429 | | summary: a-B |
|
430 | 430 | | |
|
431 | 431 | o changeset: 0:054250a37db4 |
|
432 | 432 | user: test |
|
433 | 433 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
434 | 434 | summary: a-A |
|
435 | 435 | |
|
436 | 436 | $ mkcommit a-E |
|
437 | 437 | $ mkcommit a-F |
|
438 | 438 | $ mkcommit a-G |
|
439 | 439 | $ hg up d6bcb4f74035 -q |
|
440 | 440 | $ mkcommit a-H |
|
441 | 441 | created new head |
|
442 | 442 | $ hgph |
|
443 | 443 | @ 10 draft a-H - 967b449fbc94 |
|
444 | 444 | | |
|
445 | 445 | | o 9 draft a-G - 3e27b6f1eee1 |
|
446 | 446 | | | |
|
447 | 447 | | o 8 draft a-F - b740e3e5c05d |
|
448 | 448 | | | |
|
449 | 449 | | o 7 draft a-E - e9f537e46dea |
|
450 | 450 | | | |
|
451 | 451 | +---o 6 public n-B - 145e75495359 |
|
452 | 452 | | | |
|
453 | 453 | o | 5 public n-A - d6bcb4f74035 |
|
454 | 454 | | | |
|
455 | 455 | o | 4 public b-A - f54f1bb90ff3 |
|
456 | 456 | | | |
|
457 | 457 | | o 3 public a-D - b555f63b6063 |
|
458 | 458 | | | |
|
459 | 459 | | o 2 public a-C - 54acac6f23ab |
|
460 | 460 | |/ |
|
461 | 461 | o 1 public a-B - 548a3d25dbf0 |
|
462 | 462 | | |
|
463 | 463 | o 0 public a-A - 054250a37db4 |
|
464 | 464 | |
|
465 | 465 | |
|
466 | 466 | Pushing to Publish=False (unknown changeset) |
|
467 | 467 | |
|
468 | 468 | $ hg push ../mu -r b740e3e5c05d # a-F |
|
469 | 469 | pushing to ../mu |
|
470 | 470 | searching for changes |
|
471 | 471 | adding changesets |
|
472 | 472 | adding manifests |
|
473 | 473 | adding file changes |
|
474 | 474 | added 2 changesets with 2 changes to 2 files |
|
475 | 475 | $ hgph |
|
476 | 476 | @ 10 draft a-H - 967b449fbc94 |
|
477 | 477 | | |
|
478 | 478 | | o 9 draft a-G - 3e27b6f1eee1 |
|
479 | 479 | | | |
|
480 | 480 | | o 8 draft a-F - b740e3e5c05d |
|
481 | 481 | | | |
|
482 | 482 | | o 7 draft a-E - e9f537e46dea |
|
483 | 483 | | | |
|
484 | 484 | +---o 6 public n-B - 145e75495359 |
|
485 | 485 | | | |
|
486 | 486 | o | 5 public n-A - d6bcb4f74035 |
|
487 | 487 | | | |
|
488 | 488 | o | 4 public b-A - f54f1bb90ff3 |
|
489 | 489 | | | |
|
490 | 490 | | o 3 public a-D - b555f63b6063 |
|
491 | 491 | | | |
|
492 | 492 | | o 2 public a-C - 54acac6f23ab |
|
493 | 493 | |/ |
|
494 | 494 | o 1 public a-B - 548a3d25dbf0 |
|
495 | 495 | | |
|
496 | 496 | o 0 public a-A - 054250a37db4 |
|
497 | 497 | |
|
498 | 498 | |
|
499 | 499 | $ cd ../mu |
|
500 | 500 | $ hgph # again f54f1bb90ff3, d6bcb4f74035 and 145e75495359 stay draft, |
|
501 | 501 | > # not ancestor of -r |
|
502 | 502 | o 8 draft a-F - b740e3e5c05d |
|
503 | 503 | | |
|
504 | 504 | o 7 draft a-E - e9f537e46dea |
|
505 | 505 | | |
|
506 | 506 | | o 6 draft n-B - 145e75495359 |
|
507 | 507 | | | |
|
508 | 508 | | o 5 draft n-A - d6bcb4f74035 |
|
509 | 509 | | | |
|
510 | 510 | o | 4 public a-D - b555f63b6063 |
|
511 | 511 | | | |
|
512 | 512 | o | 3 public a-C - 54acac6f23ab |
|
513 | 513 | | | |
|
514 | 514 | | o 2 draft b-A - f54f1bb90ff3 |
|
515 | 515 | |/ |
|
516 | 516 | o 1 public a-B - 548a3d25dbf0 |
|
517 | 517 | | |
|
518 | 518 | o 0 public a-A - 054250a37db4 |
|
519 | 519 | |
|
520 | 520 | |
|
521 | 521 | Pushing to Publish=True (unknown changeset) |
|
522 | 522 | |
|
523 | 523 | $ hg push ../beta -r b740e3e5c05d |
|
524 | 524 | pushing to ../beta |
|
525 | 525 | searching for changes |
|
526 | 526 | adding changesets |
|
527 | 527 | adding manifests |
|
528 | 528 | adding file changes |
|
529 | 529 | added 2 changesets with 2 changes to 2 files |
|
530 | 530 | $ hgph # again f54f1bb90ff3, d6bcb4f74035 and 145e75495359 stay draft, |
|
531 | 531 | > # not ancestor of -r |
|
532 | 532 | o 8 public a-F - b740e3e5c05d |
|
533 | 533 | | |
|
534 | 534 | o 7 public a-E - e9f537e46dea |
|
535 | 535 | | |
|
536 | 536 | | o 6 draft n-B - 145e75495359 |
|
537 | 537 | | | |
|
538 | 538 | | o 5 draft n-A - d6bcb4f74035 |
|
539 | 539 | | | |
|
540 | 540 | o | 4 public a-D - b555f63b6063 |
|
541 | 541 | | | |
|
542 | 542 | o | 3 public a-C - 54acac6f23ab |
|
543 | 543 | | | |
|
544 | 544 | | o 2 draft b-A - f54f1bb90ff3 |
|
545 | 545 | |/ |
|
546 | 546 | o 1 public a-B - 548a3d25dbf0 |
|
547 | 547 | | |
|
548 | 548 | o 0 public a-A - 054250a37db4 |
|
549 | 549 | |
|
550 | 550 | |
|
551 | 551 | Pushing to Publish=True (common changeset) |
|
552 | 552 | |
|
553 | 553 | $ cd ../beta |
|
554 | 554 | $ hg push ../alpha |
|
555 | 555 | pushing to ../alpha |
|
556 | 556 | searching for changes |
|
557 | 557 | no changes found |
|
558 | 558 | $ hgph |
|
559 | 559 | o 6 public a-F - b740e3e5c05d |
|
560 | 560 | | |
|
561 | 561 | o 5 public a-E - e9f537e46dea |
|
562 | 562 | | |
|
563 | 563 | o 4 public a-D - b555f63b6063 |
|
564 | 564 | | |
|
565 | 565 | o 3 public a-C - 54acac6f23ab |
|
566 | 566 | | |
|
567 | 567 | | @ 2 public b-A - f54f1bb90ff3 |
|
568 | 568 | |/ |
|
569 | 569 | o 1 public a-B - 548a3d25dbf0 |
|
570 | 570 | | |
|
571 | 571 | o 0 public a-A - 054250a37db4 |
|
572 | 572 | |
|
573 | 573 | $ cd ../alpha |
|
574 | 574 | $ hgph |
|
575 | 575 | @ 10 draft a-H - 967b449fbc94 |
|
576 | 576 | | |
|
577 | 577 | | o 9 draft a-G - 3e27b6f1eee1 |
|
578 | 578 | | | |
|
579 | 579 | | o 8 public a-F - b740e3e5c05d |
|
580 | 580 | | | |
|
581 | 581 | | o 7 public a-E - e9f537e46dea |
|
582 | 582 | | | |
|
583 | 583 | +---o 6 public n-B - 145e75495359 |
|
584 | 584 | | | |
|
585 | 585 | o | 5 public n-A - d6bcb4f74035 |
|
586 | 586 | | | |
|
587 | 587 | o | 4 public b-A - f54f1bb90ff3 |
|
588 | 588 | | | |
|
589 | 589 | | o 3 public a-D - b555f63b6063 |
|
590 | 590 | | | |
|
591 | 591 | | o 2 public a-C - 54acac6f23ab |
|
592 | 592 | |/ |
|
593 | 593 | o 1 public a-B - 548a3d25dbf0 |
|
594 | 594 | | |
|
595 | 595 | o 0 public a-A - 054250a37db4 |
|
596 | 596 | |
|
597 | 597 | |
|
598 | 598 | Pushing to Publish=False (common changeset that change phase + unknown one) |
|
599 | 599 | |
|
600 | 600 | $ hg push ../mu -r 967b449fbc94 -f |
|
601 | 601 | pushing to ../mu |
|
602 | 602 | searching for changes |
|
603 | 603 | adding changesets |
|
604 | 604 | adding manifests |
|
605 | 605 | adding file changes |
|
606 | 606 | added 1 changesets with 1 changes to 1 files (+1 heads) |
|
607 | 607 | $ hgph |
|
608 | 608 | @ 10 draft a-H - 967b449fbc94 |
|
609 | 609 | | |
|
610 | 610 | | o 9 draft a-G - 3e27b6f1eee1 |
|
611 | 611 | | | |
|
612 | 612 | | o 8 public a-F - b740e3e5c05d |
|
613 | 613 | | | |
|
614 | 614 | | o 7 public a-E - e9f537e46dea |
|
615 | 615 | | | |
|
616 | 616 | +---o 6 public n-B - 145e75495359 |
|
617 | 617 | | | |
|
618 | 618 | o | 5 public n-A - d6bcb4f74035 |
|
619 | 619 | | | |
|
620 | 620 | o | 4 public b-A - f54f1bb90ff3 |
|
621 | 621 | | | |
|
622 | 622 | | o 3 public a-D - b555f63b6063 |
|
623 | 623 | | | |
|
624 | 624 | | o 2 public a-C - 54acac6f23ab |
|
625 | 625 | |/ |
|
626 | 626 | o 1 public a-B - 548a3d25dbf0 |
|
627 | 627 | | |
|
628 | 628 | o 0 public a-A - 054250a37db4 |
|
629 | 629 | |
|
630 | 630 | $ cd ../mu |
|
631 | 631 | $ hgph # d6bcb4f74035 should have changed phase |
|
632 | 632 | > # 145e75495359 is still draft. not ancestor of -r |
|
633 | 633 | o 9 draft a-H - 967b449fbc94 |
|
634 | 634 | | |
|
635 | 635 | | o 8 public a-F - b740e3e5c05d |
|
636 | 636 | | | |
|
637 | 637 | | o 7 public a-E - e9f537e46dea |
|
638 | 638 | | | |
|
639 | 639 | +---o 6 draft n-B - 145e75495359 |
|
640 | 640 | | | |
|
641 | 641 | o | 5 public n-A - d6bcb4f74035 |
|
642 | 642 | | | |
|
643 | 643 | | o 4 public a-D - b555f63b6063 |
|
644 | 644 | | | |
|
645 | 645 | | o 3 public a-C - 54acac6f23ab |
|
646 | 646 | | | |
|
647 | 647 | o | 2 public b-A - f54f1bb90ff3 |
|
648 | 648 | |/ |
|
649 | 649 | o 1 public a-B - 548a3d25dbf0 |
|
650 | 650 | | |
|
651 | 651 | o 0 public a-A - 054250a37db4 |
|
652 | 652 | |
|
653 | 653 | |
|
654 | 654 | |
|
655 | 655 | Pushing to Publish=True (common changeset from publish=False) |
|
656 | 656 | |
|
657 | 657 | (in mu) |
|
658 | 658 | $ hg push ../alpha |
|
659 | 659 | pushing to ../alpha |
|
660 | 660 | searching for changes |
|
661 | 661 | no changes found |
|
662 | 662 | $ hgph |
|
663 | 663 | o 9 public a-H - 967b449fbc94 |
|
664 | 664 | | |
|
665 | 665 | | o 8 public a-F - b740e3e5c05d |
|
666 | 666 | | | |
|
667 | 667 | | o 7 public a-E - e9f537e46dea |
|
668 | 668 | | | |
|
669 | 669 | +---o 6 public n-B - 145e75495359 |
|
670 | 670 | | | |
|
671 | 671 | o | 5 public n-A - d6bcb4f74035 |
|
672 | 672 | | | |
|
673 | 673 | | o 4 public a-D - b555f63b6063 |
|
674 | 674 | | | |
|
675 | 675 | | o 3 public a-C - 54acac6f23ab |
|
676 | 676 | | | |
|
677 | 677 | o | 2 public b-A - f54f1bb90ff3 |
|
678 | 678 | |/ |
|
679 | 679 | o 1 public a-B - 548a3d25dbf0 |
|
680 | 680 | | |
|
681 | 681 | o 0 public a-A - 054250a37db4 |
|
682 | 682 | |
|
683 | 683 | $ hgph -R ../alpha # a-H should have been synced to 0 |
|
684 | 684 | @ 10 public a-H - 967b449fbc94 |
|
685 | 685 | | |
|
686 | 686 | | o 9 draft a-G - 3e27b6f1eee1 |
|
687 | 687 | | | |
|
688 | 688 | | o 8 public a-F - b740e3e5c05d |
|
689 | 689 | | | |
|
690 | 690 | | o 7 public a-E - e9f537e46dea |
|
691 | 691 | | | |
|
692 | 692 | +---o 6 public n-B - 145e75495359 |
|
693 | 693 | | | |
|
694 | 694 | o | 5 public n-A - d6bcb4f74035 |
|
695 | 695 | | | |
|
696 | 696 | o | 4 public b-A - f54f1bb90ff3 |
|
697 | 697 | | | |
|
698 | 698 | | o 3 public a-D - b555f63b6063 |
|
699 | 699 | | | |
|
700 | 700 | | o 2 public a-C - 54acac6f23ab |
|
701 | 701 | |/ |
|
702 | 702 | o 1 public a-B - 548a3d25dbf0 |
|
703 | 703 | | |
|
704 | 704 | o 0 public a-A - 054250a37db4 |
|
705 | 705 | |
|
706 | 706 | |
|
707 | 707 | |
|
708 | 708 | Discovery locally secret changeset on a remote repository: |
|
709 | 709 | |
|
710 | 710 | - should make it non-secret |
|
711 | 711 | |
|
712 | 712 | $ cd ../alpha |
|
713 | 713 | $ mkcommit A-secret --config phases.new-commit=2 |
|
714 | 714 | $ hgph |
|
715 | 715 | @ 11 secret A-secret - 435b5d83910c |
|
716 | 716 | | |
|
717 | 717 | o 10 public a-H - 967b449fbc94 |
|
718 | 718 | | |
|
719 | 719 | | o 9 draft a-G - 3e27b6f1eee1 |
|
720 | 720 | | | |
|
721 | 721 | | o 8 public a-F - b740e3e5c05d |
|
722 | 722 | | | |
|
723 | 723 | | o 7 public a-E - e9f537e46dea |
|
724 | 724 | | | |
|
725 | 725 | +---o 6 public n-B - 145e75495359 |
|
726 | 726 | | | |
|
727 | 727 | o | 5 public n-A - d6bcb4f74035 |
|
728 | 728 | | | |
|
729 | 729 | o | 4 public b-A - f54f1bb90ff3 |
|
730 | 730 | | | |
|
731 | 731 | | o 3 public a-D - b555f63b6063 |
|
732 | 732 | | | |
|
733 | 733 | | o 2 public a-C - 54acac6f23ab |
|
734 | 734 | |/ |
|
735 | 735 | o 1 public a-B - 548a3d25dbf0 |
|
736 | 736 | | |
|
737 | 737 | o 0 public a-A - 054250a37db4 |
|
738 | 738 | |
|
739 | 739 | $ hg bundle --base 'parents(.)' -r . ../secret-bundle.hg |
|
740 | 740 | 1 changesets found |
|
741 | 741 | $ hg -R ../mu unbundle ../secret-bundle.hg |
|
742 | 742 | adding changesets |
|
743 | 743 | adding manifests |
|
744 | 744 | adding file changes |
|
745 | 745 | added 1 changesets with 1 changes to 1 files |
|
746 | 746 | (run 'hg update' to get a working copy) |
|
747 | 747 | $ hgph -R ../mu |
|
748 | 748 | o 10 draft A-secret - 435b5d83910c |
|
749 | 749 | | |
|
750 | 750 | o 9 public a-H - 967b449fbc94 |
|
751 | 751 | | |
|
752 | 752 | | o 8 public a-F - b740e3e5c05d |
|
753 | 753 | | | |
|
754 | 754 | | o 7 public a-E - e9f537e46dea |
|
755 | 755 | | | |
|
756 | 756 | +---o 6 public n-B - 145e75495359 |
|
757 | 757 | | | |
|
758 | 758 | o | 5 public n-A - d6bcb4f74035 |
|
759 | 759 | | | |
|
760 | 760 | | o 4 public a-D - b555f63b6063 |
|
761 | 761 | | | |
|
762 | 762 | | o 3 public a-C - 54acac6f23ab |
|
763 | 763 | | | |
|
764 | 764 | o | 2 public b-A - f54f1bb90ff3 |
|
765 | 765 | |/ |
|
766 | 766 | o 1 public a-B - 548a3d25dbf0 |
|
767 | 767 | | |
|
768 | 768 | o 0 public a-A - 054250a37db4 |
|
769 | 769 | |
|
770 | 770 | $ hg pull ../mu |
|
771 | 771 | pulling from ../mu |
|
772 | 772 | searching for changes |
|
773 | 773 | no changes found |
|
774 | 774 | $ hgph |
|
775 | 775 | @ 11 draft A-secret - 435b5d83910c |
|
776 | 776 | | |
|
777 | 777 | o 10 public a-H - 967b449fbc94 |
|
778 | 778 | | |
|
779 | 779 | | o 9 draft a-G - 3e27b6f1eee1 |
|
780 | 780 | | | |
|
781 | 781 | | o 8 public a-F - b740e3e5c05d |
|
782 | 782 | | | |
|
783 | 783 | | o 7 public a-E - e9f537e46dea |
|
784 | 784 | | | |
|
785 | 785 | +---o 6 public n-B - 145e75495359 |
|
786 | 786 | | | |
|
787 | 787 | o | 5 public n-A - d6bcb4f74035 |
|
788 | 788 | | | |
|
789 | 789 | o | 4 public b-A - f54f1bb90ff3 |
|
790 | 790 | | | |
|
791 | 791 | | o 3 public a-D - b555f63b6063 |
|
792 | 792 | | | |
|
793 | 793 | | o 2 public a-C - 54acac6f23ab |
|
794 | 794 | |/ |
|
795 | 795 | o 1 public a-B - 548a3d25dbf0 |
|
796 | 796 | | |
|
797 | 797 | o 0 public a-A - 054250a37db4 |
|
798 | 798 | |
|
799 | 799 | |
|
800 | 800 | pushing a locally public and draft changesets remotly secret should make them appear on the remote side |
|
801 | 801 | |
|
802 | 802 | $ hg -R ../mu phase --secret --force 967b449fbc94 |
|
803 | 803 | $ hg push -r 435b5d83910c ../mu |
|
804 | 804 | pushing to ../mu |
|
805 | 805 | searching for changes |
|
806 | 806 | adding changesets |
|
807 | 807 | adding manifests |
|
808 | 808 | adding file changes |
|
809 | 809 | added 0 changesets with 0 changes to 2 files |
|
810 | 810 | $ hgph -R ../mu |
|
811 | 811 | o 10 draft A-secret - 435b5d83910c |
|
812 | 812 | | |
|
813 | 813 | o 9 public a-H - 967b449fbc94 |
|
814 | 814 | | |
|
815 | 815 | | o 8 public a-F - b740e3e5c05d |
|
816 | 816 | | | |
|
817 | 817 | | o 7 public a-E - e9f537e46dea |
|
818 | 818 | | | |
|
819 | 819 | +---o 6 public n-B - 145e75495359 |
|
820 | 820 | | | |
|
821 | 821 | o | 5 public n-A - d6bcb4f74035 |
|
822 | 822 | | | |
|
823 | 823 | | o 4 public a-D - b555f63b6063 |
|
824 | 824 | | | |
|
825 | 825 | | o 3 public a-C - 54acac6f23ab |
|
826 | 826 | | | |
|
827 | 827 | o | 2 public b-A - f54f1bb90ff3 |
|
828 | 828 | |/ |
|
829 | 829 | o 1 public a-B - 548a3d25dbf0 |
|
830 | 830 | | |
|
831 | 831 | o 0 public a-A - 054250a37db4 |
|
832 | 832 | |
|
833 | 833 | |
|
834 | 834 | pull new changeset with common draft locally |
|
835 | 835 | |
|
836 | 836 | $ hg up -q 967b449fbc94 # create a new root for draft |
|
837 | 837 | $ mkcommit 'alpha-more' |
|
838 | 838 | created new head |
|
839 | 839 | $ hg push -fr . ../mu |
|
840 | 840 | pushing to ../mu |
|
841 | 841 | searching for changes |
|
842 | 842 | adding changesets |
|
843 | 843 | adding manifests |
|
844 | 844 | adding file changes |
|
845 | 845 | added 1 changesets with 1 changes to 1 files (+1 heads) |
|
846 | 846 | $ cd ../mu |
|
847 | 847 | $ hg phase --secret --force 1c5cfd894796 |
|
848 | 848 | $ hg up -q 435b5d83910c |
|
849 | 849 | $ mkcommit 'mu-more' |
|
850 | 850 | $ cd ../alpha |
|
851 | 851 | $ hg pull ../mu |
|
852 | 852 | pulling from ../mu |
|
853 | 853 | searching for changes |
|
854 | 854 | adding changesets |
|
855 | 855 | adding manifests |
|
856 | 856 | adding file changes |
|
857 | 857 | added 1 changesets with 1 changes to 1 files |
|
858 | 858 | (run 'hg update' to get a working copy) |
|
859 | 859 | $ hgph |
|
860 | 860 | o 13 draft mu-more - 5237fb433fc8 |
|
861 | 861 | | |
|
862 | 862 | | @ 12 draft alpha-more - 1c5cfd894796 |
|
863 | 863 | | | |
|
864 | 864 | o | 11 draft A-secret - 435b5d83910c |
|
865 | 865 | |/ |
|
866 | 866 | o 10 public a-H - 967b449fbc94 |
|
867 | 867 | | |
|
868 | 868 | | o 9 draft a-G - 3e27b6f1eee1 |
|
869 | 869 | | | |
|
870 | 870 | | o 8 public a-F - b740e3e5c05d |
|
871 | 871 | | | |
|
872 | 872 | | o 7 public a-E - e9f537e46dea |
|
873 | 873 | | | |
|
874 | 874 | +---o 6 public n-B - 145e75495359 |
|
875 | 875 | | | |
|
876 | 876 | o | 5 public n-A - d6bcb4f74035 |
|
877 | 877 | | | |
|
878 | 878 | o | 4 public b-A - f54f1bb90ff3 |
|
879 | 879 | | | |
|
880 | 880 | | o 3 public a-D - b555f63b6063 |
|
881 | 881 | | | |
|
882 | 882 | | o 2 public a-C - 54acac6f23ab |
|
883 | 883 | |/ |
|
884 | 884 | o 1 public a-B - 548a3d25dbf0 |
|
885 | 885 | | |
|
886 | 886 | o 0 public a-A - 054250a37db4 |
|
887 | 887 | |
|
888 | 888 | |
|
889 | 889 | Test that test are properly ignored on remote event when existing locally |
|
890 | 890 | |
|
891 | 891 | $ cd .. |
|
892 | 892 | $ hg clone -qU -r b555f63b6063 -r f54f1bb90ff3 beta gamma |
|
893 | 893 | |
|
894 | 894 | # pathological case are |
|
895 | 895 | # |
|
896 | 896 | # * secret remotely |
|
897 | 897 | # * known locally |
|
898 | 898 | # * repo have uncommon changeset |
|
899 | 899 | |
|
900 | 900 | $ hg -R beta phase --secret --force f54f1bb90ff3 |
|
901 | 901 | $ hg -R gamma phase --draft --force f54f1bb90ff3 |
|
902 | 902 | |
|
903 | 903 | $ cd gamma |
|
904 | 904 | $ hg pull ../beta |
|
905 | 905 | pulling from ../beta |
|
906 | 906 | searching for changes |
|
907 | 907 | adding changesets |
|
908 | 908 | adding manifests |
|
909 | 909 | adding file changes |
|
910 | 910 | added 2 changesets with 2 changes to 2 files |
|
911 | 911 | (run 'hg update' to get a working copy) |
|
912 | 912 | $ hg phase f54f1bb90ff3 |
|
913 | 913 | 2: draft |
|
914 | 914 | |
|
915 | 915 | same over the wire |
|
916 | 916 | |
|
917 | 917 | $ cd ../beta |
|
918 | 918 | $ hg serve -p $HGPORT -d --pid-file=../beta.pid -E ../beta-error.log |
|
919 | 919 | $ cat ../beta.pid >> $DAEMON_PIDS |
|
920 | 920 | $ cd ../gamma |
|
921 | 921 | |
|
922 | 922 | $ hg pull http://localhost:$HGPORT/ |
|
923 | 923 | pulling from http://localhost:$HGPORT/ |
|
924 | 924 | searching for changes |
|
925 | 925 | no changes found |
|
926 | 926 | $ hg phase f54f1bb90ff3 |
|
927 | 927 | 2: draft |
|
928 | 928 | |
|
929 | 929 | check that secret local on both side are not synced to public |
|
930 | 930 | |
|
931 | 931 | $ hg push -r b555f63b6063 http://localhost:$HGPORT/ |
|
932 | 932 | pushing to http://localhost:$HGPORT/ |
|
933 | 933 | searching for changes |
|
934 | 934 | no changes found |
|
935 | 935 | $ hg phase f54f1bb90ff3 |
|
936 | 936 | 2: draft |
|
937 | 937 | |
|
938 | 938 | put the changeset in the draft state again |
|
939 | 939 | (first test after this one expect to be able to copy) |
|
940 | 940 | |
|
941 | 941 | $ cd .. |
|
942 | 942 | |
|
943 | 943 | |
|
944 | 944 | Test Clone behavior |
|
945 | 945 | |
|
946 | 946 | A. Clone without secret changeset |
|
947 | 947 | |
|
948 | 948 | 1. cloning non-publishing repository |
|
949 | 949 | (Phase should be preserved) |
|
950 | 950 | |
|
951 | 951 | # make sure there is no secret so we can use a copy clone |
|
952 | 952 | |
|
953 | 953 | $ hg -R mu phase --draft 'secret()' |
|
954 | 954 | |
|
955 | 955 | $ hg clone -U mu Tau |
|
956 | 956 | $ hgph -R Tau |
|
957 | 957 | o 12 draft mu-more - 5237fb433fc8 |
|
958 | 958 | | |
|
959 | 959 | | o 11 draft alpha-more - 1c5cfd894796 |
|
960 | 960 | | | |
|
961 | 961 | o | 10 draft A-secret - 435b5d83910c |
|
962 | 962 | |/ |
|
963 | 963 | o 9 public a-H - 967b449fbc94 |
|
964 | 964 | | |
|
965 | 965 | | o 8 public a-F - b740e3e5c05d |
|
966 | 966 | | | |
|
967 | 967 | | o 7 public a-E - e9f537e46dea |
|
968 | 968 | | | |
|
969 | 969 | +---o 6 public n-B - 145e75495359 |
|
970 | 970 | | | |
|
971 | 971 | o | 5 public n-A - d6bcb4f74035 |
|
972 | 972 | | | |
|
973 | 973 | | o 4 public a-D - b555f63b6063 |
|
974 | 974 | | | |
|
975 | 975 | | o 3 public a-C - 54acac6f23ab |
|
976 | 976 | | | |
|
977 | 977 | o | 2 public b-A - f54f1bb90ff3 |
|
978 | 978 | |/ |
|
979 | 979 | o 1 public a-B - 548a3d25dbf0 |
|
980 | 980 | | |
|
981 | 981 | o 0 public a-A - 054250a37db4 |
|
982 | 982 | |
|
983 | 983 | |
|
984 | 984 | 2. cloning publishing repository |
|
985 | 985 | |
|
986 | 986 | (everything should be public) |
|
987 | 987 | |
|
988 | 988 | $ hg clone -U alpha Upsilon |
|
989 | 989 | $ hgph -R Upsilon |
|
990 | 990 | o 13 public mu-more - 5237fb433fc8 |
|
991 | 991 | | |
|
992 | 992 | | o 12 public alpha-more - 1c5cfd894796 |
|
993 | 993 | | | |
|
994 | 994 | o | 11 public A-secret - 435b5d83910c |
|
995 | 995 | |/ |
|
996 | 996 | o 10 public a-H - 967b449fbc94 |
|
997 | 997 | | |
|
998 | 998 | | o 9 public a-G - 3e27b6f1eee1 |
|
999 | 999 | | | |
|
1000 | 1000 | | o 8 public a-F - b740e3e5c05d |
|
1001 | 1001 | | | |
|
1002 | 1002 | | o 7 public a-E - e9f537e46dea |
|
1003 | 1003 | | | |
|
1004 | 1004 | +---o 6 public n-B - 145e75495359 |
|
1005 | 1005 | | | |
|
1006 | 1006 | o | 5 public n-A - d6bcb4f74035 |
|
1007 | 1007 | | | |
|
1008 | 1008 | o | 4 public b-A - f54f1bb90ff3 |
|
1009 | 1009 | | | |
|
1010 | 1010 | | o 3 public a-D - b555f63b6063 |
|
1011 | 1011 | | | |
|
1012 | 1012 | | o 2 public a-C - 54acac6f23ab |
|
1013 | 1013 | |/ |
|
1014 | 1014 | o 1 public a-B - 548a3d25dbf0 |
|
1015 | 1015 | | |
|
1016 | 1016 | o 0 public a-A - 054250a37db4 |
|
1017 | 1017 | |
|
1018 | 1018 |
@@ -1,404 +1,404 b'' | |||
|
1 |
$ |
|
|
1 | $ hglog() { hg log --template "{rev} {phaseidx} {desc}\n" $*; } | |
|
2 | 2 | $ mkcommit() { |
|
3 | 3 | > echo "$1" > "$1" |
|
4 | 4 | > hg add "$1" |
|
5 | 5 | > message="$1" |
|
6 | 6 | > shift |
|
7 | 7 | > hg ci -m "$message" $* |
|
8 | 8 | > } |
|
9 | 9 | |
|
10 | 10 | $ hg init initialrepo |
|
11 | 11 | $ cd initialrepo |
|
12 | 12 | $ mkcommit A |
|
13 | 13 | |
|
14 | 14 | New commit are draft by default |
|
15 | 15 | |
|
16 | 16 | $ hglog |
|
17 | 17 | 0 1 A |
|
18 | 18 | |
|
19 | 19 | Following commit are draft too |
|
20 | 20 | |
|
21 | 21 | $ mkcommit B |
|
22 | 22 | |
|
23 | 23 | $ hglog |
|
24 | 24 | 1 1 B |
|
25 | 25 | 0 1 A |
|
26 | 26 | |
|
27 | 27 | Draft commit are properly created over public one: |
|
28 | 28 | |
|
29 | 29 | $ hg phase --public . |
|
30 | 30 | $ hglog |
|
31 | 31 | 1 0 B |
|
32 | 32 | 0 0 A |
|
33 | 33 | |
|
34 | 34 | $ mkcommit C |
|
35 | 35 | $ mkcommit D |
|
36 | 36 | |
|
37 | 37 | $ hglog |
|
38 | 38 | 3 1 D |
|
39 | 39 | 2 1 C |
|
40 | 40 | 1 0 B |
|
41 | 41 | 0 0 A |
|
42 | 42 | |
|
43 | 43 | Test creating changeset as secret |
|
44 | 44 | |
|
45 | 45 | $ mkcommit E --config phases.new-commit=2 |
|
46 | 46 | $ hglog |
|
47 | 47 | 4 2 E |
|
48 | 48 | 3 1 D |
|
49 | 49 | 2 1 C |
|
50 | 50 | 1 0 B |
|
51 | 51 | 0 0 A |
|
52 | 52 | |
|
53 | 53 | Test the secret property is inherited |
|
54 | 54 | |
|
55 | 55 | $ mkcommit H |
|
56 | 56 | $ hglog |
|
57 | 57 | 5 2 H |
|
58 | 58 | 4 2 E |
|
59 | 59 | 3 1 D |
|
60 | 60 | 2 1 C |
|
61 | 61 | 1 0 B |
|
62 | 62 | 0 0 A |
|
63 | 63 | |
|
64 | 64 | Even on merge |
|
65 | 65 | |
|
66 | 66 | $ hg up -q 1 |
|
67 | 67 | $ mkcommit "B'" |
|
68 | 68 | created new head |
|
69 | 69 | $ hglog |
|
70 | 70 | 6 1 B' |
|
71 | 71 | 5 2 H |
|
72 | 72 | 4 2 E |
|
73 | 73 | 3 1 D |
|
74 | 74 | 2 1 C |
|
75 | 75 | 1 0 B |
|
76 | 76 | 0 0 A |
|
77 | 77 | $ hg merge 4 # E |
|
78 | 78 | 3 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
79 | 79 | (branch merge, don't forget to commit) |
|
80 | 80 | $ hg ci -m "merge B' and E" |
|
81 | 81 | $ hglog |
|
82 | 82 | 7 2 merge B' and E |
|
83 | 83 | 6 1 B' |
|
84 | 84 | 5 2 H |
|
85 | 85 | 4 2 E |
|
86 | 86 | 3 1 D |
|
87 | 87 | 2 1 C |
|
88 | 88 | 1 0 B |
|
89 | 89 | 0 0 A |
|
90 | 90 | |
|
91 | 91 | Test secret changeset are not pushed |
|
92 | 92 | |
|
93 | 93 | $ hg init ../push-dest |
|
94 | 94 | $ cat > ../push-dest/.hg/hgrc << EOF |
|
95 | 95 | > [phases] |
|
96 | 96 | > publish=False |
|
97 | 97 | > EOF |
|
98 | 98 | $ hg outgoing ../push-dest --template='{rev} {phase} {desc|firstline}\n' |
|
99 | 99 | comparing with ../push-dest |
|
100 | 100 | searching for changes |
|
101 | 101 | 0 public A |
|
102 | 102 | 1 public B |
|
103 | 103 | 2 draft C |
|
104 | 104 | 3 draft D |
|
105 | 105 | 6 draft B' |
|
106 | 106 | $ hg outgoing -r default ../push-dest --template='{rev} {phase} {desc|firstline}\n' |
|
107 | 107 | comparing with ../push-dest |
|
108 | 108 | searching for changes |
|
109 | 109 | 0 public A |
|
110 | 110 | 1 public B |
|
111 | 111 | 2 draft C |
|
112 | 112 | 3 draft D |
|
113 | 113 | 6 draft B' |
|
114 | 114 | |
|
115 | 115 | $ hg push ../push-dest -f # force because we push multiple heads |
|
116 | 116 | pushing to ../push-dest |
|
117 | 117 | searching for changes |
|
118 | 118 | adding changesets |
|
119 | 119 | adding manifests |
|
120 | 120 | adding file changes |
|
121 | 121 | added 5 changesets with 5 changes to 5 files (+1 heads) |
|
122 | 122 | $ hglog |
|
123 | 123 | 7 2 merge B' and E |
|
124 | 124 | 6 1 B' |
|
125 | 125 | 5 2 H |
|
126 | 126 | 4 2 E |
|
127 | 127 | 3 1 D |
|
128 | 128 | 2 1 C |
|
129 | 129 | 1 0 B |
|
130 | 130 | 0 0 A |
|
131 | 131 | $ cd ../push-dest |
|
132 | 132 | $ hglog |
|
133 | 133 | 4 1 B' |
|
134 | 134 | 3 1 D |
|
135 | 135 | 2 1 C |
|
136 | 136 | 1 0 B |
|
137 | 137 | 0 0 A |
|
138 | 138 | $ cd .. |
|
139 | 139 | |
|
140 | 140 | Test secret changeset are not pull |
|
141 | 141 | |
|
142 | 142 | $ hg init pull-dest |
|
143 | 143 | $ cd pull-dest |
|
144 | 144 | $ hg pull ../initialrepo |
|
145 | 145 | pulling from ../initialrepo |
|
146 | 146 | requesting all changes |
|
147 | 147 | adding changesets |
|
148 | 148 | adding manifests |
|
149 | 149 | adding file changes |
|
150 | 150 | added 5 changesets with 5 changes to 5 files (+1 heads) |
|
151 | 151 | (run 'hg heads' to see heads, 'hg merge' to merge) |
|
152 | 152 | $ hglog |
|
153 | 153 | 4 0 B' |
|
154 | 154 | 3 0 D |
|
155 | 155 | 2 0 C |
|
156 | 156 | 1 0 B |
|
157 | 157 | 0 0 A |
|
158 | 158 | $ cd .. |
|
159 | 159 | |
|
160 | 160 | But secret can still be bundled explicitly |
|
161 | 161 | |
|
162 | 162 | $ cd initialrepo |
|
163 | 163 | $ hg bundle --base '4^' -r 'children(4)' ../secret-bundle.hg |
|
164 | 164 | 4 changesets found |
|
165 | 165 | $ cd .. |
|
166 | 166 | |
|
167 | 167 | Test secret changeset are not cloned |
|
168 | 168 | (during local clone) |
|
169 | 169 | |
|
170 | 170 | $ hg clone -qU initialrepo clone-dest |
|
171 | 171 | $ hglog -R clone-dest |
|
172 | 172 | 4 0 B' |
|
173 | 173 | 3 0 D |
|
174 | 174 | 2 0 C |
|
175 | 175 | 1 0 B |
|
176 | 176 | 0 0 A |
|
177 | 177 | |
|
178 | 178 | Test revset |
|
179 | 179 | |
|
180 | 180 | $ cd initialrepo |
|
181 | 181 | $ hglog -r 'public()' |
|
182 | 182 | 0 0 A |
|
183 | 183 | 1 0 B |
|
184 | 184 | $ hglog -r 'draft()' |
|
185 | 185 | 2 1 C |
|
186 | 186 | 3 1 D |
|
187 | 187 | 6 1 B' |
|
188 | 188 | $ hglog -r 'secret()' |
|
189 | 189 | 4 2 E |
|
190 | 190 | 5 2 H |
|
191 | 191 | 7 2 merge B' and E |
|
192 | 192 | |
|
193 | 193 | test that phase are displayed in log at debug level |
|
194 | 194 | |
|
195 | 195 | $ hg log --debug |
|
196 | 196 | changeset: 7:17a481b3bccb796c0521ae97903d81c52bfee4af |
|
197 | 197 | tag: tip |
|
198 | 198 | phase: secret |
|
199 | 199 | parent: 6:cf9fe039dfd67e829edf6522a45de057b5c86519 |
|
200 | 200 | parent: 4:a603bfb5a83e312131cebcd05353c217d4d21dde |
|
201 | 201 | manifest: 7:5e724ffacba267b2ab726c91fc8b650710deaaa8 |
|
202 | 202 | user: test |
|
203 | 203 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
204 | 204 | files+: C D E |
|
205 | 205 | extra: branch=default |
|
206 | 206 | description: |
|
207 | 207 | merge B' and E |
|
208 | 208 | |
|
209 | 209 | |
|
210 | 210 | changeset: 6:cf9fe039dfd67e829edf6522a45de057b5c86519 |
|
211 | 211 | phase: draft |
|
212 | 212 | parent: 1:27547f69f25460a52fff66ad004e58da7ad3fb56 |
|
213 | 213 | parent: -1:0000000000000000000000000000000000000000 |
|
214 | 214 | manifest: 6:ab8bfef2392903058bf4ebb9e7746e8d7026b27a |
|
215 | 215 | user: test |
|
216 | 216 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
217 | 217 | files+: B' |
|
218 | 218 | extra: branch=default |
|
219 | 219 | description: |
|
220 | 220 | B' |
|
221 | 221 | |
|
222 | 222 | |
|
223 | 223 | changeset: 5:a030c6be5127abc010fcbff1851536552e6951a8 |
|
224 | 224 | phase: secret |
|
225 | 225 | parent: 4:a603bfb5a83e312131cebcd05353c217d4d21dde |
|
226 | 226 | parent: -1:0000000000000000000000000000000000000000 |
|
227 | 227 | manifest: 5:5c710aa854874fe3d5fa7192e77bdb314cc08b5a |
|
228 | 228 | user: test |
|
229 | 229 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
230 | 230 | files+: H |
|
231 | 231 | extra: branch=default |
|
232 | 232 | description: |
|
233 | 233 | H |
|
234 | 234 | |
|
235 | 235 | |
|
236 | 236 | changeset: 4:a603bfb5a83e312131cebcd05353c217d4d21dde |
|
237 | 237 | phase: secret |
|
238 | 238 | parent: 3:b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e |
|
239 | 239 | parent: -1:0000000000000000000000000000000000000000 |
|
240 | 240 | manifest: 4:7173fd1c27119750b959e3a0f47ed78abe75d6dc |
|
241 | 241 | user: test |
|
242 | 242 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
243 | 243 | files+: E |
|
244 | 244 | extra: branch=default |
|
245 | 245 | description: |
|
246 | 246 | E |
|
247 | 247 | |
|
248 | 248 | |
|
249 | 249 | changeset: 3:b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e |
|
250 | 250 | phase: draft |
|
251 | 251 | parent: 2:f838bfaca5c7226600ebcfd84f3c3c13a28d3757 |
|
252 | 252 | parent: -1:0000000000000000000000000000000000000000 |
|
253 | 253 | manifest: 3:6e1f4c47ecb533ffd0c8e52cdc88afb6cd39e20c |
|
254 | 254 | user: test |
|
255 | 255 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
256 | 256 | files+: D |
|
257 | 257 | extra: branch=default |
|
258 | 258 | description: |
|
259 | 259 | D |
|
260 | 260 | |
|
261 | 261 | |
|
262 | 262 | changeset: 2:f838bfaca5c7226600ebcfd84f3c3c13a28d3757 |
|
263 | 263 | phase: draft |
|
264 | 264 | parent: 1:27547f69f25460a52fff66ad004e58da7ad3fb56 |
|
265 | 265 | parent: -1:0000000000000000000000000000000000000000 |
|
266 | 266 | manifest: 2:66a5a01817fdf5239c273802b5b7618d051c89e4 |
|
267 | 267 | user: test |
|
268 | 268 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
269 | 269 | files+: C |
|
270 | 270 | extra: branch=default |
|
271 | 271 | description: |
|
272 | 272 | C |
|
273 | 273 | |
|
274 | 274 | |
|
275 | 275 | changeset: 1:27547f69f25460a52fff66ad004e58da7ad3fb56 |
|
276 | 276 | parent: 0:4a2df7238c3b48766b5e22fafbb8a2f506ec8256 |
|
277 | 277 | parent: -1:0000000000000000000000000000000000000000 |
|
278 | 278 | manifest: 1:cb5cbbc1bfbf24cc34b9e8c16914e9caa2d2a7fd |
|
279 | 279 | user: test |
|
280 | 280 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
281 | 281 | files+: B |
|
282 | 282 | extra: branch=default |
|
283 | 283 | description: |
|
284 | 284 | B |
|
285 | 285 | |
|
286 | 286 | |
|
287 | 287 | changeset: 0:4a2df7238c3b48766b5e22fafbb8a2f506ec8256 |
|
288 | 288 | parent: -1:0000000000000000000000000000000000000000 |
|
289 | 289 | parent: -1:0000000000000000000000000000000000000000 |
|
290 | 290 | manifest: 0:007d8c9d88841325f5c6b06371b35b4e8a2b1a83 |
|
291 | 291 | user: test |
|
292 | 292 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
293 | 293 | files+: A |
|
294 | 294 | extra: branch=default |
|
295 | 295 | description: |
|
296 | 296 | A |
|
297 | 297 | |
|
298 | 298 | |
|
299 | 299 | |
|
300 | 300 | Test phase command |
|
301 | 301 | =================== |
|
302 | 302 | |
|
303 | 303 | initial picture |
|
304 | 304 | |
|
305 | 305 | $ cat >> $HGRCPATH << EOF |
|
306 | 306 | > [extensions] |
|
307 | 307 | > hgext.graphlog= |
|
308 | 308 | > EOF |
|
309 | 309 | $ hg log -G --template "{rev} {phase} {desc}\n" |
|
310 | 310 | @ 7 secret merge B' and E |
|
311 | 311 | |\ |
|
312 | 312 | | o 6 draft B' |
|
313 | 313 | | | |
|
314 | 314 | +---o 5 secret H |
|
315 | 315 | | | |
|
316 | 316 | o | 4 secret E |
|
317 | 317 | | | |
|
318 | 318 | o | 3 draft D |
|
319 | 319 | | | |
|
320 | 320 | o | 2 draft C |
|
321 | 321 | |/ |
|
322 | 322 | o 1 public B |
|
323 | 323 | | |
|
324 | 324 | o 0 public A |
|
325 | 325 | |
|
326 | 326 | |
|
327 | 327 | display changesets phase |
|
328 | 328 | |
|
329 | 329 | (mixing -r and plain rev specification) |
|
330 | 330 | |
|
331 | 331 | $ hg phase 1::4 -r 7 |
|
332 | 332 | 1: public |
|
333 | 333 | 2: draft |
|
334 | 334 | 3: draft |
|
335 | 335 | 4: secret |
|
336 | 336 | 7: secret |
|
337 | 337 | |
|
338 | 338 | |
|
339 | 339 | move changeset forward |
|
340 | 340 | |
|
341 | 341 | (with -r option) |
|
342 | 342 | |
|
343 | 343 | $ hg phase --public -r 2 |
|
344 | 344 | $ hg log -G --template "{rev} {phase} {desc}\n" |
|
345 | 345 | @ 7 secret merge B' and E |
|
346 | 346 | |\ |
|
347 | 347 | | o 6 draft B' |
|
348 | 348 | | | |
|
349 | 349 | +---o 5 secret H |
|
350 | 350 | | | |
|
351 | 351 | o | 4 secret E |
|
352 | 352 | | | |
|
353 | 353 | o | 3 draft D |
|
354 | 354 | | | |
|
355 | 355 | o | 2 public C |
|
356 | 356 | |/ |
|
357 | 357 | o 1 public B |
|
358 | 358 | | |
|
359 | 359 | o 0 public A |
|
360 | 360 | |
|
361 | 361 | |
|
362 | 362 | move changeset backward |
|
363 | 363 | |
|
364 | 364 | (without -r option) |
|
365 | 365 | |
|
366 | 366 | $ hg phase --draft --force 2 |
|
367 | 367 | $ hg log -G --template "{rev} {phase} {desc}\n" |
|
368 | 368 | @ 7 secret merge B' and E |
|
369 | 369 | |\ |
|
370 | 370 | | o 6 draft B' |
|
371 | 371 | | | |
|
372 | 372 | +---o 5 secret H |
|
373 | 373 | | | |
|
374 | 374 | o | 4 secret E |
|
375 | 375 | | | |
|
376 | 376 | o | 3 draft D |
|
377 | 377 | | | |
|
378 | 378 | o | 2 draft C |
|
379 | 379 | |/ |
|
380 | 380 | o 1 public B |
|
381 | 381 | | |
|
382 | 382 | o 0 public A |
|
383 | 383 | |
|
384 | 384 | |
|
385 | 385 | move changeset forward and backward |
|
386 | 386 | |
|
387 | 387 | $ hg phase --draft --force 1::4 |
|
388 | 388 | $ hg log -G --template "{rev} {phase} {desc}\n" |
|
389 | 389 | @ 7 secret merge B' and E |
|
390 | 390 | |\ |
|
391 | 391 | | o 6 draft B' |
|
392 | 392 | | | |
|
393 | 393 | +---o 5 secret H |
|
394 | 394 | | | |
|
395 | 395 | o | 4 draft E |
|
396 | 396 | | | |
|
397 | 397 | o | 3 draft D |
|
398 | 398 | | | |
|
399 | 399 | o | 2 draft C |
|
400 | 400 | |/ |
|
401 | 401 | o 1 draft B |
|
402 | 402 | | |
|
403 | 403 | o 0 public A |
|
404 | 404 |
General Comments 0
You need to be logged in to leave comments.
Login now