##// END OF EJS Templates
tests: drop a bunch of sed calls from unified tests
Matt Mackall -
r12366:c01dc908 default
parent child Browse files
Show More
@@ -1,290 +1,291 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 optparse
12 12
13 13 def repquote(m):
14 14 t = re.sub(r"\w", "x", m.group('text'))
15 15 t = re.sub(r"[^\sx]", "o", t)
16 16 return m.group('quote') + t + m.group('quote')
17 17
18 18 def reppython(m):
19 19 comment = m.group('comment')
20 20 if comment:
21 21 return "#" * len(comment)
22 22 return repquote(m)
23 23
24 24 def repcomment(m):
25 25 return m.group(1) + "#" * len(m.group(2))
26 26
27 27 def repccomment(m):
28 28 t = re.sub(r"((?<=\n) )|\S", "x", m.group(2))
29 29 return m.group(1) + t + "*/"
30 30
31 31 def repcallspaces(m):
32 32 t = re.sub(r"\n\s+", "\n", m.group(2))
33 33 return m.group(1) + t
34 34
35 35 def repinclude(m):
36 36 return m.group(1) + "<foo>"
37 37
38 38 def rephere(m):
39 39 t = re.sub(r"\S", "x", m.group(2))
40 40 return m.group(1) + t
41 41
42 42
43 43 testpats = [
44 44 (r'(pushd|popd)', "don't use 'pushd' or 'popd', use 'cd'"),
45 45 (r'\W\$?\(\([^\)]*\)\)', "don't use (()) or $(()), use 'expr'"),
46 46 (r'^function', "don't use 'function', use old style"),
47 47 (r'grep.*-q', "don't use 'grep -q', redirect to /dev/null"),
48 48 (r'echo.*\\n', "don't use 'echo \\n', use printf"),
49 49 (r'echo -n', "don't use 'echo -n', use printf"),
50 50 (r'^diff.*-\w*N', "don't use 'diff -N'"),
51 51 (r'(^| )wc[^|]*$', "filter wc output"),
52 52 (r'head -c', "don't use 'head -c', use 'dd'"),
53 53 (r'ls.*-\w*R', "don't use 'ls -R', use 'find'"),
54 54 (r'printf.*\\\d\d\d', "don't use 'printf \NNN', use Python"),
55 55 (r'printf.*\\x', "don't use printf \\x, use Python"),
56 56 (r'\$\(.*\)', "don't use $(expr), use `expr`"),
57 57 (r'rm -rf \*', "don't use naked rm -rf, target a directory"),
58 58 (r'(^|\|\s*)grep (-\w\s+)*[^|]*[(|]\w',
59 59 "use egrep for extended grep syntax"),
60 60 (r'/bin/', "don't use explicit paths for tools"),
61 61 (r'\$PWD', "don't use $PWD, use `pwd`"),
62 62 (r'[^\n]\Z', "no trailing newline"),
63 63 (r'export.*=', "don't export and assign at once"),
64 64 ('^([^"\']|("[^"]*")|(\'[^\']*\'))*\\^', "^ must be quoted"),
65 65 (r'^source\b', "don't use 'source', use '.'"),
66 66 ]
67 67
68 68 testfilters = [
69 69 (r"( *)(#([^\n]*\S)?)", repcomment),
70 70 (r"<<(\S+)((.|\n)*?\n\1)", rephere),
71 71 ]
72 72
73 73 uprefix = r"^ \$ "
74 74 utestpats = [
75 (uprefix + r'.*\|\s*sed', "use regex test output patterns instead of sed"),
75 76 (uprefix + r'(true|exit 0)', "explicit zero exit unnecessary"),
76 77 (uprefix + r'.*\$\?', "explicit exit code checks unnecessary"),
77 78 (uprefix + r'.*\|\| echo.*(fail|error)',
78 79 "explicit exit code checks unnecessary"),
79 80 (uprefix + r'set -e', "don't use set -e"),
80 81 ]
81 82
82 83 for p, m in testpats:
83 84 if p.startswith('^'):
84 85 p = uprefix + p[1:]
85 86 else:
86 87 p = uprefix + p
87 88 utestpats.append((p, m))
88 89
89 90 utestfilters = [
90 91 (r"( *)(#([^\n]*\S)?)", repcomment),
91 92 ]
92 93
93 94 pypats = [
94 95 (r'^\s*def\s*\w+\s*\(.*,\s*\(',
95 96 "tuple parameter unpacking not available in Python 3+"),
96 97 (r'lambda\s*\(.*,.*\)',
97 98 "tuple parameter unpacking not available in Python 3+"),
98 99 (r'(?<!def)\s+(cmp)\(', "cmp is not available in Python 3+"),
99 100 (r'\breduce\s*\(.*', "reduce is not available in Python 3+"),
100 101 (r'\.has_key\b', "dict.has_key is not available in Python 3+"),
101 102 (r'^\s*\t', "don't use tabs"),
102 103 (r'\S;\s*\n', "semicolon"),
103 104 (r'\w,\w', "missing whitespace after ,"),
104 105 (r'\w[+/*\-<>]\w', "missing whitespace in expression"),
105 106 (r'^\s+\w+=\w+[^,)]$', "missing whitespace in assignment"),
106 107 (r'.{85}', "line too long"),
107 108 (r'.{81}', "warning: line over 80 characters"),
108 109 (r'[^\n]\Z', "no trailing newline"),
109 110 # (r'^\s+[^_ ][^_. ]+_[^_]+\s*=', "don't use underbars in identifiers"),
110 111 # (r'\w*[a-z][A-Z]\w*\s*=', "don't use camelcase in identifiers"),
111 112 (r'^\s*(if|while|def|class|except|try)\s[^[]*:\s*[^\]#\s]+',
112 113 "linebreak after :"),
113 114 (r'class\s[^(]:', "old-style class, use class foo(object)"),
114 115 (r'^\s+del\(', "del isn't a function"),
115 116 (r'^\s+except\(', "except isn't a function"),
116 117 (r',]', "unneeded trailing ',' in list"),
117 118 # (r'class\s[A-Z][^\(]*\((?!Exception)',
118 119 # "don't capitalize non-exception classes"),
119 120 # (r'in range\(', "use xrange"),
120 121 # (r'^\s*print\s+', "avoid using print in core and extensions"),
121 122 (r'[\x80-\xff]', "non-ASCII character literal"),
122 123 (r'("\')\.format\(', "str.format() not available in Python 2.4"),
123 124 (r'^\s*with\s+', "with not available in Python 2.4"),
124 125 (r'(?<!def)\s+(any|all|format)\(',
125 126 "any/all/format not available in Python 2.4"),
126 127 (r'(?<!def)\s+(callable)\(',
127 128 "callable not available in Python 3, use hasattr(f, '__call__')"),
128 129 (r'if\s.*\selse', "if ... else form not available in Python 2.4"),
129 130 (r'([\(\[]\s\S)|(\S\s[\)\]])', "gratuitous whitespace in () or []"),
130 131 # (r'\s\s=', "gratuitous whitespace before ="),
131 132 (r'[^>< ](\+=|-=|!=|<>|<=|>=|<<=|>>=)\S',
132 133 "missing whitespace around operator"),
133 134 (r'[^>< ](\+=|-=|!=|<>|<=|>=|<<=|>>=)\s',
134 135 "missing whitespace around operator"),
135 136 (r'\s(\+=|-=|!=|<>|<=|>=|<<=|>>=)\S',
136 137 "missing whitespace around operator"),
137 138 (r'[^+=*!<>&| -](\s=|=\s)[^= ]',
138 139 "wrong whitespace around ="),
139 140 (r'raise Exception', "don't raise generic exceptions"),
140 141 (r'ui\.(status|progress|write|note|warn)\([\'\"]x',
141 142 "warning: unwrapped ui message"),
142 143 ]
143 144
144 145 pyfilters = [
145 146 (r"""(?msx)(?P<comment>\#.*?$)|
146 147 ((?P<quote>('''|\"\"\"|(?<!')'(?!')|(?<!")"(?!")))
147 148 (?P<text>(([^\\]|\\.)*?))
148 149 (?P=quote))""", reppython),
149 150 ]
150 151
151 152 cpats = [
152 153 (r'//', "don't use //-style comments"),
153 154 (r'^ ', "don't use spaces to indent"),
154 155 (r'\S\t', "don't use tabs except for indent"),
155 156 (r'(\S\s+|^\s+)\n', "trailing whitespace"),
156 157 (r'.{85}', "line too long"),
157 158 (r'(while|if|do|for)\(', "use space after while/if/do/for"),
158 159 (r'return\(', "return is not a function"),
159 160 (r' ;', "no space before ;"),
160 161 (r'\w+\* \w+', "use int *foo, not int* foo"),
161 162 (r'\([^\)]+\) \w+', "use (int)foo, not (int) foo"),
162 163 (r'\S+ (\+\+|--)', "use foo++, not foo ++"),
163 164 (r'\w,\w', "missing whitespace after ,"),
164 165 (r'\w[+/*]\w', "missing whitespace in expression"),
165 166 (r'^#\s+\w', "use #foo, not # foo"),
166 167 (r'[^\n]\Z', "no trailing newline"),
167 168 ]
168 169
169 170 cfilters = [
170 171 (r'(/\*)(((\*(?!/))|[^*])*)\*/', repccomment),
171 172 (r'''(?P<quote>(?<!")")(?P<text>([^"]|\\")+)"(?!")''', repquote),
172 173 (r'''(#\s*include\s+<)([^>]+)>''', repinclude),
173 174 (r'(\()([^)]+\))', repcallspaces),
174 175 ]
175 176
176 177 checks = [
177 178 ('python', r'.*\.(py|cgi)$', pyfilters, pypats),
178 179 ('test script', r'(.*/)?test-[^.~]*$', testfilters, testpats),
179 180 ('c', r'.*\.c$', cfilters, cpats),
180 181 ('unified test', r'.*\.t$', utestfilters, utestpats),
181 182 ]
182 183
183 184 class norepeatlogger(object):
184 185 def __init__(self):
185 186 self._lastseen = None
186 187
187 188 def log(self, fname, lineno, line, msg, blame):
188 189 """print error related a to given line of a given file.
189 190
190 191 The faulty line will also be printed but only once in the case
191 192 of multiple errors.
192 193
193 194 :fname: filename
194 195 :lineno: line number
195 196 :line: actual content of the line
196 197 :msg: error message
197 198 """
198 199 msgid = fname, lineno, line
199 200 if msgid != self._lastseen:
200 201 if blame:
201 202 print "%s:%d (%s):" % (fname, lineno, blame)
202 203 else:
203 204 print "%s:%d:" % (fname, lineno)
204 205 print " > %s" % line
205 206 self._lastseen = msgid
206 207 print " " + msg
207 208
208 209 _defaultlogger = norepeatlogger()
209 210
210 211 def getblame(f):
211 212 lines = []
212 213 for l in os.popen('hg annotate -un %s' % f):
213 214 start, line = l.split(':', 1)
214 215 user, rev = start.split()
215 216 lines.append((line[1:-1], user, rev))
216 217 return lines
217 218
218 219 def checkfile(f, logfunc=_defaultlogger.log, maxerr=None, warnings=False,
219 220 blame=False):
220 221 """checks style and portability of a given file
221 222
222 223 :f: filepath
223 224 :logfunc: function used to report error
224 225 logfunc(filename, linenumber, linecontent, errormessage)
225 226 :maxerr: number of error to display before arborting.
226 227 Set to None (default) to report all errors
227 228
228 229 return True if no error is found, False otherwise.
229 230 """
230 231 blamecache = None
231 232 result = True
232 233 for name, match, filters, pats in checks:
233 234 fc = 0
234 235 if not re.match(match, f):
235 236 continue
236 237 pre = post = open(f).read()
237 238 if "no-" + "check-code" in pre:
238 239 break
239 240 for p, r in filters:
240 241 post = re.sub(p, r, post)
241 242 # print post # uncomment to show filtered version
242 243 z = enumerate(zip(pre.splitlines(), post.splitlines(True)))
243 244 for n, l in z:
244 245 if "check-code" + "-ignore" in l[0]:
245 246 continue
246 247 for p, msg in pats:
247 248 if not warnings and msg.startswith("warning"):
248 249 continue
249 250 if re.search(p, l[1]):
250 251 bd = ""
251 252 if blame:
252 253 bd = 'working directory'
253 254 if not blamecache:
254 255 blamecache = getblame(f)
255 256 if n < len(blamecache):
256 257 bl, bu, br = blamecache[n]
257 258 if bl == l[0]:
258 259 bd = '%s@%s' % (bu, br)
259 260 logfunc(f, n + 1, l[0], msg, bd)
260 261 fc += 1
261 262 result = False
262 263 if maxerr is not None and fc >= maxerr:
263 264 print " (too many errors, giving up)"
264 265 break
265 266 break
266 267 return result
267 268
268 269 if __name__ == "__main__":
269 270 parser = optparse.OptionParser("%prog [options] [files]")
270 271 parser.add_option("-w", "--warnings", action="store_true",
271 272 help="include warning-level checks")
272 273 parser.add_option("-p", "--per-file", type="int",
273 274 help="max warnings per file")
274 275 parser.add_option("-b", "--blame", action="store_true",
275 276 help="use annotate to generate blame info")
276 277
277 278 parser.set_defaults(per_file=15, warnings=False, blame=False)
278 279 (options, args) = parser.parse_args()
279 280
280 281 if len(args) == 0:
281 282 check = glob.glob("*")
282 283 else:
283 284 check = args
284 285
285 286 for f in check:
286 287 ret = 0
287 288 if not checkfile(f, maxerr=options.per_file, warnings=options.warnings,
288 289 blame=options.blame):
289 290 ret = 1
290 291 sys.exit(ret)
@@ -1,235 +1,235 b''
1 1 $ mkdir test
2 2 $ cd test
3 3 $ hg init
4 4 $ echo foo>foo
5 5 $ hg commit -Am 1 -d '1 0'
6 6 adding foo
7 7 $ echo bar>bar
8 8 $ hg commit -Am 2 -d '2 0'
9 9 adding bar
10 10 $ mkdir baz
11 11 $ echo bletch>baz/bletch
12 12 $ hg commit -Am 3 -d '1000000000 0'
13 13 adding baz/bletch
14 14 $ echo "[web]" >> .hg/hgrc
15 15 $ echo "name = test-archive" >> .hg/hgrc
16 16 $ cp .hg/hgrc .hg/hgrc-base
17 17 > test_archtype() {
18 18 > echo "allow_archive = $1" >> .hg/hgrc
19 19 > hg serve -p $HGPORT -d --pid-file=hg.pid -E errors.log
20 20 > cat hg.pid >> $DAEMON_PIDS
21 21 > echo % $1 allowed should give 200
22 22 > "$TESTDIR/get-with-headers.py" localhost:$HGPORT "/archive/tip.$2" | head -n 1
23 23 > echo % $3 and $4 disallowed should both give 403
24 24 > "$TESTDIR/get-with-headers.py" localhost:$HGPORT "/archive/tip.$3" | head -n 1
25 25 > "$TESTDIR/get-with-headers.py" localhost:$HGPORT "/archive/tip.$4" | head -n 1
26 26 > "$TESTDIR/killdaemons.py"
27 27 > cat errors.log
28 28 > cp .hg/hgrc-base .hg/hgrc
29 29 > }
30 30
31 31 check http return codes
32 32
33 33
34 34 $ test_archtype gz tar.gz tar.bz2 zip
35 35 % gz allowed should give 200
36 36 200 Script output follows
37 37 % tar.bz2 and zip disallowed should both give 403
38 38 403 Archive type not allowed: bz2
39 39 403 Archive type not allowed: zip
40 40 $ test_archtype bz2 tar.bz2 zip tar.gz
41 41 % bz2 allowed should give 200
42 42 200 Script output follows
43 43 % zip and tar.gz disallowed should both give 403
44 44 403 Archive type not allowed: zip
45 45 403 Archive type not allowed: gz
46 46 $ test_archtype zip zip tar.gz tar.bz2
47 47 % zip allowed should give 200
48 48 200 Script output follows
49 49 % tar.gz and tar.bz2 disallowed should both give 403
50 50 403 Archive type not allowed: gz
51 51 403 Archive type not allowed: bz2
52 52
53 53 $ echo "allow_archive = gz bz2 zip" >> .hg/hgrc
54 54 $ hg serve -p $HGPORT -d --pid-file=hg.pid -E errors.log
55 55 $ cat hg.pid >> $DAEMON_PIDS
56 56
57 57 invalid arch type should give 404
58 58
59 59 $ "$TESTDIR/get-with-headers.py" localhost:$HGPORT "/archive/tip.invalid" | head -n 1
60 60 404 Unsupported archive type: None
61 61
62 62 $ TIP=`hg id -v | cut -f1 -d' '`
63 63 $ QTIP=`hg id -q`
64 64 $ cat > getarchive.py <<EOF
65 65 > import os, sys, urllib2
66 66 > try:
67 67 > # Set stdout to binary mode for win32 platforms
68 68 > import msvcrt
69 69 > msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
70 70 > except ImportError:
71 71 > pass
72 72 > node, archive = sys.argv[1:]
73 73 > f = urllib2.urlopen('http://127.0.0.1:%s/?cmd=archive;node=%s;type=%s'
74 74 > % (os.environ['HGPORT'], node, archive))
75 75 > sys.stdout.write(f.read())
76 76 > EOF
77 $ python getarchive.py "$TIP" gz | gunzip | tar tf - 2>/dev/null | sed "s/$QTIP/TIP/"
78 test-archive-TIP/.hg_archival.txt
79 test-archive-TIP/bar
80 test-archive-TIP/baz/bletch
81 test-archive-TIP/foo
82 $ python getarchive.py "$TIP" bz2 | bunzip2 | tar tf - 2>/dev/null | sed "s/$QTIP/TIP/"
83 test-archive-TIP/.hg_archival.txt
84 test-archive-TIP/bar
85 test-archive-TIP/baz/bletch
86 test-archive-TIP/foo
77 $ python getarchive.py "$TIP" gz | gunzip | tar tf - 2>/dev/null
78 test-archive-2c0277f05ed4/.hg_archival.txt
79 test-archive-2c0277f05ed4/bar
80 test-archive-2c0277f05ed4/baz/bletch
81 test-archive-2c0277f05ed4/foo
82 $ python getarchive.py "$TIP" bz2 | bunzip2 | tar tf - 2>/dev/null
83 test-archive-2c0277f05ed4/.hg_archival.txt
84 test-archive-2c0277f05ed4/bar
85 test-archive-2c0277f05ed4/baz/bletch
86 test-archive-2c0277f05ed4/foo
87 87 $ python getarchive.py "$TIP" zip > archive.zip
88 $ unzip -t archive.zip | sed "s/$QTIP/TIP/"
88 $ unzip -t archive.zip
89 89 Archive: archive.zip
90 testing: test-archive-TIP/.hg_archival.txt OK
91 testing: test-archive-TIP/bar OK
92 testing: test-archive-TIP/baz/bletch OK
93 testing: test-archive-TIP/foo OK
90 testing: test-archive-2c0277f05ed4/.hg_archival.txt OK
91 testing: test-archive-2c0277f05ed4/bar OK
92 testing: test-archive-2c0277f05ed4/baz/bletch OK
93 testing: test-archive-2c0277f05ed4/foo OK
94 94 No errors detected in compressed data of archive.zip.
95 95
96 96 $ "$TESTDIR/killdaemons.py"
97 97
98 98 $ hg archive -t tar test.tar
99 99 $ tar tf test.tar
100 100 test/.hg_archival.txt
101 101 test/bar
102 102 test/baz/bletch
103 103 test/foo
104 104
105 105 $ hg archive -t tbz2 -X baz test.tar.bz2
106 106 $ bunzip2 -dc test.tar.bz2 | tar tf - 2>/dev/null
107 107 test/.hg_archival.txt
108 108 test/bar
109 109 test/foo
110 110
111 111 $ hg archive -t tgz -p %b-%h test-%h.tar.gz
112 $ gzip -dc test-$QTIP.tar.gz | tar tf - 2>/dev/null | sed "s/$QTIP/TIP/"
113 test-TIP/.hg_archival.txt
114 test-TIP/bar
115 test-TIP/baz/bletch
116 test-TIP/foo
112 $ gzip -dc test-$QTIP.tar.gz | tar tf - 2>/dev/null
113 test-2c0277f05ed4/.hg_archival.txt
114 test-2c0277f05ed4/bar
115 test-2c0277f05ed4/baz/bletch
116 test-2c0277f05ed4/foo
117 117
118 118 $ hg archive autodetected_test.tar
119 119 $ tar tf autodetected_test.tar
120 120 autodetected_test/.hg_archival.txt
121 121 autodetected_test/bar
122 122 autodetected_test/baz/bletch
123 123 autodetected_test/foo
124 124
125 125 The '-t' should override autodetection
126 126
127 127 $ hg archive -t tar autodetect_override_test.zip
128 128 $ tar tf autodetect_override_test.zip
129 129 autodetect_override_test.zip/.hg_archival.txt
130 130 autodetect_override_test.zip/bar
131 131 autodetect_override_test.zip/baz/bletch
132 132 autodetect_override_test.zip/foo
133 133
134 134 $ for ext in tar tar.gz tgz tar.bz2 tbz2 zip; do
135 135 > hg archive auto_test.$ext
136 136 > if [ -d auto_test.$ext ]; then
137 137 > echo "extension $ext was not autodetected."
138 138 > fi
139 139 > done
140 140
141 141 $ cat > md5comp.py <<EOF
142 142 > try:
143 143 > from hashlib import md5
144 144 > except ImportError:
145 145 > from md5 import md5
146 146 > import sys
147 147 > f1, f2 = sys.argv[1:3]
148 148 > h1 = md5(file(f1, 'rb').read()).hexdigest()
149 149 > h2 = md5(file(f2, 'rb').read()).hexdigest()
150 150 > print h1 == h2 or "md5 differ: " + repr((h1, h2))
151 151 > EOF
152 152
153 153 archive name is stored in the archive, so create similar
154 154
155 155 archives and rename them afterwards.
156 156
157 157 $ hg archive -t tgz tip.tar.gz
158 158 $ mv tip.tar.gz tip1.tar.gz
159 159 $ sleep 1
160 160 $ hg archive -t tgz tip.tar.gz
161 161 $ mv tip.tar.gz tip2.tar.gz
162 162 $ python md5comp.py tip1.tar.gz tip2.tar.gz
163 163 True
164 164
165 165 $ hg archive -t zip -p /illegal test.zip
166 166 abort: archive prefix contains illegal components
167 167 [255]
168 168 $ hg archive -t zip -p very/../bad test.zip
169 169
170 170 $ hg archive --config ui.archivemeta=false -t zip -r 2 test.zip
171 171 $ unzip -t test.zip
172 172 Archive: test.zip
173 173 testing: test/bar OK
174 174 testing: test/baz/bletch OK
175 175 testing: test/foo OK
176 176 No errors detected in compressed data of test.zip.
177 177
178 $ hg archive -t tar - | tar tf - 2>/dev/null | sed "s/$QTIP/TIP/"
179 test-TIP/.hg_archival.txt
180 test-TIP/bar
181 test-TIP/baz/bletch
182 test-TIP/foo
178 $ hg archive -t tar - | tar tf - 2>/dev/null
179 test-2c0277f05ed4/.hg_archival.txt
180 test-2c0277f05ed4/bar
181 test-2c0277f05ed4/baz/bletch
182 test-2c0277f05ed4/foo
183 183
184 184 $ hg archive -r 0 -t tar rev-%r.tar
185 185 $ if [ -f rev-0.tar ]; then
186 186 $ fi
187 187
188 188 test .hg_archival.txt
189 189
190 190 $ hg archive ../test-tags
191 191 $ cat ../test-tags/.hg_archival.txt
192 192 repo: daa7f7c60e0a224faa4ff77ca41b2760562af264
193 193 node: 2c0277f05ed49d1c8328fb9ba92fba7a5ebcb33e
194 194 branch: default
195 195 latesttag: null
196 196 latesttagdistance: 3
197 197 $ hg tag -r 2 mytag
198 198 $ hg tag -r 2 anothertag
199 199 $ hg archive -r 2 ../test-lasttag
200 200 $ cat ../test-lasttag/.hg_archival.txt
201 201 repo: daa7f7c60e0a224faa4ff77ca41b2760562af264
202 202 node: 2c0277f05ed49d1c8328fb9ba92fba7a5ebcb33e
203 203 branch: default
204 204 tag: anothertag
205 205 tag: mytag
206 206
207 207 $ hg archive -t bogus test.bogus
208 208 abort: unknown archive type 'bogus'
209 209 [255]
210 210
211 211 server errors
212 212
213 213 $ cat errors.log
214 214
215 215 empty repo
216 216
217 217 $ hg init ../empty
218 218 $ cd ../empty
219 219 $ hg archive ../test-empty
220 220 abort: no working directory: please specify a revision
221 221 [255]
222 222 old file -- date clamped to 1980
223 223
224 224 $ touch -d 1975-01-01 old
225 225 $ hg add old
226 226 $ hg commit -m old
227 227 $ hg archive ../old.zip
228 228 $ unzip -l ../old.zip
229 229 Archive: ../old.zip
230 230 \s*Length.*
231 231 .*-----.*
232 232 .*147.*80.*00:00.*old/.hg_archival.txt
233 233 .*0.*80.*00:00.*old/old
234 234 .*-----.*
235 235 \s*147\s+2 files
@@ -1,419 +1,421 b''
1 1 $ hg init
2 2
3 3
4 4 committing changes
5 5
6 6 $ count=0
7 7 $ echo > a
8 8 $ while test $count -lt 32 ; do
9 9 > echo 'a' >> a
10 10 > test $count -eq 0 && hg add
11 11 > hg ci -m "msg $count" -d "$count 0"
12 12 > count=`expr $count + 1`
13 13 > done
14 14 adding a
15 15
16 16
17 17 $ hg log
18 18 changeset: 31:58c80a7c8a40
19 19 tag: tip
20 20 user: test
21 21 date: Thu Jan 01 00:00:31 1970 +0000
22 22 summary: msg 31
23 23
24 24 changeset: 30:ed2d2f24b11c
25 25 user: test
26 26 date: Thu Jan 01 00:00:30 1970 +0000
27 27 summary: msg 30
28 28
29 29 changeset: 29:b5bd63375ab9
30 30 user: test
31 31 date: Thu Jan 01 00:00:29 1970 +0000
32 32 summary: msg 29
33 33
34 34 changeset: 28:8e0c2264c8af
35 35 user: test
36 36 date: Thu Jan 01 00:00:28 1970 +0000
37 37 summary: msg 28
38 38
39 39 changeset: 27:288867a866e9
40 40 user: test
41 41 date: Thu Jan 01 00:00:27 1970 +0000
42 42 summary: msg 27
43 43
44 44 changeset: 26:3efc6fd51aeb
45 45 user: test
46 46 date: Thu Jan 01 00:00:26 1970 +0000
47 47 summary: msg 26
48 48
49 49 changeset: 25:02a84173a97a
50 50 user: test
51 51 date: Thu Jan 01 00:00:25 1970 +0000
52 52 summary: msg 25
53 53
54 54 changeset: 24:10e0acd3809e
55 55 user: test
56 56 date: Thu Jan 01 00:00:24 1970 +0000
57 57 summary: msg 24
58 58
59 59 changeset: 23:5ec79163bff4
60 60 user: test
61 61 date: Thu Jan 01 00:00:23 1970 +0000
62 62 summary: msg 23
63 63
64 64 changeset: 22:06c7993750ce
65 65 user: test
66 66 date: Thu Jan 01 00:00:22 1970 +0000
67 67 summary: msg 22
68 68
69 69 changeset: 21:e5db6aa3fe2a
70 70 user: test
71 71 date: Thu Jan 01 00:00:21 1970 +0000
72 72 summary: msg 21
73 73
74 74 changeset: 20:7128fb4fdbc9
75 75 user: test
76 76 date: Thu Jan 01 00:00:20 1970 +0000
77 77 summary: msg 20
78 78
79 79 changeset: 19:52798545b482
80 80 user: test
81 81 date: Thu Jan 01 00:00:19 1970 +0000
82 82 summary: msg 19
83 83
84 84 changeset: 18:86977a90077e
85 85 user: test
86 86 date: Thu Jan 01 00:00:18 1970 +0000
87 87 summary: msg 18
88 88
89 89 changeset: 17:03515f4a9080
90 90 user: test
91 91 date: Thu Jan 01 00:00:17 1970 +0000
92 92 summary: msg 17
93 93
94 94 changeset: 16:a2e6ea4973e9
95 95 user: test
96 96 date: Thu Jan 01 00:00:16 1970 +0000
97 97 summary: msg 16
98 98
99 99 changeset: 15:e7fa0811edb0
100 100 user: test
101 101 date: Thu Jan 01 00:00:15 1970 +0000
102 102 summary: msg 15
103 103
104 104 changeset: 14:ce8f0998e922
105 105 user: test
106 106 date: Thu Jan 01 00:00:14 1970 +0000
107 107 summary: msg 14
108 108
109 109 changeset: 13:9d7d07bc967c
110 110 user: test
111 111 date: Thu Jan 01 00:00:13 1970 +0000
112 112 summary: msg 13
113 113
114 114 changeset: 12:1941b52820a5
115 115 user: test
116 116 date: Thu Jan 01 00:00:12 1970 +0000
117 117 summary: msg 12
118 118
119 119 changeset: 11:7b4cd9578619
120 120 user: test
121 121 date: Thu Jan 01 00:00:11 1970 +0000
122 122 summary: msg 11
123 123
124 124 changeset: 10:7c5eff49a6b6
125 125 user: test
126 126 date: Thu Jan 01 00:00:10 1970 +0000
127 127 summary: msg 10
128 128
129 129 changeset: 9:eb44510ef29a
130 130 user: test
131 131 date: Thu Jan 01 00:00:09 1970 +0000
132 132 summary: msg 9
133 133
134 134 changeset: 8:453eb4dba229
135 135 user: test
136 136 date: Thu Jan 01 00:00:08 1970 +0000
137 137 summary: msg 8
138 138
139 139 changeset: 7:03750880c6b5
140 140 user: test
141 141 date: Thu Jan 01 00:00:07 1970 +0000
142 142 summary: msg 7
143 143
144 144 changeset: 6:a3d5c6fdf0d3
145 145 user: test
146 146 date: Thu Jan 01 00:00:06 1970 +0000
147 147 summary: msg 6
148 148
149 149 changeset: 5:7874a09ea728
150 150 user: test
151 151 date: Thu Jan 01 00:00:05 1970 +0000
152 152 summary: msg 5
153 153
154 154 changeset: 4:9b2ba8336a65
155 155 user: test
156 156 date: Thu Jan 01 00:00:04 1970 +0000
157 157 summary: msg 4
158 158
159 159 changeset: 3:b53bea5e2fcb
160 160 user: test
161 161 date: Thu Jan 01 00:00:03 1970 +0000
162 162 summary: msg 3
163 163
164 164 changeset: 2:db07c04beaca
165 165 user: test
166 166 date: Thu Jan 01 00:00:02 1970 +0000
167 167 summary: msg 2
168 168
169 169 changeset: 1:5cd978ea5149
170 170 user: test
171 171 date: Thu Jan 01 00:00:01 1970 +0000
172 172 summary: msg 1
173 173
174 174 changeset: 0:b99c7b9c8e11
175 175 user: test
176 176 date: Thu Jan 01 00:00:00 1970 +0000
177 177 summary: msg 0
178 178
179 179
180 180 $ hg up -C
181 181 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
182 182
183 183 bisect test
184 184
185 185 $ hg bisect -r
186 186 $ hg bisect -b
187 187 $ hg bisect -g 1
188 188 Testing changeset 16:a2e6ea4973e9 (30 changesets remaining, ~4 tests)
189 189 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
190 190 $ hg bisect -g
191 191 Testing changeset 23:5ec79163bff4 (15 changesets remaining, ~3 tests)
192 192 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
193 193
194 194 skip
195 195
196 196 $ hg bisect -s
197 197 Testing changeset 24:10e0acd3809e (15 changesets remaining, ~3 tests)
198 198 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
199 199 $ hg bisect -g
200 200 Testing changeset 27:288867a866e9 (7 changesets remaining, ~2 tests)
201 201 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
202 202 $ hg bisect -g
203 203 Testing changeset 29:b5bd63375ab9 (4 changesets remaining, ~2 tests)
204 204 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
205 205 $ hg bisect -b
206 206 Testing changeset 28:8e0c2264c8af (2 changesets remaining, ~1 tests)
207 207 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
208 208 $ hg bisect -g
209 209 The first bad revision is:
210 210 changeset: 29:b5bd63375ab9
211 211 user: test
212 212 date: Thu Jan 01 00:00:29 1970 +0000
213 213 summary: msg 29
214 214
215 215
216 216 mark revsets instead of single revs
217 217
218 218 $ hg bisect -r
219 219 $ hg bisect -b "0::3"
220 220 $ hg bisect -s "13::16"
221 221 $ hg bisect -g "26::tip"
222 222 Testing changeset 12:1941b52820a5 (23 changesets remaining, ~4 tests)
223 223 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
224 224 $ cat .hg/bisect.state
225 225 skip 9d7d07bc967ca98ad0600c24953fd289ad5fa991
226 226 skip ce8f0998e922c179e80819d5066fbe46e2998784
227 227 skip e7fa0811edb063f6319531f0d0a865882138e180
228 228 skip a2e6ea4973e9196ddd3386493b0c214b41fd97d3
229 229 bad b99c7b9c8e11558adef3fad9af211c58d46f325b
230 230 bad 5cd978ea51499179507ee7b6f340d2dbaa401185
231 231 bad db07c04beaca44cf24832541e7f4a2346a95275b
232 232 bad b53bea5e2fcb30d3e00bd3409507a5659ce0fd8b
233 233 good 3efc6fd51aeb8594398044c6c846ca59ae021203
234 234 good 288867a866e9adb7a29880b66936c874b80f4651
235 235 good 8e0c2264c8af790daf3585ada0669d93dee09c83
236 236 good b5bd63375ab9a290419f2024b7f4ee9ea7ce90a8
237 237 good ed2d2f24b11c368fa8aa0da9f4e1db580abade59
238 238 good 58c80a7c8a4025a94cedaf7b4a4e3124e8909a96
239 239
240 240 bisect reverse test
241 241
242 242 $ hg bisect -r
243 243 $ hg bisect -b null
244 244 $ hg bisect -g tip
245 245 Testing changeset 15:e7fa0811edb0 (32 changesets remaining, ~5 tests)
246 246 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
247 247 $ hg bisect -g
248 248 Testing changeset 7:03750880c6b5 (16 changesets remaining, ~4 tests)
249 249 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
250 250
251 251 skip
252 252
253 253 $ hg bisect -s
254 254 Testing changeset 6:a3d5c6fdf0d3 (16 changesets remaining, ~4 tests)
255 255 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
256 256 $ hg bisect -g
257 257 Testing changeset 2:db07c04beaca (7 changesets remaining, ~2 tests)
258 258 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
259 259 $ hg bisect -g
260 260 Testing changeset 0:b99c7b9c8e11 (3 changesets remaining, ~1 tests)
261 261 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
262 262 $ hg bisect -b
263 263 Testing changeset 1:5cd978ea5149 (2 changesets remaining, ~1 tests)
264 264 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
265 265 $ hg bisect -g
266 266 The first good revision is:
267 267 changeset: 1:5cd978ea5149
268 268 user: test
269 269 date: Thu Jan 01 00:00:01 1970 +0000
270 270 summary: msg 1
271 271
272 272 $ false
273 273 [1]
274 274
275 275
276 276 $ hg bisect -r
277 277 $ hg bisect -g tip
278 278 $ hg bisect -b tip
279 279 abort: starting revisions are not directly related
280 [255]
280 281
281 282 $ hg bisect -r
282 283 $ hg bisect -g null
283 284 $ hg bisect -bU tip
284 285 Testing changeset 15:e7fa0811edb0 (32 changesets remaining, ~5 tests)
285 286 $ hg id
286 287 5cd978ea5149
287 288
288 289
289 290 reproduce AssertionError, issue1228 and issue1182
290 291
291 292 $ hg bisect -r
292 293 $ hg bisect -b 4
293 294 $ hg bisect -g 0
294 295 Testing changeset 2:db07c04beaca (4 changesets remaining, ~2 tests)
295 296 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
296 297 $ hg bisect -s
297 298 Testing changeset 1:5cd978ea5149 (4 changesets remaining, ~2 tests)
298 299 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
299 300 $ hg bisect -s
300 301 Testing changeset 3:b53bea5e2fcb (4 changesets remaining, ~2 tests)
301 302 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
302 303 $ hg bisect -s
303 304 Due to skipped revisions, the first bad revision could be any of:
304 305 changeset: 1:5cd978ea5149
305 306 user: test
306 307 date: Thu Jan 01 00:00:01 1970 +0000
307 308 summary: msg 1
308 309
309 310 changeset: 2:db07c04beaca
310 311 user: test
311 312 date: Thu Jan 01 00:00:02 1970 +0000
312 313 summary: msg 2
313 314
314 315 changeset: 3:b53bea5e2fcb
315 316 user: test
316 317 date: Thu Jan 01 00:00:03 1970 +0000
317 318 summary: msg 3
318 319
319 320 changeset: 4:9b2ba8336a65
320 321 user: test
321 322 date: Thu Jan 01 00:00:04 1970 +0000
322 323 summary: msg 4
323 324
324 325
325 326
326 327 reproduce non converging bisect, issue1182
327 328
328 329 $ hg bisect -r
329 330 $ hg bisect -g 0
330 331 $ hg bisect -b 2
331 332 Testing changeset 1:5cd978ea5149 (2 changesets remaining, ~1 tests)
332 333 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
333 334 $ hg bisect -s
334 335 Due to skipped revisions, the first bad revision could be any of:
335 336 changeset: 1:5cd978ea5149
336 337 user: test
337 338 date: Thu Jan 01 00:00:01 1970 +0000
338 339 summary: msg 1
339 340
340 341 changeset: 2:db07c04beaca
341 342 user: test
342 343 date: Thu Jan 01 00:00:02 1970 +0000
343 344 summary: msg 2
344 345
345 346
346 347
347 348 test no action
348 349
349 350 $ hg bisect -r
350 351 $ hg bisect
351 352 abort: cannot bisect (no known good revisions)
353 [255]
352 354
353 355
354 356 reproduce AssertionError, issue1445
355 357
356 358 $ hg bisect -r
357 359 $ hg bisect -b 6
358 360 $ hg bisect -g 0
359 361 Testing changeset 3:b53bea5e2fcb (6 changesets remaining, ~2 tests)
360 362 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
361 363 $ hg bisect -s
362 364 Testing changeset 2:db07c04beaca (6 changesets remaining, ~2 tests)
363 365 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
364 366 $ hg bisect -s
365 367 Testing changeset 4:9b2ba8336a65 (6 changesets remaining, ~2 tests)
366 368 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
367 369 $ hg bisect -s
368 370 Testing changeset 1:5cd978ea5149 (6 changesets remaining, ~2 tests)
369 371 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
370 372 $ hg bisect -s
371 373 Testing changeset 5:7874a09ea728 (6 changesets remaining, ~2 tests)
372 374 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
373 375 $ hg bisect -g
374 376 The first bad revision is:
375 377 changeset: 6:a3d5c6fdf0d3
376 378 user: test
377 379 date: Thu Jan 01 00:00:06 1970 +0000
378 380 summary: msg 6
379 381
380 382
381 383 $ set +e
382 384
383 385 test invalid command
384 386 assuming that the shell returns 127 if command not found ...
385 387
386 388 $ hg bisect -r
387 389 $ hg bisect --command 'exit 127'
388 390 abort: failed to execute exit 127
389 391 [255]
390 392
391 393
392 394 test bisecting command
393 395
394 396 $ cat > script.py <<EOF
395 397 > #!/usr/bin/env python
396 398 > import sys
397 399 > from mercurial import ui, hg
398 400 > repo = hg.repository(ui.ui(), '.')
399 401 > if repo['.'].rev() < 6:
400 402 > sys.exit(1)
401 403 > EOF
402 404 $ chmod +x script.py
403 405 $ hg bisect -r
404 406 $ hg bisect --good tip
405 407 $ hg bisect --bad 0
406 408 Testing changeset 15:e7fa0811edb0 (31 changesets remaining, ~4 tests)
407 409 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
408 410 $ hg bisect --command "'`pwd`/script.py' and some parameters"
409 411 Changeset 15:e7fa0811edb0: good
410 412 Changeset 7:03750880c6b5: good
411 413 Changeset 3:b53bea5e2fcb: bad
412 414 Changeset 5:7874a09ea728: bad
413 415 Changeset 6:a3d5c6fdf0d3: good
414 416 The first good revision is:
415 417 changeset: 6:a3d5c6fdf0d3
416 418 user: test
417 419 date: Thu Jan 01 00:00:06 1970 +0000
418 420 summary: msg 6
419 421
@@ -1,110 +1,110 b''
1 1 $ hg init repo
2 2 $ cd repo
3 3 $ touch foo
4 4 $ hg add foo
5 5 $ for i in 0 1 2 3 4 5 6 7 8 9 10 11; do
6 6 > echo "foo-$i" >> foo
7 7 > hg ci -m "foo-$i"
8 8 > done
9 9
10 10 $ for out in "%nof%N" "%%%H" "%b-%R" "%h" "%r"; do
11 11 > echo
12 12 > echo "# foo-$out.patch"
13 13 > hg export -v -o "foo-$out.patch" 2:tip
14 14 > done
15 15
16 16 # foo-%nof%N.patch
17 17 exporting patches:
18 18 foo-01of10.patch
19 19 foo-02of10.patch
20 20 foo-03of10.patch
21 21 foo-04of10.patch
22 22 foo-05of10.patch
23 23 foo-06of10.patch
24 24 foo-07of10.patch
25 25 foo-08of10.patch
26 26 foo-09of10.patch
27 27 foo-10of10.patch
28 28
29 29 # foo-%%%H.patch
30 30 exporting patches:
31 31 foo-%617188a1c80f869a7b66c85134da88a6fb145f67.patch
32 32 foo-%dd41a5ff707a5225204105611ba49cc5c229d55f.patch
33 33 foo-%f95a5410f8664b6e1490a4af654e4b7d41a7b321.patch
34 34 foo-%4346bcfde53b4d9042489078bcfa9c3e28201db2.patch
35 35 foo-%afda8c3a009cc99449a05ad8aa4655648c4ecd34.patch
36 36 foo-%35284ce2b6b99c9d2ac66268fe99e68e1974e1aa.patch
37 37 foo-%9688c41894e6931305fa7165a37f6568050b4e9b.patch
38 38 foo-%747d3c68f8ec44bb35816bfcd59aeb50b9654c2f.patch
39 39 foo-%5f17a83f5fbd9414006a5e563eab4c8a00729efd.patch
40 40 foo-%f3acbafac161ec68f1598af38f794f28847ca5d3.patch
41 41
42 42 # foo-%b-%R.patch
43 43 exporting patches:
44 44 foo-repo-2.patch
45 45 foo-repo-3.patch
46 46 foo-repo-4.patch
47 47 foo-repo-5.patch
48 48 foo-repo-6.patch
49 49 foo-repo-7.patch
50 50 foo-repo-8.patch
51 51 foo-repo-9.patch
52 52 foo-repo-10.patch
53 53 foo-repo-11.patch
54 54
55 55 # foo-%h.patch
56 56 exporting patches:
57 57 foo-617188a1c80f.patch
58 58 foo-dd41a5ff707a.patch
59 59 foo-f95a5410f866.patch
60 60 foo-4346bcfde53b.patch
61 61 foo-afda8c3a009c.patch
62 62 foo-35284ce2b6b9.patch
63 63 foo-9688c41894e6.patch
64 64 foo-747d3c68f8ec.patch
65 65 foo-5f17a83f5fbd.patch
66 66 foo-f3acbafac161.patch
67 67
68 68 # foo-%r.patch
69 69 exporting patches:
70 70 foo-02.patch
71 71 foo-03.patch
72 72 foo-04.patch
73 73 foo-05.patch
74 74 foo-06.patch
75 75 foo-07.patch
76 76 foo-08.patch
77 77 foo-09.patch
78 78 foo-10.patch
79 79 foo-11.patch
80 80
81 81 Exporting 4 changesets to a file:
82 82
83 83 $ hg export -o export_internal 1 2 3 4
84 $ grep HG export_internal | wc -l | sed -e 's/^ *//'
85 4
84 $ grep HG export_internal | wc -l
85 \s*4
86 86
87 87 Exporting 4 changesets to a file:
88 88
89 $ hg export 1 2 3 4 | grep HG | wc -l | sed -e 's/^ *//'
90 4
89 $ hg export 1 2 3 4 | grep HG | wc -l
90 \s*4
91 91
92 92 Exporting revision -2 to a file:
93 93
94 94 $ hg export -- -2
95 95 # HG changeset patch
96 96 # User test
97 97 # Date 0 0
98 98 # Node ID 5f17a83f5fbd9414006a5e563eab4c8a00729efd
99 99 # Parent 747d3c68f8ec44bb35816bfcd59aeb50b9654c2f
100 100 foo-10
101 101
102 102 diff -r 747d3c68f8ec -r 5f17a83f5fbd foo
103 103 --- a/foo Thu Jan 01 00:00:00 1970 +0000
104 104 +++ b/foo Thu Jan 01 00:00:00 1970 +0000
105 105 @@ -8,3 +8,4 @@
106 106 foo-7
107 107 foo-8
108 108 foo-9
109 109 +foo-10
110 110
@@ -1,121 +1,122 b''
1 1 $ hg init
2 2
3 3 Test issue 562: .hgignore requires newline at end:
4 4
5 5 $ touch foo
6 6 $ touch bar
7 7 $ touch baz
8 8 $ cat > makeignore.py <<EOF
9 9 > f = open(".hgignore", "w")
10 10 > f.write("ignore\n")
11 11 > f.write("foo\n")
12 12 > # No EOL here
13 13 > f.write("bar")
14 14 > f.close()
15 15 > EOF
16 16
17 17 $ python makeignore.py
18 18
19 19 Should display baz only:
20 20
21 21 $ hg status
22 22 ? baz
23 23
24 24 $ rm foo bar baz .hgignore makeignore.py
25 25
26 26 $ touch a.o
27 27 $ touch a.c
28 28 $ touch syntax
29 29 $ mkdir dir
30 30 $ touch dir/a.o
31 31 $ touch dir/b.o
32 32 $ touch dir/c.o
33 33
34 34 $ hg add dir/a.o
35 35 $ hg commit -m 0
36 36 $ hg add dir/b.o
37 37
38 38 $ hg status
39 39 A dir/b.o
40 40 ? a.c
41 41 ? a.o
42 42 ? dir/c.o
43 43 ? syntax
44 44
45 45 $ echo "*.o" > .hgignore
46 $ hg status 2>&1 | sed -e 's/abort: .*\.hgignore:/abort: .hgignore:/'
47 abort: .hgignore: invalid pattern (relre): *.o
46 $ hg status
47 abort: .*/.hgignore: invalid pattern \(relre\): \*.o
48 [255]
48 49
49 50 $ echo ".*\.o" > .hgignore
50 51 $ hg status
51 52 A dir/b.o
52 53 ? .hgignore
53 54 ? a.c
54 55 ? syntax
55 56
56 57 Check it does not ignore the current directory '.':
57 58
58 59 $ echo "^\." > .hgignore
59 60 $ hg status
60 61 A dir/b.o
61 62 ? a.c
62 63 ? a.o
63 64 ? dir/c.o
64 65 ? syntax
65 66
66 67 $ echo "glob:**.o" > .hgignore
67 68 $ hg status
68 69 A dir/b.o
69 70 ? .hgignore
70 71 ? a.c
71 72 ? syntax
72 73
73 74 $ echo "glob:*.o" > .hgignore
74 75 $ hg status
75 76 A dir/b.o
76 77 ? .hgignore
77 78 ? a.c
78 79 ? syntax
79 80
80 81 $ echo "syntax: glob" > .hgignore
81 82 $ echo "re:.*\.o" >> .hgignore
82 83 $ hg status
83 84 A dir/b.o
84 85 ? .hgignore
85 86 ? a.c
86 87 ? syntax
87 88
88 89 $ echo "syntax: invalid" > .hgignore
89 $ hg status 2>&1 | sed -e 's/.*\.hgignore:/.hgignore:/'
90 .hgignore: ignoring invalid syntax 'invalid'
90 $ hg status
91 .*/.hgignore: ignoring invalid syntax 'invalid'
91 92 A dir/b.o
92 93 ? .hgignore
93 94 ? a.c
94 95 ? a.o
95 96 ? dir/c.o
96 97 ? syntax
97 98
98 99 $ echo "syntax: glob" > .hgignore
99 100 $ echo "*.o" >> .hgignore
100 101 $ hg status
101 102 A dir/b.o
102 103 ? .hgignore
103 104 ? a.c
104 105 ? syntax
105 106
106 107 $ echo "relglob:syntax*" > .hgignore
107 108 $ hg status
108 109 A dir/b.o
109 110 ? .hgignore
110 111 ? a.c
111 112 ? a.o
112 113 ? dir/c.o
113 114
114 115 $ echo "relglob:*" > .hgignore
115 116 $ hg status
116 117 A dir/b.o
117 118
118 119 $ cd dir
119 120 $ hg status .
120 121 A b.o
121 122
@@ -1,110 +1,113 b''
1 1 $ echo "invalid" > $HGRCPATH
2 $ hg version 2>&1 | sed -e "s|$HGRCPATH|\$HGRCPATH|"
3 hg: parse error at $HGRCPATH:1: invalid
2 $ hg version
3 hg: parse error at .*/\.hgrc:1: invalid
4 [255]
4 5 $ echo "" > $HGRCPATH
5 6
6 7 issue1199: escaping
7 8
8 9 $ hg init "foo%bar"
9 10 $ hg clone "foo%bar" foobar
10 11 updating to branch default
11 12 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
12 13 $ p=`pwd`
13 14 $ cd foobar
14 $ cat .hg/hgrc | sed -e "s:$p:...:"
15 $ cat .hg/hgrc
15 16 [paths]
16 default = .../foo%bar
17 $ hg paths | sed -e "s:$p:...:"
18 default = .../foo%bar
19 $ hg showconfig | sed -e "s:$p:...:"
20 bundle.mainreporoot=.../foobar
21 paths.default=.../foo%bar
17 default = .*/foo%bar
18 $ hg paths
19 default = .*/foo%bar
20 $ hg showconfig
21 bundle.mainreporoot=.*/foobar
22 paths.default=.*/foo%bar
22 23 $ cd ..
23 24
24 25 issue1829: wrong indentation
25 26
26 27 $ echo '[foo]' > $HGRCPATH
27 28 $ echo ' x = y' >> $HGRCPATH
28 $ hg version 2>&1 | sed -e "s|$HGRCPATH|\$HGRCPATH|"
29 hg: parse error at $HGRCPATH:2: x = y
29 $ hg version
30 hg: parse error at .*/\.hgrc:2: x = y
31 [255]
30 32
31 33 $ python -c "print '[foo]\nbar = a\n b\n c \n de\n fg \nbaz = bif cb \n'" \
32 34 > > $HGRCPATH
33 35 $ hg showconfig foo
34 36 foo.bar=a\nb\nc\nde\nfg
35 37 foo.baz=bif cb
36 38
37 39 $ FAKEPATH=/path/to/nowhere
38 40 $ export FAKEPATH
39 41 $ echo '%include $FAKEPATH/no-such-file' > $HGRCPATH
40 $ hg version 2>&1 | sed -e "s|$HGRCPATH|\$HGRCPATH|"
41 hg: parse error at $HGRCPATH:1: cannot include /path/to/nowhere/no-such-file (No such file or directory)
42 $ hg version
43 hg: parse error at .*/.hgrc:1: cannot include /path/to/nowhere/no-such-file \(No such file or directory\)
44 [255]
42 45 $ unset FAKEPATH
43 46
44 47 username expansion
45 48
46 49 $ olduser=$HGUSER
47 50 $ unset HGUSER
48 51
49 52 $ FAKEUSER='John Doe'
50 53 $ export FAKEUSER
51 54 $ echo '[ui]' > $HGRCPATH
52 55 $ echo 'username = $FAKEUSER' >> $HGRCPATH
53 56
54 57 $ hg init usertest
55 58 $ cd usertest
56 59 $ touch bar
57 60 $ hg commit --addremove --quiet -m "added bar"
58 61 $ hg log --template "{author}\n"
59 62 John Doe
60 63 $ cd ..
61 64
62 65 $ hg showconfig
63 66 ui.username=$FAKEUSER
64 67
65 68 $ unset FAKEUSER
66 69 $ HGUSER=$olduser
67 70 $ export HGUSER
68 71
69 72 HGPLAIN
70 73
71 74 $ cd ..
72 75 $ p=`pwd`
73 76 $ echo "[ui]" > $HGRCPATH
74 77 $ echo "debug=true" >> $HGRCPATH
75 78 $ echo "fallbackencoding=ASCII" >> $HGRCPATH
76 79 $ echo "quiet=true" >> $HGRCPATH
77 80 $ echo "slash=true" >> $HGRCPATH
78 81 $ echo "traceback=true" >> $HGRCPATH
79 82 $ echo "verbose=true" >> $HGRCPATH
80 83 $ echo "style=~/.hgstyle" >> $HGRCPATH
81 84 $ echo "logtemplate={node}" >> $HGRCPATH
82 85 $ echo "[defaults]" >> $HGRCPATH
83 86 $ echo "identify=-n" >> $HGRCPATH
84 87 $ echo "[alias]" >> $HGRCPATH
85 88 $ echo "log=log -g" >> $HGRCPATH
86 89
87 90 customized hgrc
88 91
89 $ hg showconfig | sed -e "s:$p:...:"
90 read config from: .../.hgrc
91 .../.hgrc:13: alias.log=log -g
92 .../.hgrc:11: defaults.identify=-n
93 .../.hgrc:2: ui.debug=true
94 .../.hgrc:3: ui.fallbackencoding=ASCII
95 .../.hgrc:4: ui.quiet=true
96 .../.hgrc:5: ui.slash=true
97 .../.hgrc:6: ui.traceback=true
98 .../.hgrc:7: ui.verbose=true
99 .../.hgrc:8: ui.style=~/.hgstyle
100 .../.hgrc:9: ui.logtemplate={node}
92 $ hg showconfig
93 read config from: .*/.hgrc
94 .*/.hgrc:13: alias.log=log -g
95 .*/.hgrc:11: defaults.identify=-n
96 .*/.hgrc:2: ui.debug=true
97 .*/.hgrc:3: ui.fallbackencoding=ASCII
98 .*/.hgrc:4: ui.quiet=true
99 .*/.hgrc:5: ui.slash=true
100 .*/.hgrc:6: ui.traceback=true
101 .*/.hgrc:7: ui.verbose=true
102 .*/.hgrc:8: ui.style=~/.hgstyle
103 .*/.hgrc:9: ui.logtemplate={node}
101 104
102 105 plain hgrc
103 106
104 107 $ HGPLAIN=; export HGPLAIN
105 $ hg showconfig --config ui.traceback=True --debug | sed -e "s:$p:...:"
106 read config from: .../.hgrc
108 $ hg showconfig --config ui.traceback=True --debug
109 read config from: .*/.hgrc
107 110 none: ui.traceback=True
108 111 none: ui.verbose=False
109 112 none: ui.debug=True
110 113 none: ui.quiet=False
@@ -1,919 +1,920 b''
1 1 $ hg init a
2 2 $ mkdir a/d1
3 3 $ mkdir a/d1/d2
4 4 $ echo line 1 > a/a
5 5 $ echo line 1 > a/d1/d2/a
6 6 $ hg --cwd a ci -Ama
7 7 adding a
8 8 adding d1/d2/a
9 9
10 10 $ echo line 2 >> a/a
11 11 $ hg --cwd a ci -u someone -d '1 0' -m'second change'
12 12
13 13
14 14 import exported patch
15 15
16 16 $ hg clone -r0 a b
17 17 requesting all changes
18 18 adding changesets
19 19 adding manifests
20 20 adding file changes
21 21 added 1 changesets with 2 changes to 2 files
22 22 updating to branch default
23 23 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
24 24 $ hg --cwd a export tip > tip.patch
25 25 $ hg --cwd b import ../tip.patch
26 26 applying ../tip.patch
27 27
28 28 message should be same
29 29
30 30 $ hg --cwd b tip | grep 'second change'
31 31 summary: second change
32 32
33 33 committer should be same
34 34
35 35 $ hg --cwd b tip | grep someone
36 36 user: someone
37 37 $ rm -r b
38 38
39 39
40 40 import exported patch with external patcher
41 41
42 42 $ cat > dummypatch.py <<EOF
43 43 > print 'patching file a'
44 44 > file('a', 'wb').write('line2\n')
45 45 > EOF
46 46 $ chmod +x dummypatch.py
47 47 $ hg clone -r0 a b
48 48 requesting all changes
49 49 adding changesets
50 50 adding manifests
51 51 adding file changes
52 52 added 1 changesets with 2 changes to 2 files
53 53 updating to branch default
54 54 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
55 55 $ hg --cwd a export tip > tip.patch
56 56 $ hg --config ui.patch='python ../dummypatch.py' --cwd b import ../tip.patch
57 57 applying ../tip.patch
58 58 $ cat b/a
59 59 line2
60 60 $ rm -r b
61 61
62 62
63 63 import of plain diff should fail without message
64 64
65 65 $ hg clone -r0 a b
66 66 requesting all changes
67 67 adding changesets
68 68 adding manifests
69 69 adding file changes
70 70 added 1 changesets with 2 changes to 2 files
71 71 updating to branch default
72 72 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
73 73 $ hg --cwd a diff -r0:1 > tip.patch
74 74 $ hg --cwd b import ../tip.patch
75 75 applying ../tip.patch
76 76 abort: empty commit message
77 77 [255]
78 78 $ rm -r b
79 79
80 80
81 81 import of plain diff should be ok with message
82 82
83 83 $ hg clone -r0 a b
84 84 requesting all changes
85 85 adding changesets
86 86 adding manifests
87 87 adding file changes
88 88 added 1 changesets with 2 changes to 2 files
89 89 updating to branch default
90 90 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
91 91 $ hg --cwd a diff -r0:1 > tip.patch
92 92 $ hg --cwd b import -mpatch ../tip.patch
93 93 applying ../tip.patch
94 94 $ rm -r b
95 95
96 96
97 97 import of plain diff with specific date and user
98 98
99 99 $ hg clone -r0 a b
100 100 requesting all changes
101 101 adding changesets
102 102 adding manifests
103 103 adding file changes
104 104 added 1 changesets with 2 changes to 2 files
105 105 updating to branch default
106 106 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
107 107 $ hg --cwd a diff -r0:1 > tip.patch
108 108 $ hg --cwd b import -mpatch -d '1 0' -u 'user@nowhere.net' ../tip.patch
109 109 applying ../tip.patch
110 110 $ hg -R b tip -pv
111 111 changeset: 1:ca68f19f3a40
112 112 tag: tip
113 113 user: user@nowhere.net
114 114 date: Thu Jan 01 00:00:01 1970 +0000
115 115 files: a
116 116 description:
117 117 patch
118 118
119 119
120 120 diff -r 80971e65b431 -r ca68f19f3a40 a
121 121 --- a/a Thu Jan 01 00:00:00 1970 +0000
122 122 +++ b/a Thu Jan 01 00:00:01 1970 +0000
123 123 @@ -1,1 +1,2 @@
124 124 line 1
125 125 +line 2
126 126
127 127 $ rm -r b
128 128
129 129
130 130 import of plain diff should be ok with --no-commit
131 131
132 132 $ hg clone -r0 a b
133 133 requesting all changes
134 134 adding changesets
135 135 adding manifests
136 136 adding file changes
137 137 added 1 changesets with 2 changes to 2 files
138 138 updating to branch default
139 139 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
140 140 $ hg --cwd a diff -r0:1 > tip.patch
141 141 $ hg --cwd b import --no-commit ../tip.patch
142 142 applying ../tip.patch
143 143 $ hg --cwd b diff --nodates
144 144 diff -r 80971e65b431 a
145 145 --- a/a
146 146 +++ b/a
147 147 @@ -1,1 +1,2 @@
148 148 line 1
149 149 +line 2
150 150 $ rm -r b
151 151
152 152
153 153 hg -R repo import
154 154 put the clone in a subdir - having a directory named "a"
155 155 used to hide a bug.
156 156
157 157 $ mkdir dir
158 158 $ hg clone -r0 a dir/b
159 159 requesting all changes
160 160 adding changesets
161 161 adding manifests
162 162 adding file changes
163 163 added 1 changesets with 2 changes to 2 files
164 164 updating to branch default
165 165 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
166 166 $ hg --cwd a export tip > dir/tip.patch
167 167 $ cd dir
168 168 $ hg -R b import tip.patch
169 169 applying tip.patch
170 170 $ cd ..
171 171 $ rm -r dir
172 172
173 173
174 174 import from stdin
175 175
176 176 $ hg clone -r0 a b
177 177 requesting all changes
178 178 adding changesets
179 179 adding manifests
180 180 adding file changes
181 181 added 1 changesets with 2 changes to 2 files
182 182 updating to branch default
183 183 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
184 184 $ hg --cwd a export tip | hg --cwd b import -
185 185 applying patch from stdin
186 186 $ rm -r b
187 187
188 188
189 189 import two patches in one stream
190 190
191 191 $ hg init b
192 192 $ hg --cwd a export 0:tip | hg --cwd b import -
193 193 applying patch from stdin
194 194 applied 80971e65b431
195 195 $ hg --cwd a id
196 196 1d4bd90af0e4 tip
197 197 $ hg --cwd b id
198 198 1d4bd90af0e4 tip
199 199 $ rm -r b
200 200
201 201
202 202 override commit message
203 203
204 204 $ hg clone -r0 a b
205 205 requesting all changes
206 206 adding changesets
207 207 adding manifests
208 208 adding file changes
209 209 added 1 changesets with 2 changes to 2 files
210 210 updating to branch default
211 211 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
212 212 $ hg --cwd a export tip | hg --cwd b import -m 'override' -
213 213 applying patch from stdin
214 214 $ hg --cwd b tip | grep override
215 215 summary: override
216 216 $ rm -r b
217 217
218 218 $ cat > mkmsg.py <<EOF
219 219 > import email.Message, sys
220 220 > msg = email.Message.Message()
221 221 > msg.set_payload('email commit message\n' + open('tip.patch', 'rb').read())
222 222 > msg['Subject'] = 'email patch'
223 223 > msg['From'] = 'email patcher'
224 224 > sys.stdout.write(msg.as_string())
225 225 > EOF
226 226
227 227
228 228 plain diff in email, subject, message body
229 229
230 230 $ hg clone -r0 a b
231 231 requesting all changes
232 232 adding changesets
233 233 adding manifests
234 234 adding file changes
235 235 added 1 changesets with 2 changes to 2 files
236 236 updating to branch default
237 237 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
238 238 $ hg --cwd a diff -r0:1 > tip.patch
239 239 $ python mkmsg.py > msg.patch
240 240 $ hg --cwd b import ../msg.patch
241 241 applying ../msg.patch
242 242 $ hg --cwd b tip | grep email
243 243 user: email patcher
244 244 summary: email patch
245 245 $ rm -r b
246 246
247 247
248 248 plain diff in email, no subject, message body
249 249
250 250 $ hg clone -r0 a b
251 251 requesting all changes
252 252 adding changesets
253 253 adding manifests
254 254 adding file changes
255 255 added 1 changesets with 2 changes to 2 files
256 256 updating to branch default
257 257 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
258 258 $ grep -v '^Subject:' msg.patch | hg --cwd b import -
259 259 applying patch from stdin
260 260 $ rm -r b
261 261
262 262
263 263 plain diff in email, subject, no message body
264 264
265 265 $ hg clone -r0 a b
266 266 requesting all changes
267 267 adding changesets
268 268 adding manifests
269 269 adding file changes
270 270 added 1 changesets with 2 changes to 2 files
271 271 updating to branch default
272 272 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
273 273 $ grep -v '^email ' msg.patch | hg --cwd b import -
274 274 applying patch from stdin
275 275 $ rm -r b
276 276
277 277
278 278 plain diff in email, no subject, no message body, should fail
279 279
280 280 $ hg clone -r0 a b
281 281 requesting all changes
282 282 adding changesets
283 283 adding manifests
284 284 adding file changes
285 285 added 1 changesets with 2 changes to 2 files
286 286 updating to branch default
287 287 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
288 288 $ egrep -v '^(Subject|email)' msg.patch | hg --cwd b import -
289 289 applying patch from stdin
290 290 abort: empty commit message
291 291 [255]
292 292 $ rm -r b
293 293
294 294
295 295 hg export in email, should use patch header
296 296
297 297 $ hg clone -r0 a b
298 298 requesting all changes
299 299 adding changesets
300 300 adding manifests
301 301 adding file changes
302 302 added 1 changesets with 2 changes to 2 files
303 303 updating to branch default
304 304 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
305 305 $ hg --cwd a export tip > tip.patch
306 306 $ python mkmsg.py | hg --cwd b import -
307 307 applying patch from stdin
308 308 $ hg --cwd b tip | grep second
309 309 summary: second change
310 310 $ rm -r b
311 311
312 312
313 313 subject: duplicate detection, removal of [PATCH]
314 314 The '---' tests the gitsendmail handling without proper mail headers
315 315
316 316 $ cat > mkmsg2.py <<EOF
317 317 > import email.Message, sys
318 318 > msg = email.Message.Message()
319 319 > msg.set_payload('email patch\n\nnext line\n---\n' + open('tip.patch').read())
320 320 > msg['Subject'] = '[PATCH] email patch'
321 321 > msg['From'] = 'email patcher'
322 322 > sys.stdout.write(msg.as_string())
323 323 > EOF
324 324
325 325
326 326 plain diff in email, [PATCH] subject, message body with subject
327 327
328 328 $ hg clone -r0 a b
329 329 requesting all changes
330 330 adding changesets
331 331 adding manifests
332 332 adding file changes
333 333 added 1 changesets with 2 changes to 2 files
334 334 updating to branch default
335 335 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
336 336 $ hg --cwd a diff -r0:1 > tip.patch
337 337 $ python mkmsg2.py | hg --cwd b import -
338 338 applying patch from stdin
339 339 $ hg --cwd b tip --template '{desc}\n'
340 340 email patch
341 341
342 342 next line
343 343 ---
344 344 $ rm -r b
345 345
346 346
347 347 We weren't backing up the correct dirstate file when importing many patches
348 348 (issue963)
349 349 import patch1 patch2; rollback
350 350
351 351 $ echo line 3 >> a/a
352 352 $ hg --cwd a ci -m'third change'
353 353 $ hg --cwd a export -o '../patch%R' 1 2
354 354 $ hg clone -qr0 a b
355 355 $ hg --cwd b parents --template 'parent: {rev}\n'
356 356 parent: 0
357 357 $ hg --cwd b import ../patch1 ../patch2
358 358 applying ../patch1
359 359 applying ../patch2
360 360 applied 1d4bd90af0e4
361 361 $ hg --cwd b rollback
362 362 rolling back to revision 1 (undo commit)
363 363 $ hg --cwd b parents --template 'parent: {rev}\n'
364 364 parent: 1
365 365 $ rm -r b
366 366
367 367
368 368 importing a patch in a subdirectory failed at the commit stage
369 369
370 370 $ echo line 2 >> a/d1/d2/a
371 371 $ hg --cwd a ci -u someoneelse -d '1 0' -m'subdir change'
372 372
373 373 hg import in a subdirectory
374 374
375 375 $ hg clone -r0 a b
376 376 requesting all changes
377 377 adding changesets
378 378 adding manifests
379 379 adding file changes
380 380 added 1 changesets with 2 changes to 2 files
381 381 updating to branch default
382 382 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
383 $ hg --cwd a export tip | sed -e 's/d1\/d2\///' > tip.patch
383 $ hg --cwd a export tip > tmp
384 $ sed -e 's/d1\/d2\///' < tmp > tip.patch
384 385 $ dir=`pwd`
385 386 $ cd b/d1/d2 2>&1 > /dev/null
386 387 $ hg import ../../../tip.patch
387 388 applying ../../../tip.patch
388 389 $ cd "$dir"
389 390
390 391 message should be 'subdir change'
391 392
392 393 $ hg --cwd b tip | grep 'subdir change'
393 394 summary: subdir change
394 395
395 396 committer should be 'someoneelse'
396 397
397 398 $ hg --cwd b tip | grep someoneelse
398 399 user: someoneelse
399 400
400 401 should be empty
401 402
402 403 $ hg --cwd b status
403 404
404 405
405 406 Test fuzziness (ambiguous patch location, fuzz=2)
406 407
407 408 $ hg init fuzzy
408 409 $ cd fuzzy
409 410 $ echo line1 > a
410 411 $ echo line0 >> a
411 412 $ echo line3 >> a
412 413 $ hg ci -Am adda
413 414 adding a
414 415 $ echo line1 > a
415 416 $ echo line2 >> a
416 417 $ echo line0 >> a
417 418 $ echo line3 >> a
418 419 $ hg ci -m change a
419 420 $ hg export tip > tip.patch
420 421 $ hg up -C 0
421 422 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
422 423 $ echo line1 > a
423 424 $ echo line0 >> a
424 425 $ echo line1 >> a
425 426 $ echo line0 >> a
426 427 $ hg ci -m brancha
427 428 created new head
428 429 $ hg import --no-commit -v tip.patch
429 430 applying tip.patch
430 431 patching file a
431 432 Hunk #1 succeeded at 1 with fuzz 2 (offset -2 lines).
432 433 $ hg revert -a
433 434 reverting a
434 435
435 436 test fuzziness with eol=auto
436 437
437 438 $ hg --config patch.eol=auto import --no-commit -v tip.patch
438 439 applying tip.patch
439 440 patching file a
440 441 Hunk #1 succeeded at 1 with fuzz 2 (offset -2 lines).
441 442 $ cd ..
442 443
443 444
444 445 Test hunk touching empty files (issue906)
445 446
446 447 $ hg init empty
447 448 $ cd empty
448 449 $ touch a
449 450 $ touch b1
450 451 $ touch c1
451 452 $ echo d > d
452 453 $ hg ci -Am init
453 454 adding a
454 455 adding b1
455 456 adding c1
456 457 adding d
457 458 $ echo a > a
458 459 $ echo b > b1
459 460 $ hg mv b1 b2
460 461 $ echo c > c1
461 462 $ hg copy c1 c2
462 463 $ rm d
463 464 $ touch d
464 465 $ hg diff --git
465 466 diff --git a/a b/a
466 467 --- a/a
467 468 +++ b/a
468 469 @@ -0,0 +1,1 @@
469 470 +a
470 471 diff --git a/b1 b/b2
471 472 rename from b1
472 473 rename to b2
473 474 --- a/b1
474 475 +++ b/b2
475 476 @@ -0,0 +1,1 @@
476 477 +b
477 478 diff --git a/c1 b/c1
478 479 --- a/c1
479 480 +++ b/c1
480 481 @@ -0,0 +1,1 @@
481 482 +c
482 483 diff --git a/c1 b/c2
483 484 copy from c1
484 485 copy to c2
485 486 --- a/c1
486 487 +++ b/c2
487 488 @@ -0,0 +1,1 @@
488 489 +c
489 490 diff --git a/d b/d
490 491 --- a/d
491 492 +++ b/d
492 493 @@ -1,1 +0,0 @@
493 494 -d
494 495 $ hg ci -m empty
495 496 $ hg export --git tip > empty.diff
496 497 $ hg up -C 0
497 498 4 files updated, 0 files merged, 2 files removed, 0 files unresolved
498 499 $ hg import empty.diff
499 500 applying empty.diff
500 501 $ for name in a b1 b2 c1 c2 d; do
501 502 > echo % $name file
502 503 > test -f $name && cat $name
503 504 > done
504 505 % a file
505 506 a
506 507 % b1 file
507 508 % b2 file
508 509 b
509 510 % c1 file
510 511 c
511 512 % c2 file
512 513 c
513 514 % d file
514 515 $ cd ..
515 516
516 517
517 518 Test importing a patch ending with a binary file removal
518 519
519 520 $ hg init binaryremoval
520 521 $ cd binaryremoval
521 522 $ echo a > a
522 523 $ python -c "file('b', 'wb').write('a\x00b')"
523 524 $ hg ci -Am addall
524 525 adding a
525 526 adding b
526 527 $ hg rm a
527 528 $ hg rm b
528 529 $ hg st
529 530 R a
530 531 R b
531 532 $ hg ci -m remove
532 533 $ hg export --git . > remove.diff
533 534 $ cat remove.diff | grep git
534 535 diff --git a/a b/a
535 536 diff --git a/b b/b
536 537 $ hg up -C 0
537 538 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
538 539 $ hg import remove.diff
539 540 applying remove.diff
540 541 $ hg manifest
541 542 $ cd ..
542 543
543 544
544 545 test update+rename with common name (issue 927)
545 546
546 547 $ hg init t
547 548 $ cd t
548 549 $ touch a
549 550 $ hg ci -Am t
550 551 adding a
551 552 $ echo a > a
552 553
553 554 Here, bfile.startswith(afile)
554 555
555 556 $ hg copy a a2
556 557 $ hg ci -m copya
557 558 $ hg export --git tip > copy.diff
558 559 $ hg up -C 0
559 560 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
560 561 $ hg import copy.diff
561 562 applying copy.diff
562 563
563 564 a should contain an 'a'
564 565
565 566 $ cat a
566 567 a
567 568
568 569 and a2 should have duplicated it
569 570
570 571 $ cat a2
571 572 a
572 573 $ cd ..
573 574
574 575
575 576 test -p0
576 577
577 578 $ hg init p0
578 579 $ cd p0
579 580 $ echo a > a
580 581 $ hg ci -Am t
581 582 adding a
582 583 $ hg import -p0 - << EOF
583 584 > foobar
584 585 > --- a Sat Apr 12 22:43:58 2008 -0400
585 586 > +++ a Sat Apr 12 22:44:05 2008 -0400
586 587 > @@ -1,1 +1,1 @@
587 588 > -a
588 589 > +bb
589 590 > EOF
590 591 applying patch from stdin
591 592 $ hg status
592 593 $ cat a
593 594 bb
594 595 $ cd ..
595 596
596 597
597 598 test paths outside repo root
598 599
599 600 $ mkdir outside
600 601 $ touch outside/foo
601 602 $ hg init inside
602 603 $ cd inside
603 604 $ hg import - <<EOF
604 605 > diff --git a/a b/b
605 606 > rename from ../outside/foo
606 607 > rename to bar
607 608 > EOF
608 609 applying patch from stdin
609 610 abort: ../outside/foo not under root
610 611 [255]
611 612 $ cd ..
612 613
613 614
614 615 test import with similarity and git and strip (issue295 et al.)
615 616
616 617 $ hg init sim
617 618 $ cd sim
618 619 $ echo 'this is a test' > a
619 620 $ hg ci -Ama
620 621 adding a
621 622 $ cat > ../rename.diff <<EOF
622 623 > diff --git a/foo/a b/foo/a
623 624 > deleted file mode 100644
624 625 > --- a/foo/a
625 626 > +++ /dev/null
626 627 > @@ -1,1 +0,0 @@
627 628 > -this is a test
628 629 > diff --git a/foo/b b/foo/b
629 630 > new file mode 100644
630 631 > --- /dev/null
631 632 > +++ b/foo/b
632 633 > @@ -0,0 +1,2 @@
633 634 > +this is a test
634 635 > +foo
635 636 > EOF
636 637 $ hg import --no-commit -v -s 1 ../rename.diff -p2
637 638 applying ../rename.diff
638 639 patching file a
639 640 patching file b
640 641 removing a
641 642 adding b
642 643 recording removal of a as rename to b (88% similar)
643 644 $ hg st -C
644 645 A b
645 646 a
646 647 R a
647 648 $ hg revert -a
648 649 undeleting a
649 650 forgetting b
650 651 $ rm b
651 652 $ hg import --no-commit -v -s 100 ../rename.diff -p2
652 653 applying ../rename.diff
653 654 patching file a
654 655 patching file b
655 656 removing a
656 657 adding b
657 658 $ hg st -C
658 659 A b
659 660 R a
660 661 $ cd ..
661 662
662 663
663 664 add empty file from the end of patch (issue 1495)
664 665
665 666 $ hg init addemptyend
666 667 $ cd addemptyend
667 668 $ touch a
668 669 $ hg addremove
669 670 adding a
670 671 $ hg ci -m "commit"
671 672 $ cat > a.patch <<EOF
672 673 > diff --git a/a b/a
673 674 > --- a/a
674 675 > +++ b/a
675 676 > @@ -0,0 +1,1 @@
676 677 > +a
677 678 > diff --git a/b b/b
678 679 > new file mode 100644
679 680 > EOF
680 681 $ hg import --no-commit a.patch
681 682 applying a.patch
682 683 $ cd ..
683 684
684 685
685 686 create file when source is not /dev/null
686 687
687 688 $ cat > create.patch <<EOF
688 689 > diff -Naur proj-orig/foo proj-new/foo
689 690 > --- proj-orig/foo 1969-12-31 16:00:00.000000000 -0800
690 691 > +++ proj-new/foo 2009-07-17 16:50:45.801368000 -0700
691 692 > @@ -0,0 +1,1 @@
692 693 > +a
693 694 > EOF
694 695
695 696 some people have patches like the following too
696 697
697 698 $ cat > create2.patch <<EOF
698 699 > diff -Naur proj-orig/foo proj-new/foo
699 700 > --- proj-orig/foo.orig 1969-12-31 16:00:00.000000000 -0800
700 701 > +++ proj-new/foo 2009-07-17 16:50:45.801368000 -0700
701 702 > @@ -0,0 +1,1 @@
702 703 > +a
703 704 > EOF
704 705 $ hg init oddcreate
705 706 $ cd oddcreate
706 707 $ hg import --no-commit ../create.patch
707 708 applying ../create.patch
708 709 $ cat foo
709 710 a
710 711 $ rm foo
711 712 $ hg revert foo
712 713 $ hg import --no-commit ../create2.patch
713 714 applying ../create2.patch
714 715 $ cat foo
715 716 a
716 717
717 718
718 719 first line mistaken for email headers (issue 1859)
719 720
720 721 $ hg init emailconfusion
721 722 $ cd emailconfusion
722 723 $ cat > a.patch <<EOF
723 724 > module: summary
724 725 >
725 726 > description
726 727 >
727 728 >
728 729 > diff -r 000000000000 -r 9b4c1e343b55 test.txt
729 730 > --- /dev/null
730 731 > +++ b/a
731 732 > @@ -0,0 +1,1 @@
732 733 > +a
733 734 > EOF
734 735 $ hg import -d '0 0' a.patch
735 736 applying a.patch
736 737 $ hg parents -v
737 738 changeset: 0:5a681217c0ad
738 739 tag: tip
739 740 user: test
740 741 date: Thu Jan 01 00:00:00 1970 +0000
741 742 files: a
742 743 description:
743 744 module: summary
744 745
745 746 description
746 747
747 748
748 749 $ cd ..
749 750
750 751
751 752 --- in commit message
752 753
753 754 $ hg init commitconfusion
754 755 $ cd commitconfusion
755 756 $ cat > a.patch <<EOF
756 757 > module: summary
757 758 >
758 759 > --- description
759 760 >
760 761 > diff --git a/a b/a
761 762 > new file mode 100644
762 763 > --- /dev/null
763 764 > +++ b/a
764 765 > @@ -0,0 +1,1 @@
765 766 > +a
766 767 > EOF
767 768 > hg import -d '0 0' a.patch
768 769 > hg parents -v
769 770 > cd ..
770 771 >
771 772 > echo '% tricky header splitting'
772 773 > cat > trickyheaders.patch <<EOF
773 774 > From: User A <user@a>
774 775 > Subject: [PATCH] from: tricky!
775 776 >
776 777 > # HG changeset patch
777 778 > # User User B
778 779 > # Date 1266264441 18000
779 780 > # Branch stable
780 781 > # Node ID f2be6a1170ac83bf31cb4ae0bad00d7678115bc0
781 782 > # Parent 0000000000000000000000000000000000000000
782 783 > from: tricky!
783 784 >
784 785 > That is not a header.
785 786 >
786 787 > diff -r 000000000000 -r f2be6a1170ac foo
787 788 > --- /dev/null
788 789 > +++ b/foo
789 790 > @@ -0,0 +1,1 @@
790 791 > +foo
791 792 > EOF
792 793 applying a.patch
793 794 changeset: 0:f34d9187897d
794 795 tag: tip
795 796 user: test
796 797 date: Thu Jan 01 00:00:00 1970 +0000
797 798 files: a
798 799 description:
799 800 module: summary
800 801
801 802
802 803 % tricky header splitting
803 804
804 805 $ hg init trickyheaders
805 806 $ cd trickyheaders
806 807 $ hg import -d '0 0' ../trickyheaders.patch
807 808 applying ../trickyheaders.patch
808 809 $ hg export --git tip
809 810 # HG changeset patch
810 811 # User User B
811 812 # Date 0 0
812 813 # Node ID eb56ab91903632294ac504838508cb370c0901d2
813 814 # Parent 0000000000000000000000000000000000000000
814 815 from: tricky!
815 816
816 817 That is not a header.
817 818
818 819 diff --git a/foo b/foo
819 820 new file mode 100644
820 821 --- /dev/null
821 822 +++ b/foo
822 823 @@ -0,0 +1,1 @@
823 824 +foo
824 825 $ cd ..
825 826
826 827
827 828 issue2102
828 829
829 830 $ hg init issue2102
830 831 $ cd issue2102
831 832 $ mkdir -p src/cmd/gc
832 833 $ touch src/cmd/gc/mksys.bash
833 834 $ hg ci -Am init
834 835 adding src/cmd/gc/mksys.bash
835 836 $ hg import - <<EOF
836 837 > # HG changeset patch
837 838 > # User Rob Pike
838 839 > # Date 1216685449 25200
839 840 > # Node ID 03aa2b206f499ad6eb50e6e207b9e710d6409c98
840 841 > # Parent 93d10138ad8df586827ca90b4ddb5033e21a3a84
841 842 > help management of empty pkg and lib directories in perforce
842 843 >
843 844 > R=gri
844 845 > DELTA=4 (4 added, 0 deleted, 0 changed)
845 846 > OCL=13328
846 847 > CL=13328
847 848 >
848 849 > diff --git a/lib/place-holder b/lib/place-holder
849 850 > new file mode 100644
850 851 > --- /dev/null
851 852 > +++ b/lib/place-holder
852 853 > @@ -0,0 +1,2 @@
853 854 > +perforce does not maintain empty directories.
854 855 > +this file helps.
855 856 > diff --git a/pkg/place-holder b/pkg/place-holder
856 857 > new file mode 100644
857 858 > --- /dev/null
858 859 > +++ b/pkg/place-holder
859 860 > @@ -0,0 +1,2 @@
860 861 > +perforce does not maintain empty directories.
861 862 > +this file helps.
862 863 > diff --git a/src/cmd/gc/mksys.bash b/src/cmd/gc/mksys.bash
863 864 > old mode 100644
864 865 > new mode 100755
865 866 > EOF
866 867 applying patch from stdin
867 868 $ hg sum
868 869 parent: 1:d59915696727 tip
869 870 help management of empty pkg and lib directories in perforce
870 871 branch: default
871 872 commit: (clean)
872 873 update: (current)
873 874 $ hg diff --git -c tip
874 875 diff --git a/lib/place-holder b/lib/place-holder
875 876 new file mode 100644
876 877 --- /dev/null
877 878 +++ b/lib/place-holder
878 879 @@ -0,0 +1,2 @@
879 880 +perforce does not maintain empty directories.
880 881 +this file helps.
881 882 diff --git a/pkg/place-holder b/pkg/place-holder
882 883 new file mode 100644
883 884 --- /dev/null
884 885 +++ b/pkg/place-holder
885 886 @@ -0,0 +1,2 @@
886 887 +perforce does not maintain empty directories.
887 888 +this file helps.
888 889 diff --git a/src/cmd/gc/mksys.bash b/src/cmd/gc/mksys.bash
889 890 old mode 100644
890 891 new mode 100755
891 892 $ cd ..
892 893
893 894
894 895 diff lines looking like headers
895 896
896 897 $ hg init difflineslikeheaders
897 898 $ cd difflineslikeheaders
898 899 $ echo a >a
899 900 $ echo b >b
900 901 $ echo c >c
901 902 $ hg ci -Am1
902 903 adding a
903 904 adding b
904 905 adding c
905 906
906 907 $ echo "key: value" >>a
907 908 $ echo "key: value" >>b
908 909 $ echo "foo" >>c
909 910 $ hg ci -m2
910 911
911 912 $ hg up -C 0
912 913 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
913 914 $ hg diff --git -c1 >want
914 915 $ hg diff -c1 | hg import --no-commit -
915 916 applying patch from stdin
916 917 $ hg diff --git >have
917 918 $ diff want have
918 919 $ cd ..
919 920
@@ -1,468 +1,468 b''
1 1 $ mkdir test
2 2 $ cd test
3 3 $ hg init
4 4 $ for i in 0 1 2 3 4 5 6 7 8; do
5 5 > echo $i >> foo
6 6 > hg commit -A -m $i
7 7 > done
8 8 adding foo
9 9 $ hg verify
10 10 checking changesets
11 11 checking manifests
12 12 crosschecking files in changesets and manifests
13 13 checking files
14 14 1 files, 9 changesets, 9 total revisions
15 15 $ hg serve -p $HGPORT -d --pid-file=hg.pid
16 16 $ cat hg.pid >> $DAEMON_PIDS
17 17 $ cd ..
18 18
19 19 $ hg init new
20 20
21 21 http incoming
22 22
23 $ hg -R new incoming http://localhost:$HGPORT/ | sed -e "s,:$HGPORT/,:\$HGPORT/,"
24 comparing with http://localhost:$HGPORT/
23 $ hg -R new incoming http://localhost:$HGPORT/
24 comparing with http://localhost:\d+/
25 25 changeset: 0:00a43fa82f62
26 26 user: test
27 27 date: Thu Jan 01 00:00:00 1970 +0000
28 28 summary: 0
29 29
30 30 changeset: 1:5460a410df01
31 31 user: test
32 32 date: Thu Jan 01 00:00:00 1970 +0000
33 33 summary: 1
34 34
35 35 changeset: 2:d9f42cd1a1ec
36 36 user: test
37 37 date: Thu Jan 01 00:00:00 1970 +0000
38 38 summary: 2
39 39
40 40 changeset: 3:376476025137
41 41 user: test
42 42 date: Thu Jan 01 00:00:00 1970 +0000
43 43 summary: 3
44 44
45 45 changeset: 4:70d7eb252d49
46 46 user: test
47 47 date: Thu Jan 01 00:00:00 1970 +0000
48 48 summary: 4
49 49
50 50 changeset: 5:ad284ee3b5ee
51 51 user: test
52 52 date: Thu Jan 01 00:00:00 1970 +0000
53 53 summary: 5
54 54
55 55 changeset: 6:e9229f2de384
56 56 user: test
57 57 date: Thu Jan 01 00:00:00 1970 +0000
58 58 summary: 6
59 59
60 60 changeset: 7:d152815bb8db
61 61 user: test
62 62 date: Thu Jan 01 00:00:00 1970 +0000
63 63 summary: 7
64 64
65 65 changeset: 8:e4feb4ac9035
66 66 tag: tip
67 67 user: test
68 68 date: Thu Jan 01 00:00:00 1970 +0000
69 69 summary: 8
70 70
71 $ hg -R new incoming -r 4 http://localhost:$HGPORT/ | sed -e "s,:$HGPORT/,:\$HGPORT/,"
72 comparing with http://localhost:$HGPORT/
71 $ hg -R new incoming -r 4 http://localhost:$HGPORT/
72 comparing with http://localhost:\d+/
73 73 changeset: 0:00a43fa82f62
74 74 user: test
75 75 date: Thu Jan 01 00:00:00 1970 +0000
76 76 summary: 0
77 77
78 78 changeset: 1:5460a410df01
79 79 user: test
80 80 date: Thu Jan 01 00:00:00 1970 +0000
81 81 summary: 1
82 82
83 83 changeset: 2:d9f42cd1a1ec
84 84 user: test
85 85 date: Thu Jan 01 00:00:00 1970 +0000
86 86 summary: 2
87 87
88 88 changeset: 3:376476025137
89 89 user: test
90 90 date: Thu Jan 01 00:00:00 1970 +0000
91 91 summary: 3
92 92
93 93 changeset: 4:70d7eb252d49
94 94 tag: tip
95 95 user: test
96 96 date: Thu Jan 01 00:00:00 1970 +0000
97 97 summary: 4
98 98
99 99
100 100 local incoming
101 101
102 102 $ hg -R new incoming test
103 103 comparing with test
104 104 changeset: 0:00a43fa82f62
105 105 user: test
106 106 date: Thu Jan 01 00:00:00 1970 +0000
107 107 summary: 0
108 108
109 109 changeset: 1:5460a410df01
110 110 user: test
111 111 date: Thu Jan 01 00:00:00 1970 +0000
112 112 summary: 1
113 113
114 114 changeset: 2:d9f42cd1a1ec
115 115 user: test
116 116 date: Thu Jan 01 00:00:00 1970 +0000
117 117 summary: 2
118 118
119 119 changeset: 3:376476025137
120 120 user: test
121 121 date: Thu Jan 01 00:00:00 1970 +0000
122 122 summary: 3
123 123
124 124 changeset: 4:70d7eb252d49
125 125 user: test
126 126 date: Thu Jan 01 00:00:00 1970 +0000
127 127 summary: 4
128 128
129 129 changeset: 5:ad284ee3b5ee
130 130 user: test
131 131 date: Thu Jan 01 00:00:00 1970 +0000
132 132 summary: 5
133 133
134 134 changeset: 6:e9229f2de384
135 135 user: test
136 136 date: Thu Jan 01 00:00:00 1970 +0000
137 137 summary: 6
138 138
139 139 changeset: 7:d152815bb8db
140 140 user: test
141 141 date: Thu Jan 01 00:00:00 1970 +0000
142 142 summary: 7
143 143
144 144 changeset: 8:e4feb4ac9035
145 145 tag: tip
146 146 user: test
147 147 date: Thu Jan 01 00:00:00 1970 +0000
148 148 summary: 8
149 149
150 150 $ hg -R new incoming -r 4 test
151 151 comparing with test
152 152 changeset: 0:00a43fa82f62
153 153 user: test
154 154 date: Thu Jan 01 00:00:00 1970 +0000
155 155 summary: 0
156 156
157 157 changeset: 1:5460a410df01
158 158 user: test
159 159 date: Thu Jan 01 00:00:00 1970 +0000
160 160 summary: 1
161 161
162 162 changeset: 2:d9f42cd1a1ec
163 163 user: test
164 164 date: Thu Jan 01 00:00:00 1970 +0000
165 165 summary: 2
166 166
167 167 changeset: 3:376476025137
168 168 user: test
169 169 date: Thu Jan 01 00:00:00 1970 +0000
170 170 summary: 3
171 171
172 172 changeset: 4:70d7eb252d49
173 173 user: test
174 174 date: Thu Jan 01 00:00:00 1970 +0000
175 175 summary: 4
176 176
177 177
178 178 limit to 2 changesets
179 179
180 180 $ hg -R new incoming -l 2 test
181 181 comparing with test
182 182 changeset: 0:00a43fa82f62
183 183 user: test
184 184 date: Thu Jan 01 00:00:00 1970 +0000
185 185 summary: 0
186 186
187 187 changeset: 1:5460a410df01
188 188 user: test
189 189 date: Thu Jan 01 00:00:00 1970 +0000
190 190 summary: 1
191 191
192 192
193 193 limit to 2 changesets, test with -p --git
194 194
195 195 $ hg -R new incoming -l 2 -p --git test
196 196 comparing with test
197 197 changeset: 0:00a43fa82f62
198 198 user: test
199 199 date: Thu Jan 01 00:00:00 1970 +0000
200 200 summary: 0
201 201
202 202 diff --git a/foo b/foo
203 203 new file mode 100644
204 204 --- /dev/null
205 205 +++ b/foo
206 206 @@ -0,0 +1,1 @@
207 207 +0
208 208
209 209 changeset: 1:5460a410df01
210 210 user: test
211 211 date: Thu Jan 01 00:00:00 1970 +0000
212 212 summary: 1
213 213
214 214 diff --git a/foo b/foo
215 215 --- a/foo
216 216 +++ b/foo
217 217 @@ -1,1 +1,2 @@
218 218 0
219 219 +1
220 220
221 221
222 222 test with --bundle
223 223
224 $ hg -R new incoming --bundle test.hg http://localhost:$HGPORT/ | sed -e "s,:$HGPORT/,:\$HGPORT/,"
225 comparing with http://localhost:$HGPORT/
224 $ hg -R new incoming --bundle test.hg http://localhost:$HGPORT/
225 comparing with http://localhost:.*/
226 226 changeset: 0:00a43fa82f62
227 227 user: test
228 228 date: Thu Jan 01 00:00:00 1970 +0000
229 229 summary: 0
230 230
231 231 changeset: 1:5460a410df01
232 232 user: test
233 233 date: Thu Jan 01 00:00:00 1970 +0000
234 234 summary: 1
235 235
236 236 changeset: 2:d9f42cd1a1ec
237 237 user: test
238 238 date: Thu Jan 01 00:00:00 1970 +0000
239 239 summary: 2
240 240
241 241 changeset: 3:376476025137
242 242 user: test
243 243 date: Thu Jan 01 00:00:00 1970 +0000
244 244 summary: 3
245 245
246 246 changeset: 4:70d7eb252d49
247 247 user: test
248 248 date: Thu Jan 01 00:00:00 1970 +0000
249 249 summary: 4
250 250
251 251 changeset: 5:ad284ee3b5ee
252 252 user: test
253 253 date: Thu Jan 01 00:00:00 1970 +0000
254 254 summary: 5
255 255
256 256 changeset: 6:e9229f2de384
257 257 user: test
258 258 date: Thu Jan 01 00:00:00 1970 +0000
259 259 summary: 6
260 260
261 261 changeset: 7:d152815bb8db
262 262 user: test
263 263 date: Thu Jan 01 00:00:00 1970 +0000
264 264 summary: 7
265 265
266 266 changeset: 8:e4feb4ac9035
267 267 tag: tip
268 268 user: test
269 269 date: Thu Jan 01 00:00:00 1970 +0000
270 270 summary: 8
271 271
272 272 $ hg -R new incoming --bundle test2.hg test
273 273 comparing with test
274 274 changeset: 0:00a43fa82f62
275 275 user: test
276 276 date: Thu Jan 01 00:00:00 1970 +0000
277 277 summary: 0
278 278
279 279 changeset: 1:5460a410df01
280 280 user: test
281 281 date: Thu Jan 01 00:00:00 1970 +0000
282 282 summary: 1
283 283
284 284 changeset: 2:d9f42cd1a1ec
285 285 user: test
286 286 date: Thu Jan 01 00:00:00 1970 +0000
287 287 summary: 2
288 288
289 289 changeset: 3:376476025137
290 290 user: test
291 291 date: Thu Jan 01 00:00:00 1970 +0000
292 292 summary: 3
293 293
294 294 changeset: 4:70d7eb252d49
295 295 user: test
296 296 date: Thu Jan 01 00:00:00 1970 +0000
297 297 summary: 4
298 298
299 299 changeset: 5:ad284ee3b5ee
300 300 user: test
301 301 date: Thu Jan 01 00:00:00 1970 +0000
302 302 summary: 5
303 303
304 304 changeset: 6:e9229f2de384
305 305 user: test
306 306 date: Thu Jan 01 00:00:00 1970 +0000
307 307 summary: 6
308 308
309 309 changeset: 7:d152815bb8db
310 310 user: test
311 311 date: Thu Jan 01 00:00:00 1970 +0000
312 312 summary: 7
313 313
314 314 changeset: 8:e4feb4ac9035
315 315 tag: tip
316 316 user: test
317 317 date: Thu Jan 01 00:00:00 1970 +0000
318 318 summary: 8
319 319
320 320
321 321
322 322 test the resulting bundles
323 323
324 324 $ hg init temp
325 325 $ hg init temp2
326 326 $ hg -R temp unbundle test.hg
327 327 adding changesets
328 328 adding manifests
329 329 adding file changes
330 330 added 9 changesets with 9 changes to 1 files
331 331 (run 'hg update' to get a working copy)
332 332 $ hg -R temp2 unbundle test2.hg
333 333 adding changesets
334 334 adding manifests
335 335 adding file changes
336 336 added 9 changesets with 9 changes to 1 files
337 337 (run 'hg update' to get a working copy)
338 338 $ hg -R temp tip
339 339 changeset: 8:e4feb4ac9035
340 340 tag: tip
341 341 user: test
342 342 date: Thu Jan 01 00:00:00 1970 +0000
343 343 summary: 8
344 344
345 345 $ hg -R temp2 tip
346 346 changeset: 8:e4feb4ac9035
347 347 tag: tip
348 348 user: test
349 349 date: Thu Jan 01 00:00:00 1970 +0000
350 350 summary: 8
351 351
352 352
353 353 $ rm -r temp temp2 new
354 354
355 355 test outgoing
356 356
357 357 $ hg clone test test-dev
358 358 updating to branch default
359 359 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
360 360 $ cd test-dev
361 361 $ for i in 9 10 11 12 13; do
362 362 > echo $i >> foo
363 363 > hg commit -A -m $i
364 364 > done
365 365 $ hg verify
366 366 checking changesets
367 367 checking manifests
368 368 crosschecking files in changesets and manifests
369 369 checking files
370 370 1 files, 14 changesets, 14 total revisions
371 371 $ cd ..
372 372 $ hg -R test-dev outgoing test
373 373 comparing with test
374 374 searching for changes
375 375 changeset: 9:d89d4abea5bc
376 376 user: test
377 377 date: Thu Jan 01 00:00:00 1970 +0000
378 378 summary: 9
379 379
380 380 changeset: 10:820095aa7158
381 381 user: test
382 382 date: Thu Jan 01 00:00:00 1970 +0000
383 383 summary: 10
384 384
385 385 changeset: 11:09ede2f3a638
386 386 user: test
387 387 date: Thu Jan 01 00:00:00 1970 +0000
388 388 summary: 11
389 389
390 390 changeset: 12:e576b1bed305
391 391 user: test
392 392 date: Thu Jan 01 00:00:00 1970 +0000
393 393 summary: 12
394 394
395 395 changeset: 13:96bbff09a7cc
396 396 tag: tip
397 397 user: test
398 398 date: Thu Jan 01 00:00:00 1970 +0000
399 399 summary: 13
400 400
401 401
402 402 limit to 3 changesets
403 403
404 404 $ hg -R test-dev outgoing -l 3 test
405 405 comparing with test
406 406 searching for changes
407 407 changeset: 9:d89d4abea5bc
408 408 user: test
409 409 date: Thu Jan 01 00:00:00 1970 +0000
410 410 summary: 9
411 411
412 412 changeset: 10:820095aa7158
413 413 user: test
414 414 date: Thu Jan 01 00:00:00 1970 +0000
415 415 summary: 10
416 416
417 417 changeset: 11:09ede2f3a638
418 418 user: test
419 419 date: Thu Jan 01 00:00:00 1970 +0000
420 420 summary: 11
421 421
422 $ hg -R test-dev outgoing http://localhost:$HGPORT/ | sed -e "s,:$HGPORT/,:\$HGPORT/,"
423 comparing with http://localhost:$HGPORT/
422 $ hg -R test-dev outgoing http://localhost:$HGPORT/
423 comparing with http://localhost:.*/
424 424 searching for changes
425 425 changeset: 9:d89d4abea5bc
426 426 user: test
427 427 date: Thu Jan 01 00:00:00 1970 +0000
428 428 summary: 9
429 429
430 430 changeset: 10:820095aa7158
431 431 user: test
432 432 date: Thu Jan 01 00:00:00 1970 +0000
433 433 summary: 10
434 434
435 435 changeset: 11:09ede2f3a638
436 436 user: test
437 437 date: Thu Jan 01 00:00:00 1970 +0000
438 438 summary: 11
439 439
440 440 changeset: 12:e576b1bed305
441 441 user: test
442 442 date: Thu Jan 01 00:00:00 1970 +0000
443 443 summary: 12
444 444
445 445 changeset: 13:96bbff09a7cc
446 446 tag: tip
447 447 user: test
448 448 date: Thu Jan 01 00:00:00 1970 +0000
449 449 summary: 13
450 450
451 $ hg -R test-dev outgoing -r 11 http://localhost:$HGPORT/ | sed -e "s,:$HGPORT/,:\$HGPORT/,"
452 comparing with http://localhost:$HGPORT/
451 $ hg -R test-dev outgoing -r 11 http://localhost:$HGPORT/
452 comparing with http://localhost:.*/
453 453 searching for changes
454 454 changeset: 9:d89d4abea5bc
455 455 user: test
456 456 date: Thu Jan 01 00:00:00 1970 +0000
457 457 summary: 9
458 458
459 459 changeset: 10:820095aa7158
460 460 user: test
461 461 date: Thu Jan 01 00:00:00 1970 +0000
462 462 summary: 10
463 463
464 464 changeset: 11:09ede2f3a638
465 465 user: test
466 466 date: Thu Jan 01 00:00:00 1970 +0000
467 467 summary: 11
468 468
@@ -1,166 +1,166 b''
1 1 $ echo "[extensions]" >> $HGRCPATH
2 2 $ echo "mq=" >> $HGRCPATH
3 3 $ echo "[mq]" >> $HGRCPATH
4 4 $ echo "git=keep" >> $HGRCPATH
5 5
6 6 $ hg init a
7 7 $ cd a
8 8
9 9 $ echo 'base' > base
10 10 $ hg ci -Ambase
11 11 adding base
12 12
13 13 $ hg qnew -mmqbase mqbase
14 14
15 15 $ echo 'patched' > base
16 16 $ hg qrefresh
17 17
18 18 qdiff:
19 19
20 $ hg qdiff | sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/"
20 $ hg qdiff
21 21 diff -r d20a80d4def3 base
22 22 --- a/base Thu Jan 01 00:00:00 1970 +0000
23 +++ b/base
23 \+\+\+ b/base.*
24 24 @@ -1,1 +1,1 @@
25 25 -base
26 26 +patched
27 27
28 28 qdiff dirname:
29 29
30 30 $ hg qdiff --nodates .
31 31 diff -r d20a80d4def3 base
32 32 --- a/base
33 33 +++ b/base
34 34 @@ -1,1 +1,1 @@
35 35 -base
36 36 +patched
37 37
38 38 qdiff filename:
39 39
40 40 $ hg qdiff --nodates base
41 41 diff -r d20a80d4def3 base
42 42 --- a/base
43 43 +++ b/base
44 44 @@ -1,1 +1,1 @@
45 45 -base
46 46 +patched
47 47
48 48 $ hg revert -a
49 49
50 50 $ hg qpop
51 51 popping mqbase
52 52 patch queue now empty
53 53
54 54 $ hg qdelete mqbase
55 55
56 56 $ printf '1\n2\n3\n4\nhello world\ngoodbye world\n7\n8\n9\n' > lines
57 57 $ hg ci -Amlines -d '2 0'
58 58 adding lines
59 59
60 60 $ hg qnew -mmqbase2 mqbase2
61 61 $ printf '\n\n1\n2\n3\n4\nhello world\n goodbye world\n7\n8\n9\n' > lines
62 62
63 63 $ hg qdiff --nodates -U 1
64 64 diff -r b0c220e1cf43 lines
65 65 --- a/lines
66 66 +++ b/lines
67 67 @@ -1,1 +1,3 @@
68 68 +
69 69 +
70 70 1
71 71 @@ -4,4 +6,4 @@
72 72 4
73 73 -hello world
74 74 -goodbye world
75 75 +hello world
76 76 + goodbye world
77 77 7
78 78
79 79 $ hg qdiff --nodates -b
80 80 diff -r b0c220e1cf43 lines
81 81 --- a/lines
82 82 +++ b/lines
83 83 @@ -1,9 +1,11 @@
84 84 +
85 85 +
86 86 1
87 87 2
88 88 3
89 89 4
90 90 hello world
91 91 -goodbye world
92 92 + goodbye world
93 93 7
94 94 8
95 95 9
96 96
97 97 $ hg qdiff --nodates -U 1 -B
98 98 diff -r b0c220e1cf43 lines
99 99 --- a/lines
100 100 +++ b/lines
101 101 @@ -4,4 +6,4 @@
102 102 4
103 103 -hello world
104 104 -goodbye world
105 105 +hello world
106 106 + goodbye world
107 107 7
108 108
109 109 $ hg qdiff --nodates -w
110 110 diff -r b0c220e1cf43 lines
111 111 --- a/lines
112 112 +++ b/lines
113 113 @@ -1,3 +1,5 @@
114 114 +
115 115 +
116 116 1
117 117 2
118 118 3
119 119
120 120 $ hg qdiff --nodates --reverse
121 121 diff -r b0c220e1cf43 lines
122 122 --- a/lines
123 123 +++ b/lines
124 124 @@ -1,11 +1,9 @@
125 125 -
126 126 -
127 127 1
128 128 2
129 129 3
130 130 4
131 131 -hello world
132 132 - goodbye world
133 133 +hello world
134 134 +goodbye world
135 135 7
136 136 8
137 137 9
138 138
139 139 qdiff preserve existing git flag:
140 140
141 141 $ hg qrefresh --git
142 142 $ echo a >> lines
143 143 $ hg qdiff
144 144 diff --git a/lines b/lines
145 145 --- a/lines
146 146 +++ b/lines
147 147 @@ -1,9 +1,12 @@
148 148 +
149 149 +
150 150 1
151 151 2
152 152 3
153 153 4
154 154 -hello world
155 155 -goodbye world
156 156 +hello world
157 157 + goodbye world
158 158 7
159 159 8
160 160 9
161 161 +a
162 162
163 163 $ hg qdiff --stat
164 164 lines | 7 +++++--
165 165 1 files changed, 5 insertions(+), 2 deletions(-)
166 166
@@ -1,81 +1,81 b''
1 1 $ mkdir test
2 2 $ cd test
3 3
4 4 $ echo foo>foo
5 5 $ hg init
6 6 $ hg addremove
7 7 adding foo
8 8 $ hg commit -m 1
9 9
10 10 $ hg verify
11 11 checking changesets
12 12 checking manifests
13 13 crosschecking files in changesets and manifests
14 14 checking files
15 15 1 files, 1 changesets, 1 total revisions
16 16
17 17 $ hg serve -p $HGPORT -d --pid-file=hg.pid
18 18 $ cat hg.pid >> $DAEMON_PIDS
19 19 $ cd ..
20 20
21 $ hg clone --pull http://foo:bar@localhost:$HGPORT/ copy | sed -e "s,:$HGPORT/,:\$HGPORT/,"
21 $ hg clone --pull http://foo:bar@localhost:$HGPORT/ copy
22 22 requesting all changes
23 23 adding changesets
24 24 adding manifests
25 25 adding file changes
26 26 added 1 changesets with 1 changes to 1 files
27 27 updating to branch default
28 28 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
29 29
30 30 $ cd copy
31 31 $ hg verify
32 32 checking changesets
33 33 checking manifests
34 34 crosschecking files in changesets and manifests
35 35 checking files
36 36 1 files, 1 changesets, 1 total revisions
37 37
38 38 $ hg co
39 39 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
40 40 $ cat foo
41 41 foo
42 42
43 43 $ hg manifest --debug
44 44 2ed2a3912a0b24502043eae84ee4b279c18b90dd 644 foo
45 45
46 $ hg pull | sed -e "s,:$HGPORT/,:\$HGPORT/,"
47 pulling from http://foo:***@localhost:$HGPORT/
46 $ hg pull
47 pulling from http://foo:\*\*\*@localhost:.*/
48 48 searching for changes
49 49 no changes found
50 50
51 $ hg rollback --dry-run --verbose | sed -e "s,:$HGPORT/,:\$HGPORT/,"
52 rolling back to revision -1 (undo pull: http://foo:***@localhost:$HGPORT/)
51 $ hg rollback --dry-run --verbose
52 rolling back to revision -1 \(undo pull: http://foo:\*\*\*@localhost:.*/\)
53 53
54 54 Issue 622:
55 55
56 56 $ cd ..
57 57 $ hg init empty
58 58 $ cd empty
59 59 $ hg pull -u ../test
60 60 pulling from ../test
61 61 requesting all changes
62 62 adding changesets
63 63 adding manifests
64 64 adding file changes
65 65 added 1 changesets with 1 changes to 1 files
66 66 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
67 67
68 68 Test 'file:' uri handling:
69 69
70 70 $ hg pull -q file://../test-doesnt-exist
71 71 abort: repository /test-doesnt-exist not found!
72 72 [255]
73 73
74 74 $ hg pull -q file:../test
75 75
76 76 It's tricky to make file:// URLs working on every platform with
77 77 regular shell commands.
78 78
79 79 $ URL=`python -c "import os; print 'file://foobar' + ('/' + os.getcwd().replace(os.sep, '/')).replace('//', '/') + '/../test'"`
80 80 $ hg pull -q "$URL"
81 81
@@ -1,203 +1,201 b''
1 1 $ "$TESTDIR/hghave" svn || exit 80
2 2
3 3 $ fix_path()
4 4 > {
5 5 > tr '\\' /
6 6 > }
7 7
8 $ escapedwd=`pwd | fix_path`
9
10 8 SVN wants all paths to start with a slash. Unfortunately, Windows ones
11 9 don't. Handle that.
12 10
11 $ escapedwd=`pwd | fix_path`
13 12 $ expr "$escapedwd" : / > /dev/null || escapedwd="/$escapedwd"
14 13 $ escapedwd=`python -c "import urllib, sys; sys.stdout.write(urllib.quote(sys.argv[1]))" "$escapedwd"`
15 $ filterpath="s|$escapedwd|/root|"
16 $ filteroutofdate='s/ in transaction.*/ is out of date/;s/Out of date: /File /'
17 14
18 15 create subversion repo
19 16
20 17 $ SVNREPO="file://$escapedwd/svn-repo"
21 18 $ WCROOT="`pwd`/svn-wc"
22 19 $ svnadmin create svn-repo
23 20 $ svn co "$SVNREPO" svn-wc
24 21 Checked out revision 0.
25 22 $ cd svn-wc
26 23 $ mkdir src
27 24 $ echo alpha > src/alpha
28 25 $ svn add src
29 26 A src
30 27 A src/alpha
31 28 $ mkdir externals
32 29 $ echo other > externals/other
33 30 $ svn add externals
34 31 A externals
35 32 A externals/other
36 33 $ svn ci -m 'Add alpha'
37 34 Adding externals
38 35 Adding externals/other
39 36 Adding src
40 37 Adding src/alpha
41 38 Transmitting file data ..
42 39 Committed revision 1.
43 40 $ svn up
44 41 At revision 1.
45 42 $ echo "externals -r1 $SVNREPO/externals" > extdef
46 43 $ svn propset -F extdef svn:externals src
47 44 property 'svn:externals' set on 'src'
48 45 $ svn ci -m 'Setting externals'
49 46 Sending src
50 47
51 48 Committed revision 2.
52 49 $ cd ..
53 50
54 51 create hg repo
55 52
56 53 $ mkdir sub
57 54 $ cd sub
58 55 $ hg init t
59 56 $ cd t
60 57
61 58 first revision, no sub
62 59
63 60 $ echo a > a
64 61 $ hg ci -Am0
65 62 adding a
66 63
67 64 add first svn sub with leading whitespaces
68 65
69 66 $ echo "s = [svn] $SVNREPO/src" >> .hgsub
70 67 $ svn co --quiet "$SVNREPO"/src s
71 68 $ hg add .hgsub
72 69 $ hg ci -m1
73 70 committing subrepository s
74 71
75 72 debugsub
76 73
77 $ hg debugsub | sed "$filterpath"
74 $ hg debugsub
78 75 path s
79 source file:///root/svn-repo/src
76 source file:///.*/svn-repo/src
80 77 revision 2
81 78
82 79 change file in svn and hg, commit
83 80
84 81 $ echo a >> a
85 82 $ echo alpha >> s/alpha
86 $ hg commit -m 'Message!' \
87 > | sed 's:Sending.*s/alpha:Sending s/alpha:g'
83 $ hg commit -m 'Message!'
88 84 committing subrepository s
89 Sending s/alpha
85 Sending.*s/alpha
90 86 Transmitting file data .
91 87 Committed revision 3.
92 88
93 89 Fetching external item into '.*/s/externals'
94 90 External at revision 1.
95 91
96 92 At revision 3.
97 $ hg debugsub | sed "$filterpath"
93 $ hg debugsub
98 94 path s
99 source file:///root/svn-repo/src
95 source file:///.*/svn-repo/src
100 96 revision 3
101 97
102 98 $ echo a > s/a
103 99
104 100 should be empty despite change to s/a
105 101
106 102 $ hg st
107 103
108 104 add a commit from svn
109 105
110 106 $ cd "$WCROOT"/src
111 107 $ svn up
112 108 U alpha
113 109
114 110 Fetching external item into 'externals'
115 111 A externals/other
116 112 Updated external to revision 1.
117 113
118 114 Updated to revision 3.
119 115 $ echo xyz >> alpha
120 116 $ svn propset svn:mime-type 'text/xml' alpha
121 117 property 'svn:mime-type' set on 'alpha'
122 118 $ svn ci -m 'amend a from svn'
123 119 Sending src/alpha
124 120 Transmitting file data .
125 121 Committed revision 4.
126 122 $ cd ../../sub/t
127 123
128 124 this commit from hg will fail
129 125
130 126 $ echo zzz >> s/alpha
131 $ hg ci -m 'amend alpha from hg' 2>&1 | sed "$filteroutofdate"
127 $ hg ci -m 'amend alpha from hg'
132 128 committing subrepository s
133 129 abort: svn: Commit failed (details follow):
134 svn: File '/src/alpha' is out of date
130 svn: (Out of date)?.*/src/alpha.*(is out of date)?
131 [255]
135 132 $ svn revert -q s/alpha
136 133
137 134 this commit fails because of meta changes
138 135
139 136 $ svn propset svn:mime-type 'text/html' s/alpha
140 137 property 'svn:mime-type' set on 's/alpha'
141 $ hg ci -m 'amend alpha from hg' 2>&1 | sed "$filteroutofdate"
138 $ hg ci -m 'amend alpha from hg'
142 139 committing subrepository s
143 140 abort: svn: Commit failed (details follow):
144 svn: File '/src/alpha' is out of date
141 svn: (Out of date)?.*/src/alpha.*(is out of date)?
142 [255]
145 143 $ svn revert -q s/alpha
146 144
147 145 this commit fails because of externals changes
148 146
149 147 $ echo zzz > s/externals/other
150 148 $ hg ci -m 'amend externals from hg'
151 149 committing subrepository s
152 150 abort: cannot commit svn externals
153 151 [255]
154 152 $ hg diff --subrepos -r 1:2 | grep -v diff
155 153 --- a/.hgsubstate Thu Jan 01 00:00:00 1970 +0000
156 154 +++ b/.hgsubstate Thu Jan 01 00:00:00 1970 +0000
157 155 @@ -1,1 +1,1 @@
158 156 -2 s
159 157 +3 s
160 158 --- a/a Thu Jan 01 00:00:00 1970 +0000
161 159 +++ b/a Thu Jan 01 00:00:00 1970 +0000
162 160 @@ -1,1 +1,2 @@
163 161 a
164 162 +a
165 163 $ svn revert -q s/externals/other
166 164
167 165 this commit fails because of externals meta changes
168 166
169 167 $ svn propset svn:mime-type 'text/html' s/externals/other
170 168 property 'svn:mime-type' set on 's/externals/other'
171 169 $ hg ci -m 'amend externals from hg'
172 170 committing subrepository s
173 171 abort: cannot commit svn externals
174 172 [255]
175 173 $ svn revert -q s/externals/other
176 174
177 175 clone
178 176
179 177 $ cd ..
180 178 $ hg clone t tc | fix_path
181 179 updating to branch default
182 180 A tc/s/alpha
183 181 U tc/s
184 182
185 183 Fetching external item into 'tc/s/externals'
186 184 A tc/s/externals/other
187 185 Checked out external at revision 1.
188 186
189 187 Checked out revision 3.
190 188 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
191 189 $ cd tc
192 190
193 191 debugsub in clone
194 192
195 $ hg debugsub | sed "$filterpath"
193 $ hg debugsub
196 194 path s
197 source file:///root/svn-repo/src
195 source file:///.*/svn-repo/src
198 196 revision 3
199 197
200 198 verify subrepo is contained within the repo directory
201 199
202 200 $ python -c "import os.path; print os.path.exists('s')"
203 201 True
@@ -1,370 +1,370 b''
1 1 Helper functions:
2 2
3 3 $ cacheexists() {
4 4 > [ -f .hg/tags.cache ] && echo "tag cache exists" || echo "no tag cache"
5 5 > }
6 6
7 7 $ dumptags() {
8 8 > rev=$1
9 9 > echo "rev $rev: .hgtags:"
10 10 > hg cat -r$rev .hgtags
11 11 > }
12 12
13 13 # XXX need to test that the tag cache works when we strip an old head
14 14 # and add a new one rooted off non-tip: i.e. node and rev of tip are the
15 15 # same, but stuff has changed behind tip.
16 16
17 17 Setup:
18 18
19 19 $ hg init t
20 20 $ cd t
21 21 $ cacheexists
22 22 no tag cache
23 23 $ hg id
24 24 000000000000 tip
25 25 $ cacheexists
26 26 no tag cache
27 27 $ echo a > a
28 28 $ hg add a
29 29 $ hg commit -m "test"
30 30 $ hg co
31 31 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
32 32 $ hg identify
33 33 acb14030fe0a tip
34 34 $ cacheexists
35 35 tag cache exists
36 36
37 37 Create local tag with long name:
38 38
39 39 $ T=`hg identify --debug --id`
40 40 $ hg tag -l "This is a local tag with a really long name!"
41 41 $ hg tags
42 42 tip 0:acb14030fe0a
43 43 This is a local tag with a really long name! 0:acb14030fe0a
44 44 $ rm .hg/localtags
45 45
46 46 Create a tag behind hg's back:
47 47
48 48 $ echo "$T first" > .hgtags
49 49 $ cat .hgtags
50 50 acb14030fe0a21b60322c440ad2d20cf7685a376 first
51 51 $ hg add .hgtags
52 52 $ hg commit -m "add tags"
53 53 $ hg tags
54 54 tip 1:b9154636be93
55 55 first 0:acb14030fe0a
56 56 $ hg identify
57 57 b9154636be93 tip
58 58
59 59 Repeat with cold tag cache:
60 60
61 61 $ rm -f .hg/tags.cache
62 62 $ hg identify
63 63 b9154636be93 tip
64 64
65 65 And again, but now unable to write tag cache:
66 66
67 67 $ rm -f .hg/tags.cache
68 68 $ chmod 555 .hg
69 69 $ hg identify
70 70 b9154636be93 tip
71 71 $ chmod 755 .hg
72 72
73 73 Create a branch:
74 74
75 75 $ echo bb > a
76 76 $ hg status
77 77 M a
78 78 $ hg identify
79 79 b9154636be93+ tip
80 80 $ hg co first
81 81 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
82 82 $ hg id
83 83 acb14030fe0a+ first
84 84 $ hg -v id
85 85 acb14030fe0a+ first
86 86 $ hg status
87 87 M a
88 88 $ echo 1 > b
89 89 $ hg add b
90 90 $ hg commit -m "branch"
91 91 created new head
92 92 $ hg id
93 93 c8edf04160c7 tip
94 94
95 95 Merge the two heads:
96 96
97 97 $ hg merge 1
98 98 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
99 99 (branch merge, don't forget to commit)
100 100 $ hg id
101 101 c8edf04160c7+b9154636be93+ tip
102 102 $ hg status
103 103 M .hgtags
104 104 $ hg commit -m "merge"
105 105
106 106 Create a fake head, make sure tag not visible afterwards:
107 107
108 108 $ cp .hgtags tags
109 109 $ hg tag last
110 110 $ hg rm .hgtags
111 111 $ hg commit -m "remove"
112 112
113 113 $ mv tags .hgtags
114 114 $ hg add .hgtags
115 115 $ hg commit -m "readd"
116 116 $
117 117 $ hg tags
118 118 tip 6:35ff301afafe
119 119 first 0:acb14030fe0a
120 120
121 121 Add invalid tags:
122 122
123 123 $ echo "spam" >> .hgtags
124 124 $ echo >> .hgtags
125 125 $ echo "foo bar" >> .hgtags
126 $ echo "$T invalid" | sed "s/..../a5a5/" >> .hg/localtags
126 $ echo "a5a5 invalid" >> .hg/localtags
127 127 $ echo "committing .hgtags:"
128 128 committing .hgtags:
129 129 $ cat .hgtags
130 130 acb14030fe0a21b60322c440ad2d20cf7685a376 first
131 131 spam
132 132
133 133 foo bar
134 134 $ hg commit -m "tags"
135 135
136 136 Report tag parse error on other head:
137 137
138 138 $ hg up 3
139 139 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
140 140 $ echo 'x y' >> .hgtags
141 141 $ hg commit -m "head"
142 142 created new head
143 143
144 144 $ hg tags
145 145 .hgtags@75d9f02dfe28, line 2: cannot parse entry
146 146 .hgtags@75d9f02dfe28, line 4: node 'foo' is not well formed
147 147 .hgtags@c4be69a18c11, line 2: node 'x' is not well formed
148 148 tip 8:c4be69a18c11
149 149 first 0:acb14030fe0a
150 150 $ hg tip
151 151 changeset: 8:c4be69a18c11
152 152 tag: tip
153 153 parent: 3:ac5e980c4dc0
154 154 user: test
155 155 date: Thu Jan 01 00:00:00 1970 +0000
156 156 summary: head
157 157
158 158
159 159 Test tag precedence rules:
160 160
161 161 $ cd ..
162 162 $ hg init t2
163 163 $ cd t2
164 164 $ echo foo > foo
165 165 $ hg add foo
166 166 $ hg ci -m 'add foo' # rev 0
167 167 $ hg tag bar # rev 1
168 168 $ echo >> foo
169 169 $ hg ci -m 'change foo 1' # rev 2
170 170 $ hg up -C 1
171 171 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
172 172 $ hg tag -r 1 -f bar # rev 3
173 173 $ hg up -C 1
174 174 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
175 175 $ echo >> foo
176 176 $ hg ci -m 'change foo 2' # rev 4
177 177 created new head
178 178 $ hg tags
179 179 tip 4:0c192d7d5e6b
180 180 bar 1:78391a272241
181 181
182 182 Repeat in case of cache effects:
183 183
184 184 $ hg tags
185 185 tip 4:0c192d7d5e6b
186 186 bar 1:78391a272241
187 187
188 188 Detailed dump of tag info:
189 189
190 190 $ hg heads -q # expect 4, 3, 2
191 191 4:0c192d7d5e6b
192 192 3:6fa450212aeb
193 193 2:7a94127795a3
194 194 $ dumptags 2
195 195 rev 2: .hgtags:
196 196 bbd179dfa0a71671c253b3ae0aa1513b60d199fa bar
197 197 $ dumptags 3
198 198 rev 3: .hgtags:
199 199 bbd179dfa0a71671c253b3ae0aa1513b60d199fa bar
200 200 bbd179dfa0a71671c253b3ae0aa1513b60d199fa bar
201 201 78391a272241d70354aa14c874552cad6b51bb42 bar
202 202 $ dumptags 4
203 203 rev 4: .hgtags:
204 204 bbd179dfa0a71671c253b3ae0aa1513b60d199fa bar
205 205
206 206 Dump cache:
207 207
208 208 $ cat .hg/tags.cache
209 209 4 0c192d7d5e6b78a714de54a2e9627952a877e25a 0c04f2a8af31de17fab7422878ee5a2dadbc943d
210 210 3 6fa450212aeb2a21ed616a54aea39a4a27894cd7 7d3b718c964ef37b89e550ebdafd5789e76ce1b0
211 211 2 7a94127795a33c10a370c93f731fd9fea0b79af6 0c04f2a8af31de17fab7422878ee5a2dadbc943d
212 212
213 213 78391a272241d70354aa14c874552cad6b51bb42 bar
214 214
215 215 Test tag removal:
216 216
217 217 $ hg tag --remove bar # rev 5
218 218 $ hg tip -vp
219 219 changeset: 5:5f6e8655b1c7
220 220 tag: tip
221 221 user: test
222 222 date: Thu Jan 01 00:00:00 1970 +0000
223 223 files: .hgtags
224 224 description:
225 225 Removed tag bar
226 226
227 227
228 228 diff -r 0c192d7d5e6b -r 5f6e8655b1c7 .hgtags
229 229 --- a/.hgtags Thu Jan 01 00:00:00 1970 +0000
230 230 +++ b/.hgtags Thu Jan 01 00:00:00 1970 +0000
231 231 @@ -1,1 +1,3 @@
232 232 bbd179dfa0a71671c253b3ae0aa1513b60d199fa bar
233 233 +78391a272241d70354aa14c874552cad6b51bb42 bar
234 234 +0000000000000000000000000000000000000000 bar
235 235
236 236 $ hg tags
237 237 tip 5:5f6e8655b1c7
238 238 $ hg tags # again, try to expose cache bugs
239 239 tip 5:5f6e8655b1c7
240 240
241 241 Remove nonexistent tag:
242 242
243 243 $ hg tag --remove foobar
244 244 abort: tag 'foobar' does not exist
245 245 [255]
246 246 $ hg tip
247 247 changeset: 5:5f6e8655b1c7
248 248 tag: tip
249 249 user: test
250 250 date: Thu Jan 01 00:00:00 1970 +0000
251 251 summary: Removed tag bar
252 252
253 253
254 254 Undo a tag with rollback:
255 255
256 256 $ hg rollback # destroy rev 5 (restore bar)
257 257 rolling back to revision 4 (undo commit)
258 258 $ hg tags
259 259 tip 4:0c192d7d5e6b
260 260 bar 1:78391a272241
261 261 $ hg tags
262 262 tip 4:0c192d7d5e6b
263 263 bar 1:78391a272241
264 264
265 265 Test tag rank:
266 266
267 267 $ cd ..
268 268 $ hg init t3
269 269 $ cd t3
270 270 $ echo foo > foo
271 271 $ hg add foo
272 272 $ hg ci -m 'add foo' # rev 0
273 273 $ hg tag -f bar # rev 1 bar -> 0
274 274 $ hg tag -f bar # rev 2 bar -> 1
275 275 $ hg tag -fr 0 bar # rev 3 bar -> 0
276 276 $ hg tag -fr 1 bar # rev 4 bar -> 1
277 277 $ hg tag -fr 0 bar # rev 5 bar -> 0
278 278 $ hg tags
279 279 tip 5:85f05169d91d
280 280 bar 0:bbd179dfa0a7
281 281 $ hg co 3
282 282 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
283 283 $ echo barbar > foo
284 284 $ hg ci -m 'change foo' # rev 6
285 285 created new head
286 286 $ hg tags
287 287 tip 6:735c3ca72986
288 288 bar 0:bbd179dfa0a7
289 289
290 290 Don't allow moving tag without -f:
291 291
292 292 $ hg tag -r 3 bar
293 293 abort: tag 'bar' already exists (use -f to force)
294 294 [255]
295 295 $ hg tags
296 296 tip 6:735c3ca72986
297 297 bar 0:bbd179dfa0a7
298 298
299 299 Strip 1: expose an old head:
300 300
301 301 $ hg --config extensions.mq= strip 5
302 302 saved backup bundle to .*
303 303 $ hg tags # partly stale cache
304 304 tip 5:735c3ca72986
305 305 bar 1:78391a272241
306 306 $ hg tags # up-to-date cache
307 307 tip 5:735c3ca72986
308 308 bar 1:78391a272241
309 309
310 310 Strip 2: destroy whole branch, no old head exposed
311 311
312 312 $ hg --config extensions.mq= strip 4
313 313 saved backup bundle to .*
314 314 $ hg tags # partly stale
315 315 tip 4:735c3ca72986
316 316 bar 0:bbd179dfa0a7
317 317 $ rm -f .hg/tags.cache
318 318 $ hg tags # cold cache
319 319 tip 4:735c3ca72986
320 320 bar 0:bbd179dfa0a7
321 321
322 322 Test tag rank with 3 heads:
323 323
324 324 $ cd ..
325 325 $ hg init t4
326 326 $ cd t4
327 327 $ echo foo > foo
328 328 $ hg add
329 329 adding foo
330 330 $ hg ci -m 'add foo' # rev 0
331 331 $ hg tag bar # rev 1 bar -> 0
332 332 $ hg tag -f bar # rev 2 bar -> 1
333 333 $ hg up -qC 0
334 334 $ hg tag -fr 2 bar # rev 3 bar -> 2
335 335 $ hg tags
336 336 tip 3:197c21bbbf2c
337 337 bar 2:6fa450212aeb
338 338 $ hg up -qC 0
339 339 $ hg tag -m 'retag rev 0' -fr 0 bar # rev 4 bar -> 0, but bar stays at 2
340 340
341 341 Bar should still point to rev 2:
342 342
343 343 $ hg tags
344 344 tip 4:3b4b14ed0202
345 345 bar 2:6fa450212aeb
346 346
347 347 Test that removing global/local tags does not get confused when trying
348 348 to remove a tag of type X which actually only exists as a type Y:
349 349
350 350 $ cd ..
351 351 $ hg init t5
352 352 $ cd t5
353 353 $ echo foo > foo
354 354 $ hg add
355 355 adding foo
356 356 $ hg ci -m 'add foo' # rev 0
357 357
358 358 $ hg tag -r 0 -l localtag
359 359 $ hg tag --remove localtag
360 360 abort: tag 'localtag' is not a global tag
361 361 [255]
362 362 $
363 363 $ hg tag -r 0 globaltag
364 364 $ hg tag --remove -l globaltag
365 365 abort: tag 'globaltag' is not a local tag
366 366 [255]
367 367 $ hg tags -v
368 368 tip 1:a0b6fe111088
369 369 localtag 0:bbd179dfa0a7 local
370 370 globaltag 0:bbd179dfa0a7
General Comments 0
You need to be logged in to leave comments. Login now