##// END OF EJS Templates
tests: remove sed -i from test-record
Matt Mackall -
r16332:42e95631 default
parent child Browse files
Show More
@@ -1,432 +1,433 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 (r'sed.*-i', "don't use 'sed -i', use a temporary file"),
50 51 (r'echo.*\\n', "don't use 'echo \\n', use printf"),
51 52 (r'echo -n', "don't use 'echo -n', use printf"),
52 53 (r'^diff.*-\w*N', "don't use 'diff -N'"),
53 54 (r'(^| )wc[^|]*$\n(?!.*\(re\))', "filter wc output"),
54 55 (r'head -c', "don't use 'head -c', use 'dd'"),
55 56 (r'sha1sum', "don't use sha1sum, use $TESTDIR/md5sum.py"),
56 57 (r'ls.*-\w*R', "don't use 'ls -R', use 'find'"),
57 58 (r'printf.*\\\d{1,3}', "don't use 'printf \NNN', use Python"),
58 59 (r'printf.*\\x', "don't use printf \\x, use Python"),
59 60 (r'\$\(.*\)', "don't use $(expr), use `expr`"),
60 61 (r'rm -rf \*', "don't use naked rm -rf, target a directory"),
61 62 (r'(^|\|\s*)grep (-\w\s+)*[^|]*[(|]\w',
62 63 "use egrep for extended grep syntax"),
63 64 (r'/bin/', "don't use explicit paths for tools"),
64 65 (r'\$PWD', "don't use $PWD, use `pwd`"),
65 66 (r'[^\n]\Z', "no trailing newline"),
66 67 (r'export.*=', "don't export and assign at once"),
67 68 (r'^([^"\'\n]|("[^"\n]*")|(\'[^\'\n]*\'))*\\^', "^ must be quoted"),
68 69 (r'^source\b', "don't use 'source', use '.'"),
69 70 (r'touch -d', "don't use 'touch -d', use 'touch -t' instead"),
70 71 (r'ls +[^|\n-]+ +-', "options to 'ls' must come before filenames"),
71 72 (r'[^>\n]>\s*\$HGRCPATH', "don't overwrite $HGRCPATH, append to it"),
72 73 (r'^stop\(\)', "don't use 'stop' as a shell function name"),
73 74 (r'(\[|\btest\b).*-e ', "don't use 'test -e', use 'test -f'"),
74 75 (r'^alias\b.*=', "don't use alias, use a function"),
75 76 ],
76 77 # warnings
77 78 []
78 79 ]
79 80
80 81 testfilters = [
81 82 (r"( *)(#([^\n]*\S)?)", repcomment),
82 83 (r"<<(\S+)((.|\n)*?\n\1)", rephere),
83 84 ]
84 85
85 86 uprefix = r"^ \$ "
86 87 uprefixc = r"^ > "
87 88 utestpats = [
88 89 [
89 90 (r'^(\S| $ ).*(\S[ \t]+|^[ \t]+)\n', "trailing whitespace on non-output"),
90 91 (uprefix + r'.*\|\s*sed', "use regex test output patterns instead of sed"),
91 92 (uprefix + r'(true|exit 0)', "explicit zero exit unnecessary"),
92 93 (uprefix + r'.*(?<!\[)\$\?', "explicit exit code checks unnecessary"),
93 94 (uprefix + r'.*\|\| echo.*(fail|error)',
94 95 "explicit exit code checks unnecessary"),
95 96 (uprefix + r'set -e', "don't use set -e"),
96 97 (uprefixc + r'( *)\t', "don't use tabs to indent"),
97 98 ],
98 99 # warnings
99 100 []
100 101 ]
101 102
102 103 for i in [0, 1]:
103 104 for p, m in testpats[i]:
104 105 if p.startswith(r'^'):
105 106 p = uprefix + p[1:]
106 107 else:
107 108 p = uprefix + ".*" + p
108 109 utestpats[i].append((p, m))
109 110
110 111 utestfilters = [
111 112 (r"( *)(#([^\n]*\S)?)", repcomment),
112 113 ]
113 114
114 115 pypats = [
115 116 [
116 117 (r'^\s*def\s*\w+\s*\(.*,\s*\(',
117 118 "tuple parameter unpacking not available in Python 3+"),
118 119 (r'lambda\s*\(.*,.*\)',
119 120 "tuple parameter unpacking not available in Python 3+"),
120 121 (r'(?<!def)\s+(cmp)\(', "cmp is not available in Python 3+"),
121 122 (r'\breduce\s*\(.*', "reduce is not available in Python 3+"),
122 123 (r'\.has_key\b', "dict.has_key is not available in Python 3+"),
123 124 (r'^\s*\t', "don't use tabs"),
124 125 (r'\S;\s*\n', "semicolon"),
125 126 (r'[^_]_\("[^"]+"\s*%', "don't use % inside _()"),
126 127 (r"[^_]_\('[^']+'\s*%", "don't use % inside _()"),
127 128 (r'\w,\w', "missing whitespace after ,"),
128 129 (r'\w[+/*\-<>]\w', "missing whitespace in expression"),
129 130 (r'^\s+\w+=\w+[^,)\n]$', "missing whitespace in assignment"),
130 131 (r'(\s+)try:\n((?:\n|\1\s.*\n)+?)\1except.*?:\n'
131 132 r'((?:\n|\1\s.*\n)+?)\1finally:', 'no try/except/finally in Py2.4'),
132 133 (r'.{85}', "line too long"),
133 134 (r' x+[xo][\'"]\n\s+[\'"]x', 'string join across lines with no space'),
134 135 (r'[^\n]\Z', "no trailing newline"),
135 136 (r'(\S[ \t]+|^[ \t]+)\n', "trailing whitespace"),
136 137 # (r'^\s+[^_ \n][^_. \n]+_[^_\n]+\s*=', "don't use underbars in identifiers"),
137 138 (r'^\s+(self\.)?[A-za-z][a-z0-9]+[A-Z]\w* = ',
138 139 "don't use camelcase in identifiers"),
139 140 (r'^\s*(if|while|def|class|except|try)\s[^[\n]*:\s*[^\\n]#\s]+',
140 141 "linebreak after :"),
141 142 (r'class\s[^( \n]+:', "old-style class, use class foo(object)"),
142 143 (r'class\s[^( \n]+\(\):',
143 144 "class foo() not available in Python 2.4, use class foo(object)"),
144 145 (r'\b(%s)\(' % '|'.join(keyword.kwlist),
145 146 "Python keyword is not a function"),
146 147 (r',]', "unneeded trailing ',' in list"),
147 148 # (r'class\s[A-Z][^\(]*\((?!Exception)',
148 149 # "don't capitalize non-exception classes"),
149 150 # (r'in range\(', "use xrange"),
150 151 # (r'^\s*print\s+', "avoid using print in core and extensions"),
151 152 (r'[\x80-\xff]', "non-ASCII character literal"),
152 153 (r'("\')\.format\(', "str.format() not available in Python 2.4"),
153 154 (r'^\s*with\s+', "with not available in Python 2.4"),
154 155 (r'\.isdisjoint\(', "set.isdisjoint not available in Python 2.4"),
155 156 (r'^\s*except.* as .*:', "except as not available in Python 2.4"),
156 157 (r'^\s*os\.path\.relpath', "relpath not available in Python 2.4"),
157 158 (r'(?<!def)\s+(any|all|format)\(',
158 159 "any/all/format not available in Python 2.4"),
159 160 (r'(?<!def)\s+(callable)\(',
160 161 "callable not available in Python 3, use getattr(f, '__call__', None)"),
161 162 (r'if\s.*\selse', "if ... else form not available in Python 2.4"),
162 163 (r'^\s*(%s)\s\s' % '|'.join(keyword.kwlist),
163 164 "gratuitous whitespace after Python keyword"),
164 165 (r'([\(\[][ \t]\S)|(\S[ \t][\)\]])', "gratuitous whitespace in () or []"),
165 166 # (r'\s\s=', "gratuitous whitespace before ="),
166 167 (r'[^>< ](\+=|-=|!=|<>|<=|>=|<<=|>>=)\S',
167 168 "missing whitespace around operator"),
168 169 (r'[^>< ](\+=|-=|!=|<>|<=|>=|<<=|>>=)\s',
169 170 "missing whitespace around operator"),
170 171 (r'\s(\+=|-=|!=|<>|<=|>=|<<=|>>=)\S',
171 172 "missing whitespace around operator"),
172 173 (r'[^^+=*/!<>&| -](\s=|=\s)[^= ]',
173 174 "wrong whitespace around ="),
174 175 (r'raise Exception', "don't raise generic exceptions"),
175 176 (r' is\s+(not\s+)?["\'0-9-]', "object comparison with literal"),
176 177 (r' [=!]=\s+(True|False|None)',
177 178 "comparison with singleton, use 'is' or 'is not' instead"),
178 179 (r'^\s*(while|if) [01]:',
179 180 "use True/False for constant Boolean expression"),
180 181 (r'(?<!def)\s+hasattr',
181 182 'hasattr(foo, bar) is broken, use util.safehasattr(foo, bar) instead'),
182 183 (r'opener\([^)]*\).read\(',
183 184 "use opener.read() instead"),
184 185 (r'BaseException', 'not in Py2.4, use Exception'),
185 186 (r'os\.path\.relpath', 'os.path.relpath is not in Py2.5'),
186 187 (r'opener\([^)]*\).write\(',
187 188 "use opener.write() instead"),
188 189 (r'[\s\(](open|file)\([^)]*\)\.read\(',
189 190 "use util.readfile() instead"),
190 191 (r'[\s\(](open|file)\([^)]*\)\.write\(',
191 192 "use util.readfile() instead"),
192 193 (r'^[\s\(]*(open(er)?|file)\([^)]*\)',
193 194 "always assign an opened file to a variable, and close it afterwards"),
194 195 (r'[\s\(](open|file)\([^)]*\)\.',
195 196 "always assign an opened file to a variable, and close it afterwards"),
196 197 (r'(?i)descendent', "the proper spelling is descendAnt"),
197 198 (r'\.debug\(\_', "don't mark debug messages for translation"),
198 199 ],
199 200 # warnings
200 201 [
201 202 (r'.{81}', "warning: line over 80 characters"),
202 203 (r'^\s*except:$', "warning: naked except clause"),
203 204 (r'ui\.(status|progress|write|note|warn)\([\'\"]x',
204 205 "warning: unwrapped ui message"),
205 206 ]
206 207 ]
207 208
208 209 pyfilters = [
209 210 (r"""(?msx)(?P<comment>\#.*?$)|
210 211 ((?P<quote>('''|\"\"\"|(?<!')'(?!')|(?<!")"(?!")))
211 212 (?P<text>(([^\\]|\\.)*?))
212 213 (?P=quote))""", reppython),
213 214 ]
214 215
215 216 cpats = [
216 217 [
217 218 (r'//', "don't use //-style comments"),
218 219 (r'^ ', "don't use spaces to indent"),
219 220 (r'\S\t', "don't use tabs except for indent"),
220 221 (r'(\S[ \t]+|^[ \t]+)\n', "trailing whitespace"),
221 222 (r'.{85}', "line too long"),
222 223 (r'(while|if|do|for)\(', "use space after while/if/do/for"),
223 224 (r'return\(', "return is not a function"),
224 225 (r' ;', "no space before ;"),
225 226 (r'\w+\* \w+', "use int *foo, not int* foo"),
226 227 (r'\([^\)]+\) \w+', "use (int)foo, not (int) foo"),
227 228 (r'\S+ (\+\+|--)', "use foo++, not foo ++"),
228 229 (r'\w,\w', "missing whitespace after ,"),
229 230 (r'^[^#]\w[+/*]\w', "missing whitespace in expression"),
230 231 (r'^#\s+\w', "use #foo, not # foo"),
231 232 (r'[^\n]\Z', "no trailing newline"),
232 233 (r'^\s*#import\b', "use only #include in standard C code"),
233 234 ],
234 235 # warnings
235 236 []
236 237 ]
237 238
238 239 cfilters = [
239 240 (r'(/\*)(((\*(?!/))|[^*])*)\*/', repccomment),
240 241 (r'''(?P<quote>(?<!")")(?P<text>([^"]|\\")+)"(?!")''', repquote),
241 242 (r'''(#\s*include\s+<)([^>]+)>''', repinclude),
242 243 (r'(\()([^)]+\))', repcallspaces),
243 244 ]
244 245
245 246 inutilpats = [
246 247 [
247 248 (r'\bui\.', "don't use ui in util"),
248 249 ],
249 250 # warnings
250 251 []
251 252 ]
252 253
253 254 inrevlogpats = [
254 255 [
255 256 (r'\brepo\.', "don't use repo in revlog"),
256 257 ],
257 258 # warnings
258 259 []
259 260 ]
260 261
261 262 checks = [
262 263 ('python', r'.*\.(py|cgi)$', pyfilters, pypats),
263 264 ('test script', r'(.*/)?test-[^.~]*$', testfilters, testpats),
264 265 ('c', r'.*\.c$', cfilters, cpats),
265 266 ('unified test', r'.*\.t$', utestfilters, utestpats),
266 267 ('layering violation repo in revlog', r'mercurial/revlog\.py', pyfilters,
267 268 inrevlogpats),
268 269 ('layering violation ui in util', r'mercurial/util\.py', pyfilters,
269 270 inutilpats),
270 271 ]
271 272
272 273 class norepeatlogger(object):
273 274 def __init__(self):
274 275 self._lastseen = None
275 276
276 277 def log(self, fname, lineno, line, msg, blame):
277 278 """print error related a to given line of a given file.
278 279
279 280 The faulty line will also be printed but only once in the case
280 281 of multiple errors.
281 282
282 283 :fname: filename
283 284 :lineno: line number
284 285 :line: actual content of the line
285 286 :msg: error message
286 287 """
287 288 msgid = fname, lineno, line
288 289 if msgid != self._lastseen:
289 290 if blame:
290 291 print "%s:%d (%s):" % (fname, lineno, blame)
291 292 else:
292 293 print "%s:%d:" % (fname, lineno)
293 294 print " > %s" % line
294 295 self._lastseen = msgid
295 296 print " " + msg
296 297
297 298 _defaultlogger = norepeatlogger()
298 299
299 300 def getblame(f):
300 301 lines = []
301 302 for l in os.popen('hg annotate -un %s' % f):
302 303 start, line = l.split(':', 1)
303 304 user, rev = start.split()
304 305 lines.append((line[1:-1], user, rev))
305 306 return lines
306 307
307 308 def checkfile(f, logfunc=_defaultlogger.log, maxerr=None, warnings=False,
308 309 blame=False, debug=False, lineno=True):
309 310 """checks style and portability of a given file
310 311
311 312 :f: filepath
312 313 :logfunc: function used to report error
313 314 logfunc(filename, linenumber, linecontent, errormessage)
314 315 :maxerr: number of error to display before arborting.
315 316 Set to false (default) to report all errors
316 317
317 318 return True if no error is found, False otherwise.
318 319 """
319 320 blamecache = None
320 321 result = True
321 322 for name, match, filters, pats in checks:
322 323 if debug:
323 324 print name, f
324 325 fc = 0
325 326 if not re.match(match, f):
326 327 if debug:
327 328 print "Skipping %s for %s it doesn't match %s" % (
328 329 name, match, f)
329 330 continue
330 331 fp = open(f)
331 332 pre = post = fp.read()
332 333 fp.close()
333 334 if "no-" + "check-code" in pre:
334 335 if debug:
335 336 print "Skipping %s for %s it has no- and check-code" % (
336 337 name, f)
337 338 break
338 339 for p, r in filters:
339 340 post = re.sub(p, r, post)
340 341 if warnings:
341 342 pats = pats[0] + pats[1]
342 343 else:
343 344 pats = pats[0]
344 345 # print post # uncomment to show filtered version
345 346
346 347 if debug:
347 348 print "Checking %s for %s" % (name, f)
348 349
349 350 prelines = None
350 351 errors = []
351 352 for p, msg in pats:
352 353 # fix-up regexes for multiline searches
353 354 po = p
354 355 # \s doesn't match \n
355 356 p = re.sub(r'(?<!\\)\\s', r'[ \\t]', p)
356 357 # [^...] doesn't match newline
357 358 p = re.sub(r'(?<!\\)\[\^', r'[^\\n', p)
358 359
359 360 #print po, '=>', p
360 361
361 362 pos = 0
362 363 n = 0
363 364 for m in re.finditer(p, post, re.MULTILINE):
364 365 if prelines is None:
365 366 prelines = pre.splitlines()
366 367 postlines = post.splitlines(True)
367 368
368 369 start = m.start()
369 370 while n < len(postlines):
370 371 step = len(postlines[n])
371 372 if pos + step > start:
372 373 break
373 374 pos += step
374 375 n += 1
375 376 l = prelines[n]
376 377
377 378 if "check-code" + "-ignore" in l:
378 379 if debug:
379 380 print "Skipping %s for %s:%s (check-code -ignore)" % (
380 381 name, f, n)
381 382 continue
382 383 bd = ""
383 384 if blame:
384 385 bd = 'working directory'
385 386 if not blamecache:
386 387 blamecache = getblame(f)
387 388 if n < len(blamecache):
388 389 bl, bu, br = blamecache[n]
389 390 if bl == l:
390 391 bd = '%s@%s' % (bu, br)
391 392 errors.append((f, lineno and n + 1, l, msg, bd))
392 393 result = False
393 394
394 395 errors.sort()
395 396 for e in errors:
396 397 logfunc(*e)
397 398 fc += 1
398 399 if maxerr and fc >= maxerr:
399 400 print " (too many errors, giving up)"
400 401 break
401 402
402 403 return result
403 404
404 405 if __name__ == "__main__":
405 406 parser = optparse.OptionParser("%prog [options] [files]")
406 407 parser.add_option("-w", "--warnings", action="store_true",
407 408 help="include warning-level checks")
408 409 parser.add_option("-p", "--per-file", type="int",
409 410 help="max warnings per file")
410 411 parser.add_option("-b", "--blame", action="store_true",
411 412 help="use annotate to generate blame info")
412 413 parser.add_option("", "--debug", action="store_true",
413 414 help="show debug information")
414 415 parser.add_option("", "--nolineno", action="store_false",
415 416 dest='lineno', help="don't show line numbers")
416 417
417 418 parser.set_defaults(per_file=15, warnings=False, blame=False, debug=False,
418 419 lineno=True)
419 420 (options, args) = parser.parse_args()
420 421
421 422 if len(args) == 0:
422 423 check = glob.glob("*")
423 424 else:
424 425 check = args
425 426
426 427 ret = 0
427 428 for f in check:
428 429 if not checkfile(f, maxerr=options.per_file, warnings=options.warnings,
429 430 blame=options.blame, debug=options.debug,
430 431 lineno=options.lineno):
431 432 ret = 1
432 433 sys.exit(ret)
@@ -1,1108 +1,1112 b''
1 1 $ "$TESTDIR/hghave" execbit || exit 80
2 2
3 3 Set up a repo
4 4
5 5 $ echo "[ui]" >> $HGRCPATH
6 6 $ echo "interactive=true" >> $HGRCPATH
7 7 $ echo "[extensions]" >> $HGRCPATH
8 8 $ echo "record=" >> $HGRCPATH
9 9
10 10 $ hg init a
11 11 $ cd a
12 12
13 13 Select no files
14 14
15 15 $ touch empty-rw
16 16 $ hg add empty-rw
17 17
18 18 $ hg record empty-rw<<EOF
19 19 > n
20 20 > EOF
21 21 diff --git a/empty-rw b/empty-rw
22 22 new file mode 100644
23 23 examine changes to 'empty-rw'? [Ynesfdaq?]
24 24 no changes to record
25 25
26 26 $ hg tip -p
27 27 changeset: -1:000000000000
28 28 tag: tip
29 29 user:
30 30 date: Thu Jan 01 00:00:00 1970 +0000
31 31
32 32
33 33
34 34 Select files but no hunks
35 35
36 36 $ hg record empty-rw<<EOF
37 37 > y
38 38 > n
39 39 > EOF
40 40 diff --git a/empty-rw b/empty-rw
41 41 new file mode 100644
42 42 examine changes to 'empty-rw'? [Ynesfdaq?]
43 43 abort: empty commit message
44 44 [255]
45 45
46 46 $ hg tip -p
47 47 changeset: -1:000000000000
48 48 tag: tip
49 49 user:
50 50 date: Thu Jan 01 00:00:00 1970 +0000
51 51
52 52
53 53
54 54 Record empty file
55 55
56 56 $ hg record -d '0 0' -m empty empty-rw<<EOF
57 57 > y
58 58 > y
59 59 > EOF
60 60 diff --git a/empty-rw b/empty-rw
61 61 new file mode 100644
62 62 examine changes to 'empty-rw'? [Ynesfdaq?]
63 63
64 64 $ hg tip -p
65 65 changeset: 0:c0708cf4e46e
66 66 tag: tip
67 67 user: test
68 68 date: Thu Jan 01 00:00:00 1970 +0000
69 69 summary: empty
70 70
71 71
72 72
73 73 Summary shows we updated to the new cset
74 74
75 75 $ hg summary
76 76 parent: 0:c0708cf4e46e tip
77 77 empty
78 78 branch: default
79 79 commit: (clean)
80 80 update: (current)
81 81
82 82 Rename empty file
83 83
84 84 $ hg mv empty-rw empty-rename
85 85 $ hg record -d '1 0' -m rename<<EOF
86 86 > y
87 87 > EOF
88 88 diff --git a/empty-rw b/empty-rename
89 89 rename from empty-rw
90 90 rename to empty-rename
91 91 examine changes to 'empty-rw' and 'empty-rename'? [Ynesfdaq?]
92 92
93 93 $ hg tip -p
94 94 changeset: 1:d695e8dcb197
95 95 tag: tip
96 96 user: test
97 97 date: Thu Jan 01 00:00:01 1970 +0000
98 98 summary: rename
99 99
100 100
101 101
102 102 Copy empty file
103 103
104 104 $ hg cp empty-rename empty-copy
105 105 $ hg record -d '2 0' -m copy<<EOF
106 106 > y
107 107 > EOF
108 108 diff --git a/empty-rename b/empty-copy
109 109 copy from empty-rename
110 110 copy to empty-copy
111 111 examine changes to 'empty-rename' and 'empty-copy'? [Ynesfdaq?]
112 112
113 113 $ hg tip -p
114 114 changeset: 2:1d4b90bea524
115 115 tag: tip
116 116 user: test
117 117 date: Thu Jan 01 00:00:02 1970 +0000
118 118 summary: copy
119 119
120 120
121 121
122 122 Delete empty file
123 123
124 124 $ hg rm empty-copy
125 125 $ hg record -d '3 0' -m delete<<EOF
126 126 > y
127 127 > EOF
128 128 diff --git a/empty-copy b/empty-copy
129 129 deleted file mode 100644
130 130 examine changes to 'empty-copy'? [Ynesfdaq?]
131 131
132 132 $ hg tip -p
133 133 changeset: 3:b39a238f01a1
134 134 tag: tip
135 135 user: test
136 136 date: Thu Jan 01 00:00:03 1970 +0000
137 137 summary: delete
138 138
139 139
140 140
141 141 Add binary file
142 142
143 143 $ hg bundle --base -2 tip.bundle
144 144 1 changesets found
145 145 $ hg add tip.bundle
146 146 $ hg record -d '4 0' -m binary<<EOF
147 147 > y
148 148 > EOF
149 149 diff --git a/tip.bundle b/tip.bundle
150 150 new file mode 100644
151 151 this is a binary file
152 152 examine changes to 'tip.bundle'? [Ynesfdaq?]
153 153
154 154 $ hg tip -p
155 155 changeset: 4:ad816da3711e
156 156 tag: tip
157 157 user: test
158 158 date: Thu Jan 01 00:00:04 1970 +0000
159 159 summary: binary
160 160
161 161 diff -r b39a238f01a1 -r ad816da3711e tip.bundle
162 162 Binary file tip.bundle has changed
163 163
164 164
165 165 Change binary file
166 166
167 167 $ hg bundle --base -2 tip.bundle
168 168 1 changesets found
169 169 $ hg record -d '5 0' -m binary-change<<EOF
170 170 > y
171 171 > EOF
172 172 diff --git a/tip.bundle b/tip.bundle
173 173 this modifies a binary file (all or nothing)
174 174 examine changes to 'tip.bundle'? [Ynesfdaq?]
175 175
176 176 $ hg tip -p
177 177 changeset: 5:dccd6f3eb485
178 178 tag: tip
179 179 user: test
180 180 date: Thu Jan 01 00:00:05 1970 +0000
181 181 summary: binary-change
182 182
183 183 diff -r ad816da3711e -r dccd6f3eb485 tip.bundle
184 184 Binary file tip.bundle has changed
185 185
186 186
187 187 Rename and change binary file
188 188
189 189 $ hg mv tip.bundle top.bundle
190 190 $ hg bundle --base -2 top.bundle
191 191 1 changesets found
192 192 $ hg record -d '6 0' -m binary-change-rename<<EOF
193 193 > y
194 194 > EOF
195 195 diff --git a/tip.bundle b/top.bundle
196 196 rename from tip.bundle
197 197 rename to top.bundle
198 198 this modifies a binary file (all or nothing)
199 199 examine changes to 'tip.bundle' and 'top.bundle'? [Ynesfdaq?]
200 200
201 201 $ hg tip -p
202 202 changeset: 6:7fa44105f5b3
203 203 tag: tip
204 204 user: test
205 205 date: Thu Jan 01 00:00:06 1970 +0000
206 206 summary: binary-change-rename
207 207
208 208 diff -r dccd6f3eb485 -r 7fa44105f5b3 tip.bundle
209 209 Binary file tip.bundle has changed
210 210 diff -r dccd6f3eb485 -r 7fa44105f5b3 top.bundle
211 211 Binary file top.bundle has changed
212 212
213 213
214 214 Add plain file
215 215
216 216 $ for i in 1 2 3 4 5 6 7 8 9 10; do
217 217 > echo $i >> plain
218 218 > done
219 219
220 220 $ hg add plain
221 221 $ hg record -d '7 0' -m plain plain<<EOF
222 222 > y
223 223 > y
224 224 > EOF
225 225 diff --git a/plain b/plain
226 226 new file mode 100644
227 227 examine changes to 'plain'? [Ynesfdaq?]
228 228
229 229 $ hg tip -p
230 230 changeset: 7:11fb457c1be4
231 231 tag: tip
232 232 user: test
233 233 date: Thu Jan 01 00:00:07 1970 +0000
234 234 summary: plain
235 235
236 236 diff -r 7fa44105f5b3 -r 11fb457c1be4 plain
237 237 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
238 238 +++ b/plain Thu Jan 01 00:00:07 1970 +0000
239 239 @@ -0,0 +1,10 @@
240 240 +1
241 241 +2
242 242 +3
243 243 +4
244 244 +5
245 245 +6
246 246 +7
247 247 +8
248 248 +9
249 249 +10
250 250
251 251
252 252 Modify end of plain file
253 253
254 254 $ echo 11 >> plain
255 255 $ hg record -d '8 0' -m end plain <<EOF
256 256 > y
257 257 > y
258 258 > EOF
259 259 diff --git a/plain b/plain
260 260 1 hunks, 1 lines changed
261 261 examine changes to 'plain'? [Ynesfdaq?]
262 262 @@ -8,3 +8,4 @@
263 263 8
264 264 9
265 265 10
266 266 +11
267 267 record this change to 'plain'? [Ynesfdaq?]
268 268
269 269 Modify end of plain file, no EOL
270 270
271 271 $ hg tip --template '{node}' >> plain
272 272 $ hg record -d '9 0' -m noeol plain <<EOF
273 273 > y
274 274 > y
275 275 > EOF
276 276 diff --git a/plain b/plain
277 277 1 hunks, 1 lines changed
278 278 examine changes to 'plain'? [Ynesfdaq?]
279 279 @@ -9,3 +9,4 @@
280 280 9
281 281 10
282 282 11
283 283 +7264f99c5f5ff3261504828afa4fb4d406c3af54
284 284 \ No newline at end of file
285 285 record this change to 'plain'? [Ynesfdaq?]
286 286
287 287 Modify end of plain file, add EOL
288 288
289 289 $ echo >> plain
290 290 $ echo 1 > plain2
291 291 $ hg add plain2
292 292 $ hg record -d '10 0' -m eol plain plain2 <<EOF
293 293 > y
294 294 > y
295 295 > y
296 296 > EOF
297 297 diff --git a/plain b/plain
298 298 1 hunks, 1 lines changed
299 299 examine changes to 'plain'? [Ynesfdaq?]
300 300 @@ -9,4 +9,4 @@
301 301 9
302 302 10
303 303 11
304 304 -7264f99c5f5ff3261504828afa4fb4d406c3af54
305 305 \ No newline at end of file
306 306 +7264f99c5f5ff3261504828afa4fb4d406c3af54
307 307 record change 1/2 to 'plain'? [Ynesfdaq?]
308 308 diff --git a/plain2 b/plain2
309 309 new file mode 100644
310 310 examine changes to 'plain2'? [Ynesfdaq?]
311 311
312 312 Modify beginning, trim end, record both, add another file to test
313 313 changes numbering
314 314
315 315 $ rm plain
316 316 $ for i in 2 2 3 4 5 6 7 8 9 10; do
317 317 > echo $i >> plain
318 318 > done
319 319 $ echo 2 >> plain2
320 320
321 321 $ hg record -d '10 0' -m begin-and-end plain plain2 <<EOF
322 322 > y
323 323 > y
324 324 > y
325 325 > y
326 326 > y
327 327 > EOF
328 328 diff --git a/plain b/plain
329 329 2 hunks, 3 lines changed
330 330 examine changes to 'plain'? [Ynesfdaq?]
331 331 @@ -1,4 +1,4 @@
332 332 -1
333 333 +2
334 334 2
335 335 3
336 336 4
337 337 record change 1/3 to 'plain'? [Ynesfdaq?]
338 338 @@ -8,5 +8,3 @@
339 339 8
340 340 9
341 341 10
342 342 -11
343 343 -7264f99c5f5ff3261504828afa4fb4d406c3af54
344 344 record change 2/3 to 'plain'? [Ynesfdaq?]
345 345 diff --git a/plain2 b/plain2
346 346 1 hunks, 1 lines changed
347 347 examine changes to 'plain2'? [Ynesfdaq?]
348 348 @@ -1,1 +1,2 @@
349 349 1
350 350 +2
351 351 record change 3/3 to 'plain2'? [Ynesfdaq?]
352 352
353 353 $ hg tip -p
354 354 changeset: 11:21df83db12b8
355 355 tag: tip
356 356 user: test
357 357 date: Thu Jan 01 00:00:10 1970 +0000
358 358 summary: begin-and-end
359 359
360 360 diff -r ddb8b281c3ff -r 21df83db12b8 plain
361 361 --- a/plain Thu Jan 01 00:00:10 1970 +0000
362 362 +++ b/plain Thu Jan 01 00:00:10 1970 +0000
363 363 @@ -1,4 +1,4 @@
364 364 -1
365 365 +2
366 366 2
367 367 3
368 368 4
369 369 @@ -8,5 +8,3 @@
370 370 8
371 371 9
372 372 10
373 373 -11
374 374 -7264f99c5f5ff3261504828afa4fb4d406c3af54
375 375 diff -r ddb8b281c3ff -r 21df83db12b8 plain2
376 376 --- a/plain2 Thu Jan 01 00:00:10 1970 +0000
377 377 +++ b/plain2 Thu Jan 01 00:00:10 1970 +0000
378 378 @@ -1,1 +1,2 @@
379 379 1
380 380 +2
381 381
382 382
383 383 Trim beginning, modify end
384 384
385 385 $ rm plain
386 386 > for i in 4 5 6 7 8 9 10.new; do
387 387 > echo $i >> plain
388 388 > done
389 389
390 390 Record end
391 391
392 392 $ hg record -d '11 0' -m end-only plain <<EOF
393 393 > y
394 394 > n
395 395 > y
396 396 > EOF
397 397 diff --git a/plain b/plain
398 398 2 hunks, 4 lines changed
399 399 examine changes to 'plain'? [Ynesfdaq?]
400 400 @@ -1,9 +1,6 @@
401 401 -2
402 402 -2
403 403 -3
404 404 4
405 405 5
406 406 6
407 407 7
408 408 8
409 409 9
410 410 record change 1/2 to 'plain'? [Ynesfdaq?]
411 411 @@ -4,7 +1,7 @@
412 412 4
413 413 5
414 414 6
415 415 7
416 416 8
417 417 9
418 418 -10
419 419 +10.new
420 420 record change 2/2 to 'plain'? [Ynesfdaq?]
421 421
422 422 $ hg tip -p
423 423 changeset: 12:99337501826f
424 424 tag: tip
425 425 user: test
426 426 date: Thu Jan 01 00:00:11 1970 +0000
427 427 summary: end-only
428 428
429 429 diff -r 21df83db12b8 -r 99337501826f plain
430 430 --- a/plain Thu Jan 01 00:00:10 1970 +0000
431 431 +++ b/plain Thu Jan 01 00:00:11 1970 +0000
432 432 @@ -7,4 +7,4 @@
433 433 7
434 434 8
435 435 9
436 436 -10
437 437 +10.new
438 438
439 439
440 440 Record beginning
441 441
442 442 $ hg record -d '12 0' -m begin-only plain <<EOF
443 443 > y
444 444 > y
445 445 > EOF
446 446 diff --git a/plain b/plain
447 447 1 hunks, 3 lines changed
448 448 examine changes to 'plain'? [Ynesfdaq?]
449 449 @@ -1,6 +1,3 @@
450 450 -2
451 451 -2
452 452 -3
453 453 4
454 454 5
455 455 6
456 456 record this change to 'plain'? [Ynesfdaq?]
457 457
458 458 $ hg tip -p
459 459 changeset: 13:bbd45465d540
460 460 tag: tip
461 461 user: test
462 462 date: Thu Jan 01 00:00:12 1970 +0000
463 463 summary: begin-only
464 464
465 465 diff -r 99337501826f -r bbd45465d540 plain
466 466 --- a/plain Thu Jan 01 00:00:11 1970 +0000
467 467 +++ b/plain Thu Jan 01 00:00:12 1970 +0000
468 468 @@ -1,6 +1,3 @@
469 469 -2
470 470 -2
471 471 -3
472 472 4
473 473 5
474 474 6
475 475
476 476
477 477 Add to beginning, trim from end
478 478
479 479 $ rm plain
480 480 $ for i in 1 2 3 4 5 6 7 8 9; do
481 481 > echo $i >> plain
482 482 > done
483 483
484 484 Record end
485 485
486 486 $ hg record --traceback -d '13 0' -m end-again plain<<EOF
487 487 > y
488 488 > n
489 489 > y
490 490 > EOF
491 491 diff --git a/plain b/plain
492 492 2 hunks, 4 lines changed
493 493 examine changes to 'plain'? [Ynesfdaq?]
494 494 @@ -1,6 +1,9 @@
495 495 +1
496 496 +2
497 497 +3
498 498 4
499 499 5
500 500 6
501 501 7
502 502 8
503 503 9
504 504 record change 1/2 to 'plain'? [Ynesfdaq?]
505 505 @@ -1,7 +4,6 @@
506 506 4
507 507 5
508 508 6
509 509 7
510 510 8
511 511 9
512 512 -10.new
513 513 record change 2/2 to 'plain'? [Ynesfdaq?]
514 514
515 515 Add to beginning, middle, end
516 516
517 517 $ rm plain
518 518 $ for i in 1 2 3 4 5 5.new 5.reallynew 6 7 8 9 10 11; do
519 519 > echo $i >> plain
520 520 > done
521 521
522 522 Record beginning, middle
523 523
524 524 $ hg record -d '14 0' -m middle-only plain <<EOF
525 525 > y
526 526 > y
527 527 > y
528 528 > n
529 529 > EOF
530 530 diff --git a/plain b/plain
531 531 3 hunks, 7 lines changed
532 532 examine changes to 'plain'? [Ynesfdaq?]
533 533 @@ -1,2 +1,5 @@
534 534 +1
535 535 +2
536 536 +3
537 537 4
538 538 5
539 539 record change 1/3 to 'plain'? [Ynesfdaq?]
540 540 @@ -1,6 +4,8 @@
541 541 4
542 542 5
543 543 +5.new
544 544 +5.reallynew
545 545 6
546 546 7
547 547 8
548 548 9
549 549 record change 2/3 to 'plain'? [Ynesfdaq?]
550 550 @@ -3,4 +8,6 @@
551 551 6
552 552 7
553 553 8
554 554 9
555 555 +10
556 556 +11
557 557 record change 3/3 to 'plain'? [Ynesfdaq?]
558 558
559 559 $ hg tip -p
560 560 changeset: 15:f34a7937ec33
561 561 tag: tip
562 562 user: test
563 563 date: Thu Jan 01 00:00:14 1970 +0000
564 564 summary: middle-only
565 565
566 566 diff -r 82c065d0b850 -r f34a7937ec33 plain
567 567 --- a/plain Thu Jan 01 00:00:13 1970 +0000
568 568 +++ b/plain Thu Jan 01 00:00:14 1970 +0000
569 569 @@ -1,5 +1,10 @@
570 570 +1
571 571 +2
572 572 +3
573 573 4
574 574 5
575 575 +5.new
576 576 +5.reallynew
577 577 6
578 578 7
579 579 8
580 580
581 581
582 582 Record end
583 583
584 584 $ hg record -d '15 0' -m end-only plain <<EOF
585 585 > y
586 586 > y
587 587 > EOF
588 588 diff --git a/plain b/plain
589 589 1 hunks, 2 lines changed
590 590 examine changes to 'plain'? [Ynesfdaq?]
591 591 @@ -9,3 +9,5 @@
592 592 7
593 593 8
594 594 9
595 595 +10
596 596 +11
597 597 record this change to 'plain'? [Ynesfdaq?]
598 598
599 599 $ hg tip -p
600 600 changeset: 16:f9900b71a04c
601 601 tag: tip
602 602 user: test
603 603 date: Thu Jan 01 00:00:15 1970 +0000
604 604 summary: end-only
605 605
606 606 diff -r f34a7937ec33 -r f9900b71a04c plain
607 607 --- a/plain Thu Jan 01 00:00:14 1970 +0000
608 608 +++ b/plain Thu Jan 01 00:00:15 1970 +0000
609 609 @@ -9,3 +9,5 @@
610 610 7
611 611 8
612 612 9
613 613 +10
614 614 +11
615 615
616 616
617 617 $ mkdir subdir
618 618 $ cd subdir
619 619 $ echo a > a
620 620 $ hg ci -d '16 0' -Amsubdir
621 621 adding subdir/a
622 622
623 623 $ echo a >> a
624 624 $ hg record -d '16 0' -m subdir-change a <<EOF
625 625 > y
626 626 > y
627 627 > EOF
628 628 diff --git a/subdir/a b/subdir/a
629 629 1 hunks, 1 lines changed
630 630 examine changes to 'subdir/a'? [Ynesfdaq?]
631 631 @@ -1,1 +1,2 @@
632 632 a
633 633 +a
634 634 record this change to 'subdir/a'? [Ynesfdaq?]
635 635
636 636 $ hg tip -p
637 637 changeset: 18:61be427a9deb
638 638 tag: tip
639 639 user: test
640 640 date: Thu Jan 01 00:00:16 1970 +0000
641 641 summary: subdir-change
642 642
643 643 diff -r a7ffae4d61cb -r 61be427a9deb subdir/a
644 644 --- a/subdir/a Thu Jan 01 00:00:16 1970 +0000
645 645 +++ b/subdir/a Thu Jan 01 00:00:16 1970 +0000
646 646 @@ -1,1 +1,2 @@
647 647 a
648 648 +a
649 649
650 650
651 651 $ echo a > f1
652 652 $ echo b > f2
653 653 $ hg add f1 f2
654 654
655 655 $ hg ci -mz -d '17 0'
656 656
657 657 $ echo a >> f1
658 658 $ echo b >> f2
659 659
660 660 Help, quit
661 661
662 662 $ hg record <<EOF
663 663 > ?
664 664 > q
665 665 > EOF
666 666 diff --git a/subdir/f1 b/subdir/f1
667 667 1 hunks, 1 lines changed
668 668 examine changes to 'subdir/f1'? [Ynesfdaq?]
669 669 y - record this change
670 670 n - skip this change
671 671 e - edit this change manually
672 672 s - skip remaining changes to this file
673 673 f - record remaining changes to this file
674 674 d - done, skip remaining changes and files
675 675 a - record all changes to all remaining files
676 676 q - quit, recording no changes
677 677 ? - display help
678 678 examine changes to 'subdir/f1'? [Ynesfdaq?]
679 679 abort: user quit
680 680 [255]
681 681
682 682 Skip
683 683
684 684 $ hg record <<EOF
685 685 > s
686 686 > EOF
687 687 diff --git a/subdir/f1 b/subdir/f1
688 688 1 hunks, 1 lines changed
689 689 examine changes to 'subdir/f1'? [Ynesfdaq?]
690 690 diff --git a/subdir/f2 b/subdir/f2
691 691 1 hunks, 1 lines changed
692 692 examine changes to 'subdir/f2'? [Ynesfdaq?] abort: response expected
693 693 [255]
694 694
695 695 No
696 696
697 697 $ hg record <<EOF
698 698 > n
699 699 > EOF
700 700 diff --git a/subdir/f1 b/subdir/f1
701 701 1 hunks, 1 lines changed
702 702 examine changes to 'subdir/f1'? [Ynesfdaq?]
703 703 diff --git a/subdir/f2 b/subdir/f2
704 704 1 hunks, 1 lines changed
705 705 examine changes to 'subdir/f2'? [Ynesfdaq?] abort: response expected
706 706 [255]
707 707
708 708 f, quit
709 709
710 710 $ hg record <<EOF
711 711 > f
712 712 > q
713 713 > EOF
714 714 diff --git a/subdir/f1 b/subdir/f1
715 715 1 hunks, 1 lines changed
716 716 examine changes to 'subdir/f1'? [Ynesfdaq?]
717 717 diff --git a/subdir/f2 b/subdir/f2
718 718 1 hunks, 1 lines changed
719 719 examine changes to 'subdir/f2'? [Ynesfdaq?]
720 720 abort: user quit
721 721 [255]
722 722
723 723 s, all
724 724
725 725 $ hg record -d '18 0' -mx <<EOF
726 726 > s
727 727 > a
728 728 > EOF
729 729 diff --git a/subdir/f1 b/subdir/f1
730 730 1 hunks, 1 lines changed
731 731 examine changes to 'subdir/f1'? [Ynesfdaq?]
732 732 diff --git a/subdir/f2 b/subdir/f2
733 733 1 hunks, 1 lines changed
734 734 examine changes to 'subdir/f2'? [Ynesfdaq?]
735 735
736 736 $ hg tip -p
737 737 changeset: 20:b3df3dda369a
738 738 tag: tip
739 739 user: test
740 740 date: Thu Jan 01 00:00:18 1970 +0000
741 741 summary: x
742 742
743 743 diff -r 6e02d6c9906d -r b3df3dda369a subdir/f2
744 744 --- a/subdir/f2 Thu Jan 01 00:00:17 1970 +0000
745 745 +++ b/subdir/f2 Thu Jan 01 00:00:18 1970 +0000
746 746 @@ -1,1 +1,2 @@
747 747 b
748 748 +b
749 749
750 750
751 751 f
752 752
753 753 $ hg record -d '19 0' -my <<EOF
754 754 > f
755 755 > EOF
756 756 diff --git a/subdir/f1 b/subdir/f1
757 757 1 hunks, 1 lines changed
758 758 examine changes to 'subdir/f1'? [Ynesfdaq?]
759 759
760 760 $ hg tip -p
761 761 changeset: 21:38ec577f126b
762 762 tag: tip
763 763 user: test
764 764 date: Thu Jan 01 00:00:19 1970 +0000
765 765 summary: y
766 766
767 767 diff -r b3df3dda369a -r 38ec577f126b subdir/f1
768 768 --- a/subdir/f1 Thu Jan 01 00:00:18 1970 +0000
769 769 +++ b/subdir/f1 Thu Jan 01 00:00:19 1970 +0000
770 770 @@ -1,1 +1,2 @@
771 771 a
772 772 +a
773 773
774 774
775 775 Preserve chmod +x
776 776
777 777 $ chmod +x f1
778 778 $ echo a >> f1
779 779 $ hg record -d '20 0' -mz <<EOF
780 780 > y
781 781 > y
782 782 > y
783 783 > EOF
784 784 diff --git a/subdir/f1 b/subdir/f1
785 785 old mode 100644
786 786 new mode 100755
787 787 1 hunks, 1 lines changed
788 788 examine changes to 'subdir/f1'? [Ynesfdaq?]
789 789 @@ -1,2 +1,3 @@
790 790 a
791 791 a
792 792 +a
793 793 record this change to 'subdir/f1'? [Ynesfdaq?]
794 794
795 795 $ hg tip --config diff.git=True -p
796 796 changeset: 22:3261adceb075
797 797 tag: tip
798 798 user: test
799 799 date: Thu Jan 01 00:00:20 1970 +0000
800 800 summary: z
801 801
802 802 diff --git a/subdir/f1 b/subdir/f1
803 803 old mode 100644
804 804 new mode 100755
805 805 --- a/subdir/f1
806 806 +++ b/subdir/f1
807 807 @@ -1,2 +1,3 @@
808 808 a
809 809 a
810 810 +a
811 811
812 812
813 813 Preserve execute permission on original
814 814
815 815 $ echo b >> f1
816 816 $ hg record -d '21 0' -maa <<EOF
817 817 > y
818 818 > y
819 819 > y
820 820 > EOF
821 821 diff --git a/subdir/f1 b/subdir/f1
822 822 1 hunks, 1 lines changed
823 823 examine changes to 'subdir/f1'? [Ynesfdaq?]
824 824 @@ -1,3 +1,4 @@
825 825 a
826 826 a
827 827 a
828 828 +b
829 829 record this change to 'subdir/f1'? [Ynesfdaq?]
830 830
831 831 $ hg tip --config diff.git=True -p
832 832 changeset: 23:b429867550db
833 833 tag: tip
834 834 user: test
835 835 date: Thu Jan 01 00:00:21 1970 +0000
836 836 summary: aa
837 837
838 838 diff --git a/subdir/f1 b/subdir/f1
839 839 --- a/subdir/f1
840 840 +++ b/subdir/f1
841 841 @@ -1,3 +1,4 @@
842 842 a
843 843 a
844 844 a
845 845 +b
846 846
847 847
848 848 Preserve chmod -x
849 849
850 850 $ chmod -x f1
851 851 $ echo c >> f1
852 852 $ hg record -d '22 0' -mab <<EOF
853 853 > y
854 854 > y
855 855 > y
856 856 > EOF
857 857 diff --git a/subdir/f1 b/subdir/f1
858 858 old mode 100755
859 859 new mode 100644
860 860 1 hunks, 1 lines changed
861 861 examine changes to 'subdir/f1'? [Ynesfdaq?]
862 862 @@ -2,3 +2,4 @@
863 863 a
864 864 a
865 865 b
866 866 +c
867 867 record this change to 'subdir/f1'? [Ynesfdaq?]
868 868
869 869 $ hg tip --config diff.git=True -p
870 870 changeset: 24:0b082130c20a
871 871 tag: tip
872 872 user: test
873 873 date: Thu Jan 01 00:00:22 1970 +0000
874 874 summary: ab
875 875
876 876 diff --git a/subdir/f1 b/subdir/f1
877 877 old mode 100755
878 878 new mode 100644
879 879 --- a/subdir/f1
880 880 +++ b/subdir/f1
881 881 @@ -2,3 +2,4 @@
882 882 a
883 883 a
884 884 b
885 885 +c
886 886
887 887
888 888 $ cd ..
889 889
890 890 Abort early when a merge is in progress
891 891
892 892 $ hg up 4
893 893 1 files updated, 0 files merged, 6 files removed, 0 files unresolved
894 894
895 895 $ touch iwillmergethat
896 896 $ hg add iwillmergethat
897 897
898 898 $ hg branch thatbranch
899 899 marked working directory as branch thatbranch
900 900 (branches are permanent and global, did you want a bookmark?)
901 901
902 902 $ hg ci -m'new head'
903 903
904 904 $ hg up default
905 905 6 files updated, 0 files merged, 2 files removed, 0 files unresolved
906 906
907 907 $ hg merge thatbranch
908 908 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
909 909 (branch merge, don't forget to commit)
910 910
911 911 $ hg record -m'will abort'
912 912 abort: cannot partially commit a merge (use "hg commit" instead)
913 913 [255]
914 914
915 915 $ hg up -C
916 916 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
917 917
918 918 Editing patch
919 919
920 920 $ cat > editor << '__EOF__'
921 921 > #!/bin/sh
922 > sed -i.bak -e 7d -e '5s/^-/ /' "$1"
922 > sed -e 7d -e '5s/^-/ /' "$1" > tmp
923 > mv tmp "$1"
923 924 > __EOF__
924 925 $ chmod +x editor
925 926 $ cat > editedfile << '__EOF__'
926 927 > This is the first line
927 928 > This is the second line
928 929 > This is the third line
929 930 > __EOF__
930 931 $ hg add editedfile
931 932 $ hg commit -medit-patch-1
932 933 $ cat > editedfile << '__EOF__'
933 934 > This line has changed
934 935 > This change will be committed
935 936 > This is the third line
936 937 > __EOF__
937 938 $ HGEDITOR="'`pwd`'"/editor hg record -d '23 0' -medit-patch-2 <<EOF
938 939 > y
939 940 > e
940 941 > EOF
941 942 diff --git a/editedfile b/editedfile
942 943 1 hunks, 2 lines changed
943 944 examine changes to 'editedfile'? [Ynesfdaq?]
944 945 @@ -1,3 +1,3 @@
945 946 -This is the first line
946 947 -This is the second line
947 948 +This line has changed
948 949 +This change will be committed
949 950 This is the third line
950 951 record this change to 'editedfile'? [Ynesfdaq?]
951 952 $ cat editedfile
952 953 This line has changed
953 954 This change will be committed
954 955 This is the third line
955 956 $ hg cat -r tip editedfile
956 957 This is the first line
957 958 This change will be committed
958 959 This is the third line
959 960 $ hg revert editedfile
960 961
961 962 Trying to edit patch for whole file
962 963
963 964 $ echo "This is the fourth line" >> editedfile
964 965 $ hg record <<EOF
965 966 > e
966 967 > q
967 968 > EOF
968 969 diff --git a/editedfile b/editedfile
969 970 1 hunks, 1 lines changed
970 971 examine changes to 'editedfile'? [Ynesfdaq?]
971 972 cannot edit patch for whole file
972 973 examine changes to 'editedfile'? [Ynesfdaq?]
973 974 abort: user quit
974 975 [255]
975 976 $ hg revert editedfile
976 977
977 978 Removing changes from patch
978 979
979 980 $ sed -i -e '3s/third/second/' -e '2s/will/will not/' -e 1d editedfile
980 981 $ echo "This line has been added" >> editedfile
981 982 $ cat > editor << '__EOF__'
982 983 > #!/bin/sh
983 > sed -i -e 's/^[-+]/ /' "$1"
984 > sed -e 's/^[-+]/ /' "$1" > tmp
985 > mv tmp "$1"
984 986 > __EOF__
985 987 $ chmod +x editor
986 988 $ HGEDITOR="'`pwd`'"/editor hg record <<EOF
987 989 > y
988 990 > e
989 991 > EOF
990 992 diff --git a/editedfile b/editedfile
991 993 1 hunks, 3 lines changed
992 994 examine changes to 'editedfile'? [Ynesfdaq?]
993 995 @@ -1,3 +1,3 @@
994 996 -This is the first line
995 997 -This change will be committed
996 998 -This is the third line
997 999 +This change will not be committed
998 1000 +This is the second line
999 1001 +This line has been added
1000 1002 record this change to 'editedfile'? [Ynesfdaq?]
1001 1003 no changes to record
1002 1004 $ cat editedfile
1003 1005 This change will not be committed
1004 1006 This is the second line
1005 1007 This line has been added
1006 1008 $ hg cat -r tip editedfile
1007 1009 This is the first line
1008 1010 This change will be committed
1009 1011 This is the third line
1010 1012 $ hg revert editedfile
1011 1013
1012 1014 Invalid patch
1013 1015
1014 $ sed -i -e '3s/third/second/' -e '2s/will/will not/' -e 1d editedfile
1016 $ sed -e '3s/third/second/' -e '2s/will/will not/' -e 1d editedfile > tmp
1017 $ mv tmp editedfile
1015 1018 $ echo "This line has been added" >> editedfile
1016 1019 $ cat > editor << '__EOF__'
1017 1020 > #!/bin/sh
1018 > sed -i s/This/That/ "$1"
1021 > sed s/This/That/ "$1" > tmp
1022 > mv tmp "$1"
1019 1023 > __EOF__
1020 1024 $ chmod +x editor
1021 1025 $ HGEDITOR="'`pwd`'"/editor hg record <<EOF
1022 1026 > y
1023 1027 > e
1024 1028 > EOF
1025 1029 diff --git a/editedfile b/editedfile
1026 1030 1 hunks, 3 lines changed
1027 1031 examine changes to 'editedfile'? [Ynesfdaq?]
1028 1032 @@ -1,3 +1,3 @@
1029 1033 -This is the first line
1030 1034 -This change will be committed
1031 1035 -This is the third line
1032 1036 +This change will not be committed
1033 1037 +This is the second line
1034 1038 +This line has been added
1035 1039 record this change to 'editedfile'? [Ynesfdaq?]
1036 1040 patching file editedfile
1037 1041 Hunk #1 FAILED at 0
1038 1042 1 out of 1 hunks FAILED -- saving rejects to file editedfile.rej
1039 1043 abort: patch failed to apply
1040 1044 [255]
1041 1045 $ cat editedfile
1042 1046 This change will not be committed
1043 1047 This is the second line
1044 1048 This line has been added
1045 1049 $ hg cat -r tip editedfile
1046 1050 This is the first line
1047 1051 This change will be committed
1048 1052 This is the third line
1049 1053 $ cat editedfile.rej
1050 1054 --- editedfile
1051 1055 +++ editedfile
1052 1056 @@ -1,3 +1,3 @@
1053 1057 -That is the first line
1054 1058 -That change will be committed
1055 1059 -That is the third line
1056 1060 +That change will not be committed
1057 1061 +That is the second line
1058 1062 +That line has been added
1059 1063 $ hg up -C
1060 1064 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1061 1065
1062 1066 With win32text
1063 1067
1064 1068 $ echo '[extensions]' >> .hg/hgrc
1065 1069 $ echo 'win32text = ' >> .hg/hgrc
1066 1070 $ echo '[decode]' >> .hg/hgrc
1067 1071 $ echo '** = cleverdecode:' >> .hg/hgrc
1068 1072 $ echo '[encode]' >> .hg/hgrc
1069 1073 $ echo '** = cleverencode:' >> .hg/hgrc
1070 1074 $ echo '[patch]' >> .hg/hgrc
1071 1075 $ echo 'eol = crlf' >> .hg/hgrc
1072 1076
1073 1077 Ignore win32text deprecation warning for now:
1074 1078
1075 1079 $ echo '[win32text]' >> .hg/hgrc
1076 1080 $ echo 'warn = no' >> .hg/hgrc
1077 1081
1078 1082 $ echo d >> subdir/f1
1079 1083 $ hg record -d '24 0' -mw1 <<EOF
1080 1084 > y
1081 1085 > y
1082 1086 > EOF
1083 1087 diff --git a/subdir/f1 b/subdir/f1
1084 1088 1 hunks, 1 lines changed
1085 1089 examine changes to 'subdir/f1'? [Ynesfdaq?]
1086 1090 @@ -3,3 +3,4 @@
1087 1091 a
1088 1092 b
1089 1093 c
1090 1094 +d
1091 1095 record this change to 'subdir/f1'? [Ynesfdaq?]
1092 1096
1093 1097 $ hg tip -p
1094 1098 changeset: 28:287ad1f41a72
1095 1099 tag: tip
1096 1100 user: test
1097 1101 date: Thu Jan 01 00:00:24 1970 +0000
1098 1102 summary: w1
1099 1103
1100 1104 diff -r 65ce23a81197 -r 287ad1f41a72 subdir/f1
1101 1105 --- a/subdir/f1 Thu Jan 01 00:00:23 1970 +0000
1102 1106 +++ b/subdir/f1 Thu Jan 01 00:00:24 1970 +0000
1103 1107 @@ -3,3 +3,4 @@
1104 1108 a
1105 1109 b
1106 1110 c
1107 1111 +d
1108 1112
General Comments 0
You need to be logged in to leave comments. Login now