##// END OF EJS Templates
documentation: update to new filter names...
Pierre-Yves David -
r18462:593eb378 stable
parent child Browse files
Show More
@@ -1,219 +1,219 b''
1 1 # repoview.py - Filtered view of a localrepo object
2 2 #
3 3 # Copyright 2012 Pierre-Yves David <pierre-yves.david@ens-lyon.org>
4 4 # Logilab SA <contact@logilab.fr>
5 5 #
6 6 # This software may be used and distributed according to the terms of the
7 7 # GNU General Public License version 2 or any later version.
8 8
9 9 import copy
10 10 import phases
11 11 import util
12 12 import obsolete, bookmarks, revset
13 13
14 14
15 15 def hideablerevs(repo):
16 16 """Revisions candidates to be hidden
17 17
18 18 This is a standalone function to help extensions to wrap it."""
19 19 return obsolete.getrevs(repo, 'obsolete')
20 20
21 21 def computehidden(repo):
22 22 """compute the set of hidden revision to filter
23 23
24 24 During most operation hidden should be filtered."""
25 25 assert not repo.changelog.filteredrevs
26 26 hideable = hideablerevs(repo)
27 27 if hideable:
28 28 cl = repo.changelog
29 29 firsthideable = min(hideable)
30 30 revs = cl.revs(start=firsthideable)
31 31 blockers = [r for r in revset._children(repo, revs, hideable)
32 32 if r not in hideable]
33 33 for par in repo[None].parents():
34 34 blockers.append(par.rev())
35 35 for bm in bookmarks.listbookmarks(repo).values():
36 36 blockers.append(repo[bm].rev())
37 37 blocked = cl.ancestors(blockers, inclusive=True)
38 38 return frozenset(r for r in hideable if r not in blocked)
39 39 return frozenset()
40 40
41 41 def computeunserved(repo):
42 42 """compute the set of revision that should be filtered when used a server
43 43
44 44 Secret and hidden changeset should not pretend to be here."""
45 45 assert not repo.changelog.filteredrevs
46 46 # fast path in simple case to avoid impact of non optimised code
47 47 hiddens = filterrevs(repo, 'visible')
48 48 if phases.hassecret(repo):
49 49 cl = repo.changelog
50 50 secret = phases.secret
51 51 getphase = repo._phasecache.phase
52 52 first = min(cl.rev(n) for n in repo._phasecache.phaseroots[secret])
53 53 revs = cl.revs(start=first)
54 54 secrets = set(r for r in revs if getphase(repo, r) >= secret)
55 55 return frozenset(hiddens | secrets)
56 56 else:
57 57 return hiddens
58 58 return frozenset()
59 59
60 60 def computemutable(repo):
61 61 """compute the set of revision that should be filtered when used a server
62 62
63 63 Secret and hidden changeset should not pretend to be here."""
64 64 assert not repo.changelog.filteredrevs
65 65 # fast check to avoid revset call on huge repo
66 66 if util.any(repo._phasecache.phaseroots[1:]):
67 67 getphase = repo._phasecache.phase
68 68 maymutable = filterrevs(repo, 'base')
69 69 return frozenset(r for r in maymutable if getphase(repo, r))
70 70 return frozenset()
71 71
72 72 def computeimpactable(repo):
73 73 """Everything impactable by mutable revision
74 74
75 The mutable filter still have some chance to get invalidated. This will
75 The immutable filter still have some chance to get invalidated. This will
76 76 happen when:
77 77
78 78 - you garbage collect hidden changeset,
79 79 - public phase is moved backward,
80 80 - something is changed in the filtering (this could be fixed)
81 81
82 82 This filter out any mutable changeset and any public changeset that may be
83 83 impacted by something happening to a mutable revision.
84 84
85 85 This is achieved by filtered everything with a revision number egal or
86 86 higher than the first mutable changeset is filtered."""
87 87 assert not repo.changelog.filteredrevs
88 88 cl = repo.changelog
89 89 firstmutable = len(cl)
90 90 for roots in repo._phasecache.phaseroots[1:]:
91 91 if roots:
92 92 firstmutable = min(firstmutable, min(cl.rev(r) for r in roots))
93 93 # protect from nullrev root
94 94 firstmutable = max(0, firstmutable)
95 95 return frozenset(xrange(firstmutable, len(cl)))
96 96
97 97 # function to compute filtered set
98 98 filtertable = {'visible': computehidden,
99 99 'served': computeunserved,
100 100 'immutable': computemutable,
101 101 'base': computeimpactable}
102 102 ### Nearest subset relation
103 103 # Nearest subset of filter X is a filter Y so that:
104 104 # * Y is included in X,
105 105 # * X - Y is as small as possible.
106 106 # This create and ordering used for branchmap purpose.
107 107 # the ordering may be partial
108 108 subsettable = {None: 'visible',
109 109 'visible': 'served',
110 110 'served': 'immutable',
111 111 'immutable': 'base'}
112 112
113 113 def filterrevs(repo, filtername):
114 114 """returns set of filtered revision for this filter name"""
115 115 if filtername not in repo.filteredrevcache:
116 116 func = filtertable[filtername]
117 117 repo.filteredrevcache[filtername] = func(repo.unfiltered())
118 118 return repo.filteredrevcache[filtername]
119 119
120 120 class repoview(object):
121 121 """Provide a read/write view of a repo through a filtered changelog
122 122
123 123 This object is used to access a filtered version of a repository without
124 124 altering the original repository object itself. We can not alter the
125 125 original object for two main reasons:
126 126 - It prevents the use of a repo with multiple filters at the same time. In
127 127 particular when multiple threads are involved.
128 128 - It makes scope of the filtering harder to control.
129 129
130 130 This object behaves very closely to the original repository. All attribute
131 131 operations are done on the original repository:
132 132 - An access to `repoview.someattr` actually returns `repo.someattr`,
133 133 - A write to `repoview.someattr` actually sets value of `repo.someattr`,
134 134 - A deletion of `repoview.someattr` actually drops `someattr`
135 135 from `repo.__dict__`.
136 136
137 137 The only exception is the `changelog` property. It is overridden to return
138 138 a (surface) copy of `repo.changelog` with some revisions filtered. The
139 139 `filtername` attribute of the view control the revisions that need to be
140 140 filtered. (the fact the changelog is copied is an implementation detail).
141 141
142 142 Unlike attributes, this object intercepts all method calls. This means that
143 143 all methods are run on the `repoview` object with the filtered `changelog`
144 144 property. For this purpose the simple `repoview` class must be mixed with
145 145 the actual class of the repository. This ensures that the resulting
146 146 `repoview` object have the very same methods than the repo object. This
147 147 leads to the property below.
148 148
149 149 repoview.method() --> repo.__class__.method(repoview)
150 150
151 151 The inheritance has to be done dynamically because `repo` can be of any
152 152 subclasses of `localrepo`. Eg: `bundlerepo` or `httprepo`.
153 153 """
154 154
155 155 def __init__(self, repo, filtername):
156 156 object.__setattr__(self, '_unfilteredrepo', repo)
157 157 object.__setattr__(self, 'filtername', filtername)
158 158 object.__setattr__(self, '_clcachekey', None)
159 159 object.__setattr__(self, '_clcache', None)
160 160
161 161 # not a cacheproperty on purpose we shall implement a proper cache later
162 162 @property
163 163 def changelog(self):
164 164 """return a filtered version of the changeset
165 165
166 166 this changelog must not be used for writing"""
167 167 # some cache may be implemented later
168 168 unfi = self._unfilteredrepo
169 169 unfichangelog = unfi.changelog
170 170 revs = filterrevs(unfi, self.filtername)
171 171 cl = self._clcache
172 172 newkey = (len(unfichangelog), unfichangelog.tip(), hash(revs))
173 173 if cl is not None:
174 174 # we need to check curkey too for some obscure reason.
175 175 # MQ test show a corruption of the underlying repo (in _clcache)
176 176 # without change in the cachekey.
177 177 oldfilter = cl.filteredrevs
178 178 try:
179 179 cl.filterrevs = () # disable filtering for tip
180 180 curkey = (len(cl), cl.tip(), hash(oldfilter))
181 181 finally:
182 182 cl.filteredrevs = oldfilter
183 183 if newkey != self._clcachekey or newkey != curkey:
184 184 cl = None
185 185 # could have been made None by the previous if
186 186 if cl is None:
187 187 cl = copy.copy(unfichangelog)
188 188 cl.filteredrevs = revs
189 189 object.__setattr__(self, '_clcache', cl)
190 190 object.__setattr__(self, '_clcachekey', newkey)
191 191 return cl
192 192
193 193 def unfiltered(self):
194 194 """Return an unfiltered version of a repo"""
195 195 return self._unfilteredrepo
196 196
197 197 def filtered(self, name):
198 198 """Return a filtered version of a repository"""
199 199 if name == self.filtername:
200 200 return self
201 201 return self.unfiltered().filtered(name)
202 202
203 203 # everything access are forwarded to the proxied repo
204 204 def __getattr__(self, attr):
205 205 return getattr(self._unfilteredrepo, attr)
206 206
207 207 def __setattr__(self, attr, value):
208 208 return setattr(self._unfilteredrepo, attr, value)
209 209
210 210 def __delattr__(self, attr):
211 211 return delattr(self._unfilteredrepo, attr)
212 212
213 213 # The `requirement` attribut is initialiazed during __init__. But
214 214 # __getattr__ won't be called as it also exists on the class. We need
215 215 # explicit forwarding to main repo here
216 216 @property
217 217 def requirements(self):
218 218 return self._unfilteredrepo.requirements
219 219
@@ -1,1154 +1,1154 b''
1 1 $ cat <<EOF >> $HGRCPATH
2 2 > [extensions]
3 3 > keyword =
4 4 > mq =
5 5 > notify =
6 6 > record =
7 7 > transplant =
8 8 > [ui]
9 9 > interactive = true
10 10 > EOF
11 11
12 12 hide outer repo
13 13 $ hg init
14 14
15 15 Run kwdemo before [keyword] files are set up
16 16 as it would succeed without uisetup otherwise
17 17
18 18 $ hg --quiet kwdemo
19 19 [extensions]
20 20 keyword =
21 21 [keyword]
22 22 demo.txt =
23 23 [keywordset]
24 24 svn = False
25 25 [keywordmaps]
26 26 Author = {author|user}
27 27 Date = {date|utcdate}
28 28 Header = {root}/{file},v {node|short} {date|utcdate} {author|user}
29 29 Id = {file|basename},v {node|short} {date|utcdate} {author|user}
30 30 RCSFile = {file|basename},v
31 31 RCSfile = {file|basename},v
32 32 Revision = {node|short}
33 33 Source = {root}/{file},v
34 34 $Author: test $
35 35 $Date: ????/??/?? ??:??:?? $ (glob)
36 36 $Header: */demo.txt,v ???????????? ????/??/?? ??:??:?? test $ (glob)
37 37 $Id: demo.txt,v ???????????? ????/??/?? ??:??:?? test $ (glob)
38 38 $RCSFile: demo.txt,v $
39 39 $RCSfile: demo.txt,v $
40 40 $Revision: ???????????? $ (glob)
41 41 $Source: */demo.txt,v $ (glob)
42 42
43 43 $ hg --quiet kwdemo "Branch = {branches}"
44 44 [extensions]
45 45 keyword =
46 46 [keyword]
47 47 demo.txt =
48 48 [keywordset]
49 49 svn = False
50 50 [keywordmaps]
51 51 Branch = {branches}
52 52 $Branch: demobranch $
53 53
54 54 $ cat <<EOF >> $HGRCPATH
55 55 > [keyword]
56 56 > ** =
57 57 > b = ignore
58 58 > i = ignore
59 59 > [hooks]
60 60 > EOF
61 61 $ cp $HGRCPATH $HGRCPATH.nohooks
62 62 > cat <<EOF >> $HGRCPATH
63 63 > commit=
64 64 > commit.test=cp a hooktest
65 65 > EOF
66 66
67 67 $ hg init Test-bndl
68 68 $ cd Test-bndl
69 69
70 70 kwshrink should exit silently in empty/invalid repo
71 71
72 72 $ hg kwshrink
73 73
74 74 Symlinks cannot be created on Windows.
75 75 A bundle to test this was made with:
76 76 hg init t
77 77 cd t
78 78 echo a > a
79 79 ln -s a sym
80 80 hg add sym
81 81 hg ci -m addsym -u mercurial
82 82 hg bundle --base null ../test-keyword.hg
83 83
84 84 $ hg pull -u "$TESTDIR"/bundles/test-keyword.hg
85 85 pulling from *test-keyword.hg (glob)
86 86 requesting all changes
87 87 adding changesets
88 88 adding manifests
89 89 adding file changes
90 90 added 1 changesets with 1 changes to 1 files
91 91 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
92 92
93 93 $ echo 'expand $Id$' > a
94 94 $ echo 'do not process $Id:' >> a
95 95 $ echo 'xxx $' >> a
96 96 $ echo 'ignore $Id$' > b
97 97
98 98 Output files as they were created
99 99
100 100 $ cat a b
101 101 expand $Id$
102 102 do not process $Id:
103 103 xxx $
104 104 ignore $Id$
105 105
106 106 no kwfiles
107 107
108 108 $ hg kwfiles
109 109
110 110 untracked candidates
111 111
112 112 $ hg -v kwfiles --unknown
113 113 k a
114 114
115 115 Add files and check status
116 116
117 117 $ hg addremove
118 118 adding a
119 119 adding b
120 120 $ hg status
121 121 A a
122 122 A b
123 123
124 124
125 125 Default keyword expansion including commit hook
126 126 Interrupted commit should not change state or run commit hook
127 127
128 128 $ hg --debug commit
129 129 abort: empty commit message
130 130 [255]
131 131 $ hg status
132 132 A a
133 133 A b
134 134
135 135 Commit with several checks
136 136
137 137 $ hg --debug commit -mabsym -u 'User Name <user@example.com>'
138 138 a
139 139 b
140 140 overwriting a expanding keywords
141 141 running hook commit.test: cp a hooktest
142 142 committed changeset 1:ef63ca68695bc9495032c6fda1350c71e6d256e9
143 143 $ hg status
144 144 ? hooktest
145 145 $ hg debugrebuildstate
146 146 $ hg --quiet identify
147 147 ef63ca68695b
148 148
149 149 cat files in working directory with keywords expanded
150 150
151 151 $ cat a b
152 152 expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
153 153 do not process $Id:
154 154 xxx $
155 155 ignore $Id$
156 156
157 157 hg cat files and symlink, no expansion
158 158
159 159 $ hg cat sym a b && echo
160 160 expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
161 161 do not process $Id:
162 162 xxx $
163 163 ignore $Id$
164 164 a
165 165
166 166 $ diff a hooktest
167 167
168 168 $ cp $HGRCPATH.nohooks $HGRCPATH
169 169 $ rm hooktest
170 170
171 171 hg status of kw-ignored binary file starting with '\1\n'
172 172
173 173 >>> open("i", "wb").write("\1\nfoo")
174 174 $ hg -q commit -Am metasep i
175 175 $ hg status
176 176 >>> open("i", "wb").write("\1\nbar")
177 177 $ hg status
178 178 M i
179 179 $ hg -q commit -m "modify metasep" i
180 180 $ hg status --rev 2:3
181 181 M i
182 182 $ touch empty
183 183 $ hg -q commit -A -m "another file"
184 184 $ hg status -A --rev 3:4 i
185 185 C i
186 186
187 187 $ hg -q strip -n 2
188 188
189 189 Test hook execution
190 190
191 191 bundle
192 192
193 193 $ hg bundle --base null ../kw.hg
194 194 2 changesets found
195 195 $ cd ..
196 196 $ hg init Test
197 197 $ cd Test
198 198
199 199 Notify on pull to check whether keywords stay as is in email
200 200 ie. if patch.diff wrapper acts as it should
201 201
202 202 $ cat <<EOF >> $HGRCPATH
203 203 > [hooks]
204 204 > incoming.notify = python:hgext.notify.hook
205 205 > [notify]
206 206 > sources = pull
207 207 > diffstat = False
208 208 > maxsubject = 15
209 209 > [reposubs]
210 210 > * = Test
211 211 > EOF
212 212
213 213 Pull from bundle and trigger notify
214 214
215 215 $ hg pull -u ../kw.hg
216 216 pulling from ../kw.hg
217 217 requesting all changes
218 218 adding changesets
219 219 adding manifests
220 220 adding file changes
221 221 added 2 changesets with 3 changes to 3 files
222 222 Content-Type: text/plain; charset="us-ascii"
223 223 MIME-Version: 1.0
224 224 Content-Transfer-Encoding: 7bit
225 225 Date: * (glob)
226 226 Subject: changeset in...
227 227 From: mercurial
228 228 X-Hg-Notification: changeset a2392c293916
229 229 Message-Id: <hg.a2392c293916*> (glob)
230 230 To: Test
231 231
232 232 changeset a2392c293916 in $TESTTMP/Test (glob)
233 233 details: $TESTTMP/Test?cmd=changeset;node=a2392c293916
234 234 description:
235 235 addsym
236 236
237 237 diffs (6 lines):
238 238
239 239 diff -r 000000000000 -r a2392c293916 sym
240 240 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
241 241 +++ b/sym Sat Feb 09 20:25:47 2008 +0100
242 242 @@ -0,0 +1,1 @@
243 243 +a
244 244 \ No newline at end of file
245 245 Content-Type: text/plain; charset="us-ascii"
246 246 MIME-Version: 1.0
247 247 Content-Transfer-Encoding: 7bit
248 248 Date:* (glob)
249 249 Subject: changeset in...
250 250 From: User Name <user@example.com>
251 251 X-Hg-Notification: changeset ef63ca68695b
252 252 Message-Id: <hg.ef63ca68695b*> (glob)
253 253 To: Test
254 254
255 255 changeset ef63ca68695b in $TESTTMP/Test (glob)
256 256 details: $TESTTMP/Test?cmd=changeset;node=ef63ca68695b
257 257 description:
258 258 absym
259 259
260 260 diffs (12 lines):
261 261
262 262 diff -r a2392c293916 -r ef63ca68695b a
263 263 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
264 264 +++ b/a Thu Jan 01 00:00:00 1970 +0000
265 265 @@ -0,0 +1,3 @@
266 266 +expand $Id$
267 267 +do not process $Id:
268 268 +xxx $
269 269 diff -r a2392c293916 -r ef63ca68695b b
270 270 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
271 271 +++ b/b Thu Jan 01 00:00:00 1970 +0000
272 272 @@ -0,0 +1,1 @@
273 273 +ignore $Id$
274 274 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
275 275
276 276 $ cp $HGRCPATH.nohooks $HGRCPATH
277 277
278 278 Touch files and check with status
279 279
280 280 $ touch a b
281 281 $ hg status
282 282
283 283 Update and expand
284 284
285 285 $ rm sym a b
286 286 $ hg update -C
287 287 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
288 288 $ cat a b
289 289 expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
290 290 do not process $Id:
291 291 xxx $
292 292 ignore $Id$
293 293
294 294 Check whether expansion is filewise and file mode is preserved
295 295
296 296 $ echo '$Id$' > c
297 297 $ echo 'tests for different changenodes' >> c
298 298 #if unix-permissions
299 299 $ chmod 600 c
300 300 $ ls -l c | cut -b 1-10
301 301 -rw-------
302 302 #endif
303 303
304 304 commit file c
305 305
306 306 $ hg commit -A -mcndiff -d '1 0' -u 'User Name <user@example.com>'
307 307 adding c
308 308 #if unix-permissions
309 309 $ ls -l c | cut -b 1-10
310 310 -rw-------
311 311 #endif
312 312
313 313 force expansion
314 314
315 315 $ hg -v kwexpand
316 316 overwriting a expanding keywords
317 317 overwriting c expanding keywords
318 318
319 319 compare changenodes in a and c
320 320
321 321 $ cat a c
322 322 expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
323 323 do not process $Id:
324 324 xxx $
325 325 $Id: c,v 40a904bbbe4c 1970/01/01 00:00:01 user $
326 326 tests for different changenodes
327 327
328 328 record
329 329
330 330 $ echo '$Id$' > r
331 331 $ hg add r
332 332
333 333 record chunk
334 334
335 335 >>> lines = open('a', 'rb').readlines()
336 336 >>> lines.insert(1, 'foo\n')
337 337 >>> lines.append('bar\n')
338 338 >>> open('a', 'wb').writelines(lines)
339 339 $ hg record -d '10 1' -m rectest a<<EOF
340 340 > y
341 341 > y
342 342 > n
343 343 > EOF
344 344 diff --git a/a b/a
345 345 2 hunks, 2 lines changed
346 346 examine changes to 'a'? [Ynesfdaq?]
347 347 @@ -1,3 +1,4 @@
348 348 expand $Id$
349 349 +foo
350 350 do not process $Id:
351 351 xxx $
352 352 record change 1/2 to 'a'? [Ynesfdaq?]
353 353 @@ -2,2 +3,3 @@
354 354 do not process $Id:
355 355 xxx $
356 356 +bar
357 357 record change 2/2 to 'a'? [Ynesfdaq?]
358 358
359 359 $ hg identify
360 360 5f5eb23505c3+ tip
361 361 $ hg status
362 362 M a
363 363 A r
364 364
365 365 Cat modified file a
366 366
367 367 $ cat a
368 368 expand $Id: a,v 5f5eb23505c3 1970/01/01 00:00:10 test $
369 369 foo
370 370 do not process $Id:
371 371 xxx $
372 372 bar
373 373
374 374 Diff remaining chunk
375 375
376 376 $ hg diff a
377 377 diff -r 5f5eb23505c3 a
378 378 --- a/a Thu Jan 01 00:00:09 1970 -0000
379 379 +++ b/a * (glob)
380 380 @@ -2,3 +2,4 @@
381 381 foo
382 382 do not process $Id:
383 383 xxx $
384 384 +bar
385 385
386 386 $ hg rollback
387 387 repository tip rolled back to revision 2 (undo commit)
388 388 working directory now based on revision 2
389 389
390 390 Record all chunks in file a
391 391
392 392 $ echo foo > msg
393 393
394 394 - do not use "hg record -m" here!
395 395
396 396 $ hg record -l msg -d '11 1' a<<EOF
397 397 > y
398 398 > y
399 399 > y
400 400 > EOF
401 401 diff --git a/a b/a
402 402 2 hunks, 2 lines changed
403 403 examine changes to 'a'? [Ynesfdaq?]
404 404 @@ -1,3 +1,4 @@
405 405 expand $Id$
406 406 +foo
407 407 do not process $Id:
408 408 xxx $
409 409 record change 1/2 to 'a'? [Ynesfdaq?]
410 410 @@ -2,2 +3,3 @@
411 411 do not process $Id:
412 412 xxx $
413 413 +bar
414 414 record change 2/2 to 'a'? [Ynesfdaq?]
415 415
416 416 File a should be clean
417 417
418 418 $ hg status -A a
419 419 C a
420 420
421 421 rollback and revert expansion
422 422
423 423 $ cat a
424 424 expand $Id: a,v 78e0a02d76aa 1970/01/01 00:00:11 test $
425 425 foo
426 426 do not process $Id:
427 427 xxx $
428 428 bar
429 429 $ hg --verbose rollback
430 430 repository tip rolled back to revision 2 (undo commit)
431 431 working directory now based on revision 2
432 432 overwriting a expanding keywords
433 433 $ hg status a
434 434 M a
435 435 $ cat a
436 436 expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
437 437 foo
438 438 do not process $Id:
439 439 xxx $
440 440 bar
441 441 $ echo '$Id$' > y
442 442 $ echo '$Id$' > z
443 443 $ hg add y
444 444 $ hg commit -Am "rollback only" z
445 445 $ cat z
446 446 $Id: z,v 45a5d3adce53 1970/01/01 00:00:00 test $
447 447 $ hg --verbose rollback
448 448 repository tip rolled back to revision 2 (undo commit)
449 449 working directory now based on revision 2
450 450 overwriting z shrinking keywords
451 451
452 452 Only z should be overwritten
453 453
454 454 $ hg status a y z
455 455 M a
456 456 A y
457 457 A z
458 458 $ cat z
459 459 $Id$
460 460 $ hg forget y z
461 461 $ rm y z
462 462
463 463 record added file alone
464 464
465 465 $ hg -v record -l msg -d '12 2' r<<EOF
466 466 > y
467 467 > EOF
468 468 diff --git a/r b/r
469 469 new file mode 100644
470 470 examine changes to 'r'? [Ynesfdaq?]
471 471 r
472 472 committed changeset 3:82a2f715724d
473 473 overwriting r expanding keywords
474 474 - status call required for dirstate.normallookup() check
475 475 $ hg status r
476 476 $ hg --verbose rollback
477 477 repository tip rolled back to revision 2 (undo commit)
478 478 working directory now based on revision 2
479 479 overwriting r shrinking keywords
480 480 $ hg forget r
481 481 $ rm msg r
482 482 $ hg update -C
483 483 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
484 484
485 485 record added keyword ignored file
486 486
487 487 $ echo '$Id$' > i
488 488 $ hg add i
489 489 $ hg --verbose record -d '13 1' -m recignored<<EOF
490 490 > y
491 491 > EOF
492 492 diff --git a/i b/i
493 493 new file mode 100644
494 494 examine changes to 'i'? [Ynesfdaq?]
495 495 i
496 496 committed changeset 3:9f40ceb5a072
497 497 $ cat i
498 498 $Id$
499 499 $ hg -q rollback
500 500 $ hg forget i
501 501 $ rm i
502 502
503 503 amend
504 504
505 505 $ echo amend >> a
506 506 $ echo amend >> b
507 507 $ hg -q commit -d '14 1' -m 'prepare amend'
508 508
509 509 $ hg --debug commit --amend -d '15 1' -m 'amend without changes' | grep keywords
510 510 invalid branchheads cache (served): tip differs
511 511 overwriting a expanding keywords
512 512 $ hg -q id
513 513 67d8c481a6be
514 514 $ head -1 a
515 515 expand $Id: a,v 67d8c481a6be 1970/01/01 00:00:15 test $
516 516
517 517 $ hg -q strip -n tip
518 518
519 519 Test patch queue repo
520 520
521 521 $ hg init --mq
522 522 $ hg qimport -r tip -n mqtest.diff
523 523 $ hg commit --mq -m mqtest
524 524
525 525 Keywords should not be expanded in patch
526 526
527 527 $ cat .hg/patches/mqtest.diff
528 528 # HG changeset patch
529 529 # User User Name <user@example.com>
530 530 # Date 1 0
531 531 # Node ID 40a904bbbe4cd4ab0a1f28411e35db26341a40ad
532 532 # Parent ef63ca68695bc9495032c6fda1350c71e6d256e9
533 533 cndiff
534 534
535 535 diff -r ef63ca68695b -r 40a904bbbe4c c
536 536 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
537 537 +++ b/c Thu Jan 01 00:00:01 1970 +0000
538 538 @@ -0,0 +1,2 @@
539 539 +$Id$
540 540 +tests for different changenodes
541 541
542 542 $ hg qpop
543 543 popping mqtest.diff
544 544 patch queue now empty
545 545
546 546 qgoto, implying qpush, should expand
547 547
548 548 $ hg qgoto mqtest.diff
549 549 applying mqtest.diff
550 550 now at: mqtest.diff
551 551 $ cat c
552 552 $Id: c,v 40a904bbbe4c 1970/01/01 00:00:01 user $
553 553 tests for different changenodes
554 554 $ hg cat c
555 555 $Id: c,v 40a904bbbe4c 1970/01/01 00:00:01 user $
556 556 tests for different changenodes
557 557
558 558 Keywords should not be expanded in filelog
559 559
560 560 $ hg --config 'extensions.keyword=!' cat c
561 561 $Id$
562 562 tests for different changenodes
563 563
564 564 qpop and move on
565 565
566 566 $ hg qpop
567 567 popping mqtest.diff
568 568 patch queue now empty
569 569
570 570 Copy and show added kwfiles
571 571
572 572 $ hg cp a c
573 573 $ hg kwfiles
574 574 a
575 575 c
576 576
577 577 Commit and show expansion in original and copy
578 578
579 579 $ hg --debug commit -ma2c -d '1 0' -u 'User Name <user@example.com>'
580 580 invalid branchheads cache (served): tip differs
581 581 c
582 582 c: copy a:0045e12f6c5791aac80ca6cbfd97709a88307292
583 583 invalid branchheads cache (served): tip differs
584 584 overwriting c expanding keywords
585 585 committed changeset 2:25736cf2f5cbe41f6be4e6784ef6ecf9f3bbcc7d
586 586 $ cat a c
587 587 expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
588 588 do not process $Id:
589 589 xxx $
590 590 expand $Id: c,v 25736cf2f5cb 1970/01/01 00:00:01 user $
591 591 do not process $Id:
592 592 xxx $
593 593
594 594 Touch copied c and check its status
595 595
596 596 $ touch c
597 597 $ hg status
598 598
599 599 Copy kwfile to keyword ignored file unexpanding keywords
600 600
601 601 $ hg --verbose copy a i
602 602 copying a to i
603 603 overwriting i shrinking keywords
604 604 $ head -n 1 i
605 605 expand $Id$
606 606 $ hg forget i
607 607 $ rm i
608 608
609 609 Copy ignored file to ignored file: no overwriting
610 610
611 611 $ hg --verbose copy b i
612 612 copying b to i
613 613 $ hg forget i
614 614 $ rm i
615 615
616 616 cp symlink file; hg cp -A symlink file (part1)
617 617 - copied symlink points to kwfile: overwrite
618 618
619 619 #if symlink
620 620 $ cp sym i
621 621 $ ls -l i
622 622 -rw-r--r--* (glob)
623 623 $ head -1 i
624 624 expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
625 625 $ hg copy --after --verbose sym i
626 626 copying sym to i
627 627 overwriting i shrinking keywords
628 628 $ head -1 i
629 629 expand $Id$
630 630 $ hg forget i
631 631 $ rm i
632 632 #endif
633 633
634 634 Test different options of hg kwfiles
635 635
636 636 $ hg kwfiles
637 637 a
638 638 c
639 639 $ hg -v kwfiles --ignore
640 640 I b
641 641 I sym
642 642 $ hg kwfiles --all
643 643 K a
644 644 K c
645 645 I b
646 646 I sym
647 647
648 648 Diff specific revision
649 649
650 650 $ hg diff --rev 1
651 651 diff -r ef63ca68695b c
652 652 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
653 653 +++ b/c * (glob)
654 654 @@ -0,0 +1,3 @@
655 655 +expand $Id$
656 656 +do not process $Id:
657 657 +xxx $
658 658
659 659 Status after rollback:
660 660
661 661 $ hg rollback
662 662 repository tip rolled back to revision 1 (undo commit)
663 663 working directory now based on revision 1
664 664 $ hg status
665 665 A c
666 666 $ hg update --clean
667 667 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
668 668
669 669 #if symlink
670 670
671 671 cp symlink file; hg cp -A symlink file (part2)
672 672 - copied symlink points to kw ignored file: do not overwrite
673 673
674 674 $ cat a > i
675 675 $ ln -s i symignored
676 676 $ hg commit -Am 'fake expansion in ignored and symlink' i symignored
677 677 $ cp symignored x
678 678 $ hg copy --after --verbose symignored x
679 679 copying symignored to x
680 680 $ head -n 1 x
681 681 expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
682 682 $ hg forget x
683 683 $ rm x
684 684
685 685 $ hg rollback
686 686 repository tip rolled back to revision 1 (undo commit)
687 687 working directory now based on revision 1
688 688 $ hg update --clean
689 689 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
690 690 $ rm i symignored
691 691
692 692 #endif
693 693
694 694 Custom keywordmaps as argument to kwdemo
695 695
696 696 $ hg --quiet kwdemo "Xinfo = {author}: {desc}"
697 697 [extensions]
698 698 keyword =
699 699 [keyword]
700 700 ** =
701 701 b = ignore
702 702 demo.txt =
703 703 i = ignore
704 704 [keywordset]
705 705 svn = False
706 706 [keywordmaps]
707 707 Xinfo = {author}: {desc}
708 708 $Xinfo: test: hg keyword configuration and expansion example $
709 709
710 710 Configure custom keywordmaps
711 711
712 712 $ cat <<EOF >>$HGRCPATH
713 713 > [keywordmaps]
714 714 > Id = {file} {node|short} {date|rfc822date} {author|user}
715 715 > Xinfo = {author}: {desc}
716 716 > EOF
717 717
718 718 Cat and hg cat files before custom expansion
719 719
720 720 $ cat a b
721 721 expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
722 722 do not process $Id:
723 723 xxx $
724 724 ignore $Id$
725 725 $ hg cat sym a b && echo
726 726 expand $Id: a ef63ca68695b Thu, 01 Jan 1970 00:00:00 +0000 user $
727 727 do not process $Id:
728 728 xxx $
729 729 ignore $Id$
730 730 a
731 731
732 732 Write custom keyword and prepare multi-line commit message
733 733
734 734 $ echo '$Xinfo$' >> a
735 735 $ cat <<EOF >> log
736 736 > firstline
737 737 > secondline
738 738 > EOF
739 739
740 740 Interrupted commit should not change state
741 741
742 742 $ hg commit
743 743 abort: empty commit message
744 744 [255]
745 745 $ hg status
746 746 M a
747 747 ? c
748 748 ? log
749 749
750 750 Commit with multi-line message and custom expansion
751 751
752 752 |Note:
753 753 |
754 | After the last rollback, the "unserved" branchheads cache became invalid, but
754 | After the last rollback, the "served" branchheads cache became invalid, but
755 755 | all changesets in the repo were public. For filtering this means:
756 | "mutable" == "unserved" == ΓΈ.
756 | "immutable" == "served" == ΓΈ.
757 757 |
758 | As the "unserved" cache is invalid, we fall back to the "mutable" cache. But
759 | no update is needed between "mutable" and "unserved" and the "unserved" cache
758 | As the "served" cache is invalid, we fall back to the "immutable" cache. But
759 | no update is needed between "immutable" and "served" and the "served" cache
760 760 | is not updated on disk. The on-disk version therefore stays invalid for some
761 | time. This explains why the "unserved" branchheads cache is detected as
761 | time. This explains why the "served" branchheads cache is detected as
762 762 | invalid here.
763 763
764 764 $ hg --debug commit -l log -d '2 0' -u 'User Name <user@example.com>'
765 765 invalid branchheads cache (served): tip differs
766 766 a
767 767 invalid branchheads cache (served): tip differs
768 768 overwriting a expanding keywords
769 769 committed changeset 2:bb948857c743469b22bbf51f7ec8112279ca5d83
770 770 $ rm log
771 771
772 772 Stat, verify and show custom expansion (firstline)
773 773
774 774 $ hg status
775 775 ? c
776 776 $ hg verify
777 777 checking changesets
778 778 checking manifests
779 779 crosschecking files in changesets and manifests
780 780 checking files
781 781 3 files, 3 changesets, 4 total revisions
782 782 $ cat a b
783 783 expand $Id: a bb948857c743 Thu, 01 Jan 1970 00:00:02 +0000 user $
784 784 do not process $Id:
785 785 xxx $
786 786 $Xinfo: User Name <user@example.com>: firstline $
787 787 ignore $Id$
788 788 $ hg cat sym a b && echo
789 789 expand $Id: a bb948857c743 Thu, 01 Jan 1970 00:00:02 +0000 user $
790 790 do not process $Id:
791 791 xxx $
792 792 $Xinfo: User Name <user@example.com>: firstline $
793 793 ignore $Id$
794 794 a
795 795
796 796 annotate
797 797
798 798 $ hg annotate a
799 799 1: expand $Id$
800 800 1: do not process $Id:
801 801 1: xxx $
802 802 2: $Xinfo$
803 803
804 804 remove with status checks
805 805
806 806 $ hg debugrebuildstate
807 807 $ hg remove a
808 808 $ hg --debug commit -m rma
809 809 committed changeset 3:d14c712653769de926994cf7fbb06c8fbd68f012
810 810 $ hg status
811 811 ? c
812 812
813 813 Rollback, revert, and check expansion
814 814
815 815 $ hg rollback
816 816 repository tip rolled back to revision 2 (undo commit)
817 817 working directory now based on revision 2
818 818 $ hg status
819 819 R a
820 820 ? c
821 821 $ hg revert --no-backup --rev tip a
822 822 $ cat a
823 823 expand $Id: a bb948857c743 Thu, 01 Jan 1970 00:00:02 +0000 user $
824 824 do not process $Id:
825 825 xxx $
826 826 $Xinfo: User Name <user@example.com>: firstline $
827 827
828 828 Clone to test global and local configurations
829 829
830 830 $ cd ..
831 831
832 832 Expansion in destination with global configuration
833 833
834 834 $ hg --quiet clone Test globalconf
835 835 $ cat globalconf/a
836 836 expand $Id: a bb948857c743 Thu, 01 Jan 1970 00:00:02 +0000 user $
837 837 do not process $Id:
838 838 xxx $
839 839 $Xinfo: User Name <user@example.com>: firstline $
840 840
841 841 No expansion in destination with local configuration in origin only
842 842
843 843 $ hg --quiet --config 'keyword.**=ignore' clone Test localconf
844 844 $ cat localconf/a
845 845 expand $Id$
846 846 do not process $Id:
847 847 xxx $
848 848 $Xinfo$
849 849
850 850 Clone to test incoming
851 851
852 852 $ hg clone -r1 Test Test-a
853 853 adding changesets
854 854 adding manifests
855 855 adding file changes
856 856 added 2 changesets with 3 changes to 3 files
857 857 updating to branch default
858 858 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
859 859 $ cd Test-a
860 860 $ cat <<EOF >> .hg/hgrc
861 861 > [paths]
862 862 > default = ../Test
863 863 > EOF
864 864 $ hg incoming
865 865 comparing with $TESTTMP/Test (glob)
866 866 searching for changes
867 867 changeset: 2:bb948857c743
868 868 tag: tip
869 869 user: User Name <user@example.com>
870 870 date: Thu Jan 01 00:00:02 1970 +0000
871 871 summary: firstline
872 872
873 873 Imported patch should not be rejected
874 874
875 875 >>> import re
876 876 >>> text = re.sub(r'(Id.*)', r'\1 rejecttest', open('a').read())
877 877 >>> open('a', 'wb').write(text)
878 878 $ hg --debug commit -m'rejects?' -d '3 0' -u 'User Name <user@example.com>'
879 879 a
880 880 overwriting a expanding keywords
881 881 committed changeset 2:85e279d709ffc28c9fdd1b868570985fc3d87082
882 882 $ hg export -o ../rejecttest.diff tip
883 883 $ cd ../Test
884 884 $ hg import ../rejecttest.diff
885 885 applying ../rejecttest.diff
886 886 $ cat a b
887 887 expand $Id: a 4e0994474d25 Thu, 01 Jan 1970 00:00:03 +0000 user $ rejecttest
888 888 do not process $Id: rejecttest
889 889 xxx $
890 890 $Xinfo: User Name <user@example.com>: rejects? $
891 891 ignore $Id$
892 892
893 893 $ hg rollback
894 894 repository tip rolled back to revision 2 (undo import)
895 895 working directory now based on revision 2
896 896 $ hg update --clean
897 897 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
898 898
899 899 kwexpand/kwshrink on selected files
900 900
901 901 $ mkdir x
902 902 $ hg copy a x/a
903 903 $ hg --verbose kwshrink a
904 904 overwriting a shrinking keywords
905 905 - sleep required for dirstate.normal() check
906 906 $ sleep 1
907 907 $ hg status a
908 908 $ hg --verbose kwexpand a
909 909 overwriting a expanding keywords
910 910 $ hg status a
911 911
912 912 kwexpand x/a should abort
913 913
914 914 $ hg --verbose kwexpand x/a
915 915 abort: outstanding uncommitted changes
916 916 [255]
917 917 $ cd x
918 918 $ hg --debug commit -m xa -d '3 0' -u 'User Name <user@example.com>'
919 919 x/a
920 920 x/a: copy a:779c764182ce5d43e2b1eb66ce06d7b47bfe342e
921 921 overwriting x/a expanding keywords
922 922 committed changeset 3:b4560182a3f9a358179fd2d835c15e9da379c1e4
923 923 $ cat a
924 924 expand $Id: x/a b4560182a3f9 Thu, 01 Jan 1970 00:00:03 +0000 user $
925 925 do not process $Id:
926 926 xxx $
927 927 $Xinfo: User Name <user@example.com>: xa $
928 928
929 929 kwshrink a inside directory x
930 930
931 931 $ hg --verbose kwshrink a
932 932 overwriting x/a shrinking keywords
933 933 $ cat a
934 934 expand $Id$
935 935 do not process $Id:
936 936 xxx $
937 937 $Xinfo$
938 938 $ cd ..
939 939
940 940 kwexpand nonexistent
941 941
942 942 $ hg kwexpand nonexistent
943 943 nonexistent:* (glob)
944 944
945 945
946 946 #if serve
947 947 hg serve
948 948 - expand with hgweb file
949 949 - no expansion with hgweb annotate/changeset/filediff
950 950 - check errors
951 951
952 952 $ hg serve -p $HGPORT -d --pid-file=hg.pid -A access.log -E errors.log
953 953 $ cat hg.pid >> $DAEMON_PIDS
954 954 $ "$TESTDIR/get-with-headers.py" localhost:$HGPORT 'file/tip/a/?style=raw'
955 955 200 Script output follows
956 956
957 957 expand $Id: a bb948857c743 Thu, 01 Jan 1970 00:00:02 +0000 user $
958 958 do not process $Id:
959 959 xxx $
960 960 $Xinfo: User Name <user@example.com>: firstline $
961 961 $ "$TESTDIR/get-with-headers.py" localhost:$HGPORT 'annotate/tip/a/?style=raw'
962 962 200 Script output follows
963 963
964 964
965 965 user@1: expand $Id$
966 966 user@1: do not process $Id:
967 967 user@1: xxx $
968 968 user@2: $Xinfo$
969 969
970 970
971 971
972 972
973 973 $ "$TESTDIR/get-with-headers.py" localhost:$HGPORT 'rev/tip/?style=raw'
974 974 200 Script output follows
975 975
976 976
977 977 # HG changeset patch
978 978 # User User Name <user@example.com>
979 979 # Date 3 0
980 980 # Node ID b4560182a3f9a358179fd2d835c15e9da379c1e4
981 981 # Parent bb948857c743469b22bbf51f7ec8112279ca5d83
982 982 xa
983 983
984 984 diff -r bb948857c743 -r b4560182a3f9 x/a
985 985 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
986 986 +++ b/x/a Thu Jan 01 00:00:03 1970 +0000
987 987 @@ -0,0 +1,4 @@
988 988 +expand $Id$
989 989 +do not process $Id:
990 990 +xxx $
991 991 +$Xinfo$
992 992
993 993 $ "$TESTDIR/get-with-headers.py" localhost:$HGPORT 'diff/bb948857c743/a?style=raw'
994 994 200 Script output follows
995 995
996 996
997 997 diff -r ef63ca68695b -r bb948857c743 a
998 998 --- a/a Thu Jan 01 00:00:00 1970 +0000
999 999 +++ b/a Thu Jan 01 00:00:02 1970 +0000
1000 1000 @@ -1,3 +1,4 @@
1001 1001 expand $Id$
1002 1002 do not process $Id:
1003 1003 xxx $
1004 1004 +$Xinfo$
1005 1005
1006 1006
1007 1007
1008 1008
1009 1009 $ cat errors.log
1010 1010 #endif
1011 1011
1012 1012 Prepare merge and resolve tests
1013 1013
1014 1014 $ echo '$Id$' > m
1015 1015 $ hg add m
1016 1016 $ hg commit -m 4kw
1017 1017 $ echo foo >> m
1018 1018 $ hg commit -m 5foo
1019 1019
1020 1020 simplemerge
1021 1021
1022 1022 $ hg update 4
1023 1023 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1024 1024 $ echo foo >> m
1025 1025 $ hg commit -m 6foo
1026 1026 created new head
1027 1027 $ hg merge
1028 1028 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
1029 1029 (branch merge, don't forget to commit)
1030 1030 $ hg commit -m simplemerge
1031 1031 $ cat m
1032 1032 $Id: m 27d48ee14f67 Thu, 01 Jan 1970 00:00:00 +0000 test $
1033 1033 foo
1034 1034
1035 1035 conflict: keyword should stay outside conflict zone
1036 1036
1037 1037 $ hg update 4
1038 1038 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1039 1039 $ echo bar >> m
1040 1040 $ hg commit -m 8bar
1041 1041 created new head
1042 1042 $ hg merge
1043 1043 merging m
1044 1044 warning: conflicts during merge.
1045 1045 merging m incomplete! (edit conflicts, then use 'hg resolve --mark')
1046 1046 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
1047 1047 use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon
1048 1048 [1]
1049 1049 $ cat m
1050 1050 $Id$
1051 1051 <<<<<<< local
1052 1052 bar
1053 1053 =======
1054 1054 foo
1055 1055 >>>>>>> other
1056 1056
1057 1057 resolve to local
1058 1058
1059 1059 $ HGMERGE=internal:local hg resolve -a
1060 1060 $ hg commit -m localresolve
1061 1061 $ cat m
1062 1062 $Id: m 800511b3a22d Thu, 01 Jan 1970 00:00:00 +0000 test $
1063 1063 bar
1064 1064
1065 1065 Test restricted mode with transplant -b
1066 1066
1067 1067 $ hg update 6
1068 1068 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1069 1069 $ hg branch foo
1070 1070 marked working directory as branch foo
1071 1071 (branches are permanent and global, did you want a bookmark?)
1072 1072 $ mv a a.bak
1073 1073 $ echo foobranch > a
1074 1074 $ cat a.bak >> a
1075 1075 $ rm a.bak
1076 1076 $ hg commit -m 9foobranch
1077 1077 $ hg update default
1078 1078 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
1079 1079 $ hg -y transplant -b foo tip
1080 1080 applying 4aa30d025d50
1081 1081 4aa30d025d50 transplanted to e00abbf63521
1082 1082
1083 1083 Expansion in changeset but not in file
1084 1084
1085 1085 $ hg tip -p
1086 1086 changeset: 11:e00abbf63521
1087 1087 tag: tip
1088 1088 parent: 9:800511b3a22d
1089 1089 user: test
1090 1090 date: Thu Jan 01 00:00:00 1970 +0000
1091 1091 summary: 9foobranch
1092 1092
1093 1093 diff -r 800511b3a22d -r e00abbf63521 a
1094 1094 --- a/a Thu Jan 01 00:00:00 1970 +0000
1095 1095 +++ b/a Thu Jan 01 00:00:00 1970 +0000
1096 1096 @@ -1,3 +1,4 @@
1097 1097 +foobranch
1098 1098 expand $Id$
1099 1099 do not process $Id:
1100 1100 xxx $
1101 1101
1102 1102 $ head -n 2 a
1103 1103 foobranch
1104 1104 expand $Id: a e00abbf63521 Thu, 01 Jan 1970 00:00:00 +0000 test $
1105 1105
1106 1106 Turn off expansion
1107 1107
1108 1108 $ hg -q rollback
1109 1109 $ hg -q update -C
1110 1110
1111 1111 kwshrink with unknown file u
1112 1112
1113 1113 $ cp a u
1114 1114 $ hg --verbose kwshrink
1115 1115 overwriting a shrinking keywords
1116 1116 overwriting m shrinking keywords
1117 1117 overwriting x/a shrinking keywords
1118 1118
1119 1119 Keywords shrunk in working directory, but not yet disabled
1120 1120 - cat shows unexpanded keywords
1121 1121 - hg cat shows expanded keywords
1122 1122
1123 1123 $ cat a b
1124 1124 expand $Id$
1125 1125 do not process $Id:
1126 1126 xxx $
1127 1127 $Xinfo$
1128 1128 ignore $Id$
1129 1129 $ hg cat sym a b && echo
1130 1130 expand $Id: a bb948857c743 Thu, 01 Jan 1970 00:00:02 +0000 user $
1131 1131 do not process $Id:
1132 1132 xxx $
1133 1133 $Xinfo: User Name <user@example.com>: firstline $
1134 1134 ignore $Id$
1135 1135 a
1136 1136
1137 1137 Now disable keyword expansion
1138 1138
1139 1139 $ rm "$HGRCPATH"
1140 1140 $ cat a b
1141 1141 expand $Id$
1142 1142 do not process $Id:
1143 1143 xxx $
1144 1144 $Xinfo$
1145 1145 ignore $Id$
1146 1146 $ hg cat sym a b && echo
1147 1147 expand $Id$
1148 1148 do not process $Id:
1149 1149 xxx $
1150 1150 $Xinfo$
1151 1151 ignore $Id$
1152 1152 a
1153 1153
1154 1154 $ cd ..
@@ -1,513 +1,513 b''
1 1 $ hglog() { hg log --template "{rev} {phaseidx} {desc}\n" $*; }
2 2 $ mkcommit() {
3 3 > echo "$1" > "$1"
4 4 > hg add "$1"
5 5 > message="$1"
6 6 > shift
7 7 > hg ci -m "$message" $*
8 8 > }
9 9
10 10 $ hg init initialrepo
11 11 $ cd initialrepo
12 12
13 13 Cannot change null revision phase
14 14
15 15 $ hg phase --force --secret null
16 16 abort: cannot change null revision phase
17 17 [255]
18 18 $ hg phase null
19 19 -1: public
20 20
21 21 $ mkcommit A
22 22
23 23 New commit are draft by default
24 24
25 25 $ hglog
26 26 0 1 A
27 27
28 28 Following commit are draft too
29 29
30 30 $ mkcommit B
31 31
32 32 $ hglog
33 33 1 1 B
34 34 0 1 A
35 35
36 36 Draft commit are properly created over public one:
37 37
38 38 $ hg phase --public .
39 39 $ hglog
40 40 1 0 B
41 41 0 0 A
42 42
43 43 $ mkcommit C
44 44 $ mkcommit D
45 45
46 46 $ hglog
47 47 3 1 D
48 48 2 1 C
49 49 1 0 B
50 50 0 0 A
51 51
52 52 Test creating changeset as secret
53 53
54 54 $ mkcommit E --config phases.new-commit='secret'
55 55 $ hglog
56 56 4 2 E
57 57 3 1 D
58 58 2 1 C
59 59 1 0 B
60 60 0 0 A
61 61
62 62 Test the secret property is inherited
63 63
64 64 $ mkcommit H
65 65 $ hglog
66 66 5 2 H
67 67 4 2 E
68 68 3 1 D
69 69 2 1 C
70 70 1 0 B
71 71 0 0 A
72 72
73 73 Even on merge
74 74
75 75 $ hg up -q 1
76 76 $ mkcommit "B'"
77 77 created new head
78 78 $ hglog
79 79 6 1 B'
80 80 5 2 H
81 81 4 2 E
82 82 3 1 D
83 83 2 1 C
84 84 1 0 B
85 85 0 0 A
86 86 $ hg merge 4 # E
87 87 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
88 88 (branch merge, don't forget to commit)
89 89 $ hg ci -m "merge B' and E"
90 90 $ hglog
91 91 7 2 merge B' and E
92 92 6 1 B'
93 93 5 2 H
94 94 4 2 E
95 95 3 1 D
96 96 2 1 C
97 97 1 0 B
98 98 0 0 A
99 99
100 100 Test secret changeset are not pushed
101 101
102 102 $ hg init ../push-dest
103 103 $ cat > ../push-dest/.hg/hgrc << EOF
104 104 > [phases]
105 105 > publish=False
106 106 > EOF
107 107 $ hg outgoing ../push-dest --template='{rev} {phase} {desc|firstline}\n'
108 108 comparing with ../push-dest
109 109 searching for changes
110 110 0 public A
111 111 1 public B
112 112 2 draft C
113 113 3 draft D
114 114 6 draft B'
115 115 $ hg outgoing -r 'branch(default)' ../push-dest --template='{rev} {phase} {desc|firstline}\n'
116 116 comparing with ../push-dest
117 117 searching for changes
118 118 0 public A
119 119 1 public B
120 120 2 draft C
121 121 3 draft D
122 122 6 draft B'
123 123
124 124 $ hg push ../push-dest -f # force because we push multiple heads
125 125 pushing to ../push-dest
126 126 searching for changes
127 127 adding changesets
128 128 adding manifests
129 129 adding file changes
130 130 added 5 changesets with 5 changes to 5 files (+1 heads)
131 131 $ hglog
132 132 7 2 merge B' and E
133 133 6 1 B'
134 134 5 2 H
135 135 4 2 E
136 136 3 1 D
137 137 2 1 C
138 138 1 0 B
139 139 0 0 A
140 140 $ cd ../push-dest
141 141 $ hglog
142 142 4 1 B'
143 143 3 1 D
144 144 2 1 C
145 145 1 0 B
146 146 0 0 A
147 147
148 148 (Issue3303)
149 149 Check that remote secret changeset are ignore when checking creation of remote heads
150 150
151 151 We add a secret head into the push destination. This secreat head shadow a
152 152 visible shared between the initial repo and the push destination.
153 153
154 154 $ hg up -q 4 # B'
155 155 $ mkcommit Z --config phases.new-commit=secret
156 156 $ hg phase .
157 157 5: secret
158 158
159 159 # We now try to push a new public changeset that descend from the common public
160 160 # head shadowed by the remote secret head.
161 161
162 162 $ cd ../initialrepo
163 163 $ hg up -q 6 #B'
164 164 $ mkcommit I
165 165 created new head
166 166 $ hg push ../push-dest
167 167 pushing to ../push-dest
168 168 searching for changes
169 169 adding changesets
170 170 adding manifests
171 171 adding file changes
172 172 added 1 changesets with 1 changes to 1 files (+1 heads)
173 173
174 174 :note: The "(+1 heads)" is wrong as we do not had any visible head
175 175
176 check that branch cache with "unserved" filter are properly computed and stored
176 check that branch cache with "served" filter are properly computed and stored
177 177
178 178 $ ls ../push-dest/.hg/cache/branchheads*
179 179 ../push-dest/.hg/cache/branchheads-served
180 180 $ cat ../push-dest/.hg/cache/branchheads-served
181 181 6d6770faffce199f1fddd1cf87f6f026138cf061 6 465891ffab3c47a3c23792f7dc84156e19a90722
182 182 b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e default
183 183 6d6770faffce199f1fddd1cf87f6f026138cf061 default
184 184 $ hg heads -R ../push-dest --template '{rev}:{node} {phase}\n' #update visible cache too
185 185 6:6d6770faffce199f1fddd1cf87f6f026138cf061 draft
186 186 5:2713879da13d6eea1ff22b442a5a87cb31a7ce6a secret
187 187 3:b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e draft
188 188 $ ls ../push-dest/.hg/cache/branchheads*
189 189 ../push-dest/.hg/cache/branchheads-served
190 190 ../push-dest/.hg/cache/branchheads-visible
191 191 $ cat ../push-dest/.hg/cache/branchheads-served
192 192 6d6770faffce199f1fddd1cf87f6f026138cf061 6 465891ffab3c47a3c23792f7dc84156e19a90722
193 193 b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e default
194 194 6d6770faffce199f1fddd1cf87f6f026138cf061 default
195 195 $ cat ../push-dest/.hg/cache/branchheads-visible
196 196 6d6770faffce199f1fddd1cf87f6f026138cf061 6
197 197 b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e default
198 198 2713879da13d6eea1ff22b442a5a87cb31a7ce6a default
199 199 6d6770faffce199f1fddd1cf87f6f026138cf061 default
200 200
201 201
202 202 Restore condition prior extra insertion.
203 203 $ hg -q --config extensions.mq= strip .
204 204 $ hg up -q 7
205 205 $ cd ..
206 206
207 207 Test secret changeset are not pull
208 208
209 209 $ hg init pull-dest
210 210 $ cd pull-dest
211 211 $ hg pull ../initialrepo
212 212 pulling from ../initialrepo
213 213 requesting all changes
214 214 adding changesets
215 215 adding manifests
216 216 adding file changes
217 217 added 5 changesets with 5 changes to 5 files (+1 heads)
218 218 (run 'hg heads' to see heads, 'hg merge' to merge)
219 219 $ hglog
220 220 4 0 B'
221 221 3 0 D
222 222 2 0 C
223 223 1 0 B
224 224 0 0 A
225 225 $ cd ..
226 226
227 227 But secret can still be bundled explicitly
228 228
229 229 $ cd initialrepo
230 230 $ hg bundle --base '4^' -r 'children(4)' ../secret-bundle.hg
231 231 4 changesets found
232 232 $ cd ..
233 233
234 234 Test secret changeset are not cloned
235 235 (during local clone)
236 236
237 237 $ hg clone -qU initialrepo clone-dest
238 238 $ hglog -R clone-dest
239 239 4 0 B'
240 240 3 0 D
241 241 2 0 C
242 242 1 0 B
243 243 0 0 A
244 244
245 245 Test revset
246 246
247 247 $ cd initialrepo
248 248 $ hglog -r 'public()'
249 249 0 0 A
250 250 1 0 B
251 251 $ hglog -r 'draft()'
252 252 2 1 C
253 253 3 1 D
254 254 6 1 B'
255 255 $ hglog -r 'secret()'
256 256 4 2 E
257 257 5 2 H
258 258 7 2 merge B' and E
259 259
260 260 test that phase are displayed in log at debug level
261 261
262 262 $ hg log --debug
263 263 changeset: 7:17a481b3bccb796c0521ae97903d81c52bfee4af
264 264 tag: tip
265 265 phase: secret
266 266 parent: 6:cf9fe039dfd67e829edf6522a45de057b5c86519
267 267 parent: 4:a603bfb5a83e312131cebcd05353c217d4d21dde
268 268 manifest: 7:5e724ffacba267b2ab726c91fc8b650710deaaa8
269 269 user: test
270 270 date: Thu Jan 01 00:00:00 1970 +0000
271 271 files+: C D E
272 272 extra: branch=default
273 273 description:
274 274 merge B' and E
275 275
276 276
277 277 changeset: 6:cf9fe039dfd67e829edf6522a45de057b5c86519
278 278 phase: draft
279 279 parent: 1:27547f69f25460a52fff66ad004e58da7ad3fb56
280 280 parent: -1:0000000000000000000000000000000000000000
281 281 manifest: 6:ab8bfef2392903058bf4ebb9e7746e8d7026b27a
282 282 user: test
283 283 date: Thu Jan 01 00:00:00 1970 +0000
284 284 files+: B'
285 285 extra: branch=default
286 286 description:
287 287 B'
288 288
289 289
290 290 changeset: 5:a030c6be5127abc010fcbff1851536552e6951a8
291 291 phase: secret
292 292 parent: 4:a603bfb5a83e312131cebcd05353c217d4d21dde
293 293 parent: -1:0000000000000000000000000000000000000000
294 294 manifest: 5:5c710aa854874fe3d5fa7192e77bdb314cc08b5a
295 295 user: test
296 296 date: Thu Jan 01 00:00:00 1970 +0000
297 297 files+: H
298 298 extra: branch=default
299 299 description:
300 300 H
301 301
302 302
303 303 changeset: 4:a603bfb5a83e312131cebcd05353c217d4d21dde
304 304 phase: secret
305 305 parent: 3:b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e
306 306 parent: -1:0000000000000000000000000000000000000000
307 307 manifest: 4:7173fd1c27119750b959e3a0f47ed78abe75d6dc
308 308 user: test
309 309 date: Thu Jan 01 00:00:00 1970 +0000
310 310 files+: E
311 311 extra: branch=default
312 312 description:
313 313 E
314 314
315 315
316 316 changeset: 3:b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e
317 317 phase: draft
318 318 parent: 2:f838bfaca5c7226600ebcfd84f3c3c13a28d3757
319 319 parent: -1:0000000000000000000000000000000000000000
320 320 manifest: 3:6e1f4c47ecb533ffd0c8e52cdc88afb6cd39e20c
321 321 user: test
322 322 date: Thu Jan 01 00:00:00 1970 +0000
323 323 files+: D
324 324 extra: branch=default
325 325 description:
326 326 D
327 327
328 328
329 329 changeset: 2:f838bfaca5c7226600ebcfd84f3c3c13a28d3757
330 330 phase: draft
331 331 parent: 1:27547f69f25460a52fff66ad004e58da7ad3fb56
332 332 parent: -1:0000000000000000000000000000000000000000
333 333 manifest: 2:66a5a01817fdf5239c273802b5b7618d051c89e4
334 334 user: test
335 335 date: Thu Jan 01 00:00:00 1970 +0000
336 336 files+: C
337 337 extra: branch=default
338 338 description:
339 339 C
340 340
341 341
342 342 changeset: 1:27547f69f25460a52fff66ad004e58da7ad3fb56
343 343 parent: 0:4a2df7238c3b48766b5e22fafbb8a2f506ec8256
344 344 parent: -1:0000000000000000000000000000000000000000
345 345 manifest: 1:cb5cbbc1bfbf24cc34b9e8c16914e9caa2d2a7fd
346 346 user: test
347 347 date: Thu Jan 01 00:00:00 1970 +0000
348 348 files+: B
349 349 extra: branch=default
350 350 description:
351 351 B
352 352
353 353
354 354 changeset: 0:4a2df7238c3b48766b5e22fafbb8a2f506ec8256
355 355 parent: -1:0000000000000000000000000000000000000000
356 356 parent: -1:0000000000000000000000000000000000000000
357 357 manifest: 0:007d8c9d88841325f5c6b06371b35b4e8a2b1a83
358 358 user: test
359 359 date: Thu Jan 01 00:00:00 1970 +0000
360 360 files+: A
361 361 extra: branch=default
362 362 description:
363 363 A
364 364
365 365
366 366
367 367
368 368 (Issue3707)
369 369 test invalid phase name
370 370
371 371 $ mkcommit I --config phases.new-commit='babar'
372 372 transaction abort!
373 373 rollback completed
374 374 abort: phases.new-commit: not a valid phase name ('babar')
375 375 [255]
376 376 Test phase command
377 377 ===================
378 378
379 379 initial picture
380 380
381 381 $ cat >> $HGRCPATH << EOF
382 382 > [extensions]
383 383 > hgext.graphlog=
384 384 > EOF
385 385 $ hg log -G --template "{rev} {phase} {desc}\n"
386 386 @ 7 secret merge B' and E
387 387 |\
388 388 | o 6 draft B'
389 389 | |
390 390 +---o 5 secret H
391 391 | |
392 392 o | 4 secret E
393 393 | |
394 394 o | 3 draft D
395 395 | |
396 396 o | 2 draft C
397 397 |/
398 398 o 1 public B
399 399 |
400 400 o 0 public A
401 401
402 402
403 403 display changesets phase
404 404
405 405 (mixing -r and plain rev specification)
406 406
407 407 $ hg phase 1::4 -r 7
408 408 1: public
409 409 2: draft
410 410 3: draft
411 411 4: secret
412 412 7: secret
413 413
414 414
415 415 move changeset forward
416 416
417 417 (with -r option)
418 418
419 419 $ hg phase --public -r 2
420 420 $ hg log -G --template "{rev} {phase} {desc}\n"
421 421 @ 7 secret merge B' and E
422 422 |\
423 423 | o 6 draft B'
424 424 | |
425 425 +---o 5 secret H
426 426 | |
427 427 o | 4 secret E
428 428 | |
429 429 o | 3 draft D
430 430 | |
431 431 o | 2 public C
432 432 |/
433 433 o 1 public B
434 434 |
435 435 o 0 public A
436 436
437 437
438 438 move changeset backward
439 439
440 440 (without -r option)
441 441
442 442 $ hg phase --draft --force 2
443 443 $ hg log -G --template "{rev} {phase} {desc}\n"
444 444 @ 7 secret merge B' and E
445 445 |\
446 446 | o 6 draft B'
447 447 | |
448 448 +---o 5 secret H
449 449 | |
450 450 o | 4 secret E
451 451 | |
452 452 o | 3 draft D
453 453 | |
454 454 o | 2 draft C
455 455 |/
456 456 o 1 public B
457 457 |
458 458 o 0 public A
459 459
460 460
461 461 move changeset forward and backward
462 462
463 463 $ hg phase --draft --force 1::4
464 464 $ hg log -G --template "{rev} {phase} {desc}\n"
465 465 @ 7 secret merge B' and E
466 466 |\
467 467 | o 6 draft B'
468 468 | |
469 469 +---o 5 secret H
470 470 | |
471 471 o | 4 draft E
472 472 | |
473 473 o | 3 draft D
474 474 | |
475 475 o | 2 draft C
476 476 |/
477 477 o 1 draft B
478 478 |
479 479 o 0 public A
480 480
481 481 test partial failure
482 482
483 483 $ hg phase --public 7
484 484 $ hg phase --draft '5 or 7'
485 485 cannot move 1 changesets to a more permissive phase, use --force
486 486 phase changed for 1 changesets
487 487 [1]
488 488 $ hg log -G --template "{rev} {phase} {desc}\n"
489 489 @ 7 public merge B' and E
490 490 |\
491 491 | o 6 public B'
492 492 | |
493 493 +---o 5 draft H
494 494 | |
495 495 o | 4 public E
496 496 | |
497 497 o | 3 public D
498 498 | |
499 499 o | 2 public C
500 500 |/
501 501 o 1 public B
502 502 |
503 503 o 0 public A
504 504
505 505
506 506 test complete failure
507 507
508 508 $ hg phase --draft 7
509 509 cannot move 1 changesets to a more permissive phase, use --force
510 510 no phases changed
511 511 [1]
512 512
513 513 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now