##// END OF EJS Templates
blackbox: log working directory version...
timeless -
r28245:caa2a0c6 default
parent child Browse files
Show More
@@ -1,187 +1,205 b''
1 1 # blackbox.py - log repository events to a file for post-mortem debugging
2 2 #
3 3 # Copyright 2010 Nicolas Dumazet
4 4 # Copyright 2013 Facebook, Inc.
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 """log repository events to a blackbox for debugging
10 10
11 11 Logs event information to .hg/blackbox.log to help debug and diagnose problems.
12 12 The events that get logged can be configured via the blackbox.track config key.
13 13 Examples::
14 14
15 15 [blackbox]
16 16 track = *
17 17
18 18 [blackbox]
19 19 track = command, commandfinish, commandexception, exthook, pythonhook
20 20
21 21 [blackbox]
22 22 track = incoming
23 23
24 24 [blackbox]
25 25 # limit the size of a log file
26 26 maxsize = 1.5 MB
27 27 # rotate up to N log files when the current one gets too big
28 28 maxfiles = 3
29 29
30 30 """
31 31
32 32 from __future__ import absolute_import
33 33
34 34 import errno
35 35 import re
36 36
37 37 from mercurial.i18n import _
38 from mercurial.node import hex
39
38 40 from mercurial import (
39 41 cmdutil,
40 42 util,
41 43 )
42 44
43 45 cmdtable = {}
44 46 command = cmdutil.command(cmdtable)
45 47 # Note for extension authors: ONLY specify testedwith = 'internal' for
46 48 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
47 49 # be specifying the version(s) of Mercurial they are tested with, or
48 50 # leave the attribute unspecified.
49 51 testedwith = 'internal'
50 52 lastfp = None
51 53
52 54 filehandles = {}
53 55
54 56 def _openlog(vfs):
55 57 path = vfs.join('blackbox.log')
56 58 if path in filehandles:
57 59 return filehandles[path]
58 60 filehandles[path] = fp = vfs('blackbox.log', 'a')
59 61 return fp
60 62
61 63 def _closelog(vfs):
62 64 path = vfs.join('blackbox.log')
63 65 fp = filehandles[path]
64 66 del filehandles[path]
65 67 fp.close()
66 68
69 def hexfn(node):
70 if node is None:
71 return None
72 else:
73 return hex(node)
74
67 75 def wrapui(ui):
68 76 class blackboxui(ui.__class__):
69 77 @util.propertycache
70 78 def track(self):
71 79 return self.configlist('blackbox', 'track', ['*'])
72 80
73 81 def _openlogfile(self):
74 82 def rotate(oldpath, newpath):
75 83 try:
76 84 self._bbvfs.unlink(newpath)
77 85 except OSError as err:
78 86 if err.errno != errno.ENOENT:
79 87 self.debug("warning: cannot remove '%s': %s\n" %
80 88 (newpath, err.strerror))
81 89 try:
82 90 if newpath:
83 91 self._bbvfs.rename(oldpath, newpath)
84 92 except OSError as err:
85 93 if err.errno != errno.ENOENT:
86 94 self.debug("warning: cannot rename '%s' to '%s': %s\n" %
87 95 (newpath, oldpath, err.strerror))
88 96
89 97 fp = _openlog(self._bbvfs)
90 98 maxsize = self.configbytes('blackbox', 'maxsize', 1048576)
91 99 if maxsize > 0:
92 100 st = self._bbvfs.fstat(fp)
93 101 if st.st_size >= maxsize:
94 102 path = fp.name
95 103 _closelog(self._bbvfs)
96 104 maxfiles = self.configint('blackbox', 'maxfiles', 7)
97 105 for i in xrange(maxfiles - 1, 1, -1):
98 106 rotate(oldpath='%s.%d' % (path, i - 1),
99 107 newpath='%s.%d' % (path, i))
100 108 rotate(oldpath=path,
101 109 newpath=maxfiles > 0 and path + '.1')
102 110 fp = _openlog(self._bbvfs)
103 111 return fp
104 112
105 113 def log(self, event, *msg, **opts):
106 114 global lastfp
107 115 super(blackboxui, self).log(event, *msg, **opts)
108 116
109 117 if not '*' in self.track and not event in self.track:
110 118 return
111 119
112 120 if util.safehasattr(self, '_blackbox'):
113 121 fp = self._blackbox
114 122 elif util.safehasattr(self, '_bbvfs'):
115 123 try:
116 124 self._bbfp = self._openlogfile()
117 125 except (IOError, OSError) as err:
118 126 self.debug('warning: cannot write to blackbox.log: %s\n' %
119 127 err.strerror)
120 128 del self._bbvfs
121 129 self._bbfp = None
122 130 fp = self._bbfp
123 131 else:
124 132 # certain ui instances exist outside the context of
125 133 # a repo, so just default to the last blackbox that
126 134 # was seen.
127 135 fp = lastfp
128 136
129 137 if fp:
130 138 date = util.datestr(None, '%Y/%m/%d %H:%M:%S')
131 139 user = util.getuser()
132 140 pid = str(util.getpid())
133 141 formattedmsg = msg[0] % msg[1:]
142 rev = '(unknown)'
143 if util.safehasattr(self, '_bbrepo'):
144 ctx = self._bbrepo[None]
145 if ctx.rev() is not None:
146 rev = hexfn(ctx.node())
147 else:
148 parents = ctx.parents()
149 rev = ('+'.join([hexfn(p.node()) for p in parents]))
134 150 try:
135 fp.write('%s %s (%s)> %s' %
136 (date, user, pid, formattedmsg))
151 fp.write('%s %s @%s (%s)> %s' %
152 (date, user, rev, pid, formattedmsg))
137 153 fp.flush()
138 154 except IOError as err:
139 155 self.debug('warning: cannot write to blackbox.log: %s\n' %
140 156 err.strerror)
141 lastfp = fp
157 if not lastfp or util.safehasattr(self, '_bbrepo'):
158 lastfp = fp
142 159
143 160 def setrepo(self, repo):
144 161 self._bbvfs = repo.vfs
162 self._bbrepo = repo
145 163
146 164 ui.__class__ = blackboxui
147 165
148 166 def uisetup(ui):
149 167 wrapui(ui)
150 168
151 169 def reposetup(ui, repo):
152 170 # During 'hg pull' a httppeer repo is created to represent the remote repo.
153 171 # It doesn't have a .hg directory to put a blackbox in, so we don't do
154 172 # the blackbox setup for it.
155 173 if not repo.local():
156 174 return
157 175
158 176 if util.safehasattr(ui, 'setrepo'):
159 177 ui.setrepo(repo)
160 178
161 179 @command('^blackbox',
162 180 [('l', 'limit', 10, _('the number of events to show')),
163 181 ],
164 182 _('hg blackbox [OPTION]...'))
165 183 def blackbox(ui, repo, *revs, **opts):
166 184 '''view the recent repository events
167 185 '''
168 186
169 187 if not repo.vfs.exists('blackbox.log'):
170 188 return
171 189
172 190 limit = opts.get('limit')
173 191 fp = repo.vfs('blackbox.log', 'r')
174 192 lines = fp.read().split('\n')
175 193
176 194 count = 0
177 195 output = []
178 196 for line in reversed(lines):
179 197 if count >= limit:
180 198 break
181 199
182 200 # count the commands by matching lines like: 2013/01/23 19:13:36 root>
183 201 if re.match('^\d{4}/\d{2}/\d{2} \d{2}:\d{2}:\d{2} .*> .*', line):
184 202 count += 1
185 203 output.append(line)
186 204
187 205 ui.status('\n'.join(reversed(output)))
@@ -1,186 +1,189 b''
1 1 setup
2 2 $ cat >> $HGRCPATH <<EOF
3 3 > [extensions]
4 4 > blackbox=
5 5 > mock=$TESTDIR/mockblackbox.py
6 6 > mq=
7 7 > EOF
8 8 $ hg init blackboxtest
9 9 $ cd blackboxtest
10 10
11 11 command, exit codes, and duration
12 12
13 13 $ echo a > a
14 14 $ hg add a
15 $ hg id > /dev/null
15 16 $ hg blackbox
16 1970/01/01 00:00:00 bob (5000)> add a
17 1970/01/01 00:00:00 bob (5000)> add a exited 0 after * seconds (glob)
18 1970/01/01 00:00:00 bob (5000)> blackbox
17 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> add a
18 1970/01/01 00:00:00 bob @(unknown) (5000)> add a exited 0 after * seconds (glob)
19 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> id
20 1970/01/01 00:00:00 bob @(unknown) (5000)> id exited 0 after * seconds (glob)
21 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> blackbox
19 22
20 23 incoming change tracking
21 24
22 25 create two heads to verify that we only see one change in the log later
23 26 $ hg commit -ma
24 27 $ hg up null
25 28 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
26 29 $ echo b > b
27 30 $ hg commit -Amb
28 31 adding b
29 32 created new head
30 33
31 34 clone, commit, pull
32 35 $ hg clone . ../blackboxtest2
33 36 updating to branch default
34 37 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
35 38 $ echo c > c
36 39 $ hg commit -Amc
37 40 adding c
38 41 $ cd ../blackboxtest2
39 42 $ hg pull
40 43 pulling from $TESTTMP/blackboxtest (glob)
41 44 searching for changes
42 45 adding changesets
43 46 adding manifests
44 47 adding file changes
45 48 added 1 changesets with 1 changes to 1 files
46 49 (run 'hg update' to get a working copy)
47 50 $ hg blackbox -l 6
48 1970/01/01 00:00:00 bob (5000)> pull
49 1970/01/01 00:00:00 bob (5000)> updated served branch cache in * seconds (glob)
50 1970/01/01 00:00:00 bob (5000)> wrote served branch cache with 1 labels and 2 nodes
51 1970/01/01 00:00:00 bob (5000)> 1 incoming changes - new heads: d02f48003e62
52 1970/01/01 00:00:00 bob (5000)> pull exited 0 after * seconds (glob)
53 1970/01/01 00:00:00 bob (5000)> blackbox -l 6
51 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> pull
52 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> updated served branch cache in * seconds (glob)
53 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> wrote served branch cache with 1 labels and 2 nodes
54 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> 1 incoming changes - new heads: d02f48003e62
55 1970/01/01 00:00:00 bob @(unknown) (5000)> pull exited 0 after * seconds (glob)
56 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> blackbox -l 6
54 57
55 58 we must not cause a failure if we cannot write to the log
56 59
57 60 $ hg rollback
58 61 repository tip rolled back to revision 1 (undo pull)
59 62
60 63 $ mv .hg/blackbox.log .hg/blackbox.log-
61 64 $ mkdir .hg/blackbox.log
62 65 $ hg --debug incoming
63 66 warning: cannot write to blackbox.log: * (glob)
64 67 comparing with $TESTTMP/blackboxtest (glob)
65 68 query 1; heads
66 69 searching for changes
67 70 all local heads known remotely
68 71 changeset: 2:d02f48003e62c24e2659d97d30f2a83abe5d5d51
69 72 tag: tip
70 73 phase: draft
71 74 parent: 1:6563da9dcf87b1949716e38ff3e3dfaa3198eb06
72 75 parent: -1:0000000000000000000000000000000000000000
73 76 manifest: 2:ab9d46b053ebf45b7996f2922b9893ff4b63d892
74 77 user: test
75 78 date: Thu Jan 01 00:00:00 1970 +0000
76 79 files+: c
77 80 extra: branch=default
78 81 description:
79 82 c
80 83
81 84
82 85 $ hg pull
83 86 pulling from $TESTTMP/blackboxtest (glob)
84 87 searching for changes
85 88 adding changesets
86 89 adding manifests
87 90 adding file changes
88 91 added 1 changesets with 1 changes to 1 files
89 92 (run 'hg update' to get a working copy)
90 93
91 94 a failure reading from the log is fatal
92 95
93 96 $ hg blackbox -l 3
94 97 abort: *$TESTTMP/blackboxtest2/.hg/blackbox.log* (glob)
95 98 [255]
96 99
97 100 $ rmdir .hg/blackbox.log
98 101 $ mv .hg/blackbox.log- .hg/blackbox.log
99 102
100 103 backup bundles get logged
101 104
102 105 $ touch d
103 106 $ hg commit -Amd
104 107 adding d
105 108 created new head
106 109 $ hg strip tip
107 110 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
108 111 saved backup bundle to $TESTTMP/blackboxtest2/.hg/strip-backup/*-backup.hg (glob)
109 112 $ hg blackbox -l 6
110 1970/01/01 00:00:00 bob (5000)> strip tip
111 1970/01/01 00:00:00 bob (5000)> saved backup bundle to $TESTTMP/blackboxtest2/.hg/strip-backup/73f6ee326b27-7612e004-backup.hg (glob)
112 1970/01/01 00:00:00 bob (5000)> updated base branch cache in * seconds (glob)
113 1970/01/01 00:00:00 bob (5000)> wrote base branch cache with 1 labels and 2 nodes
114 1970/01/01 00:00:00 bob (5000)> strip tip exited 0 after * seconds (glob)
115 1970/01/01 00:00:00 bob (5000)> blackbox -l 6
113 1970/01/01 00:00:00 bob @73f6ee326b27d820b0472f1a825e3a50f3dc489b (5000)> strip tip
114 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> saved backup bundle to $TESTTMP/blackboxtest2/.hg/strip-backup/73f6ee326b27-7612e004-backup.hg
115 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> updated base branch cache in * seconds (glob)
116 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> wrote base branch cache with 1 labels and 2 nodes
117 1970/01/01 00:00:00 bob @(unknown) (5000)> strip tip exited 0 after * seconds (glob)
118 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> blackbox -l 6
116 119
117 120 extension and python hooks - use the eol extension for a pythonhook
118 121
119 122 $ echo '[extensions]' >> .hg/hgrc
120 123 $ echo 'eol=' >> .hg/hgrc
121 124 $ echo '[hooks]' >> .hg/hgrc
122 125 $ echo 'update = echo hooked' >> .hg/hgrc
123 126 $ hg update
124 127 hooked
125 128 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
126 129 1 other heads for branch "default"
127 130 $ hg blackbox -l 6
128 1970/01/01 00:00:00 bob (5000)> update
129 1970/01/01 00:00:00 bob (5000)> writing .hg/cache/tags2-visible with 0 tags
130 1970/01/01 00:00:00 bob (5000)> pythonhook-preupdate: hgext.eol.preupdate finished in * seconds (glob)
131 1970/01/01 00:00:00 bob (5000)> exthook-update: echo hooked finished in * seconds (glob)
132 1970/01/01 00:00:00 bob (5000)> update exited 0 after * seconds (glob)
133 1970/01/01 00:00:00 bob (5000)> blackbox -l 6
131 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> update
132 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> writing .hg/cache/tags2-visible with 0 tags
133 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> pythonhook-preupdate: hgext.eol.preupdate finished in * seconds (glob)
134 1970/01/01 00:00:00 bob @d02f48003e62c24e2659d97d30f2a83abe5d5d51 (5000)> exthook-update: echo hooked finished in * seconds (glob)
135 1970/01/01 00:00:00 bob @(unknown) (5000)> update exited 0 after * seconds (glob)
136 1970/01/01 00:00:00 bob @d02f48003e62c24e2659d97d30f2a83abe5d5d51 (5000)> blackbox -l 6
134 137
135 138 log rotation
136 139
137 140 $ echo '[blackbox]' >> .hg/hgrc
138 141 $ echo 'maxsize = 20 b' >> .hg/hgrc
139 142 $ echo 'maxfiles = 3' >> .hg/hgrc
140 143 $ hg status
141 144 $ hg status
142 145 $ hg status
143 146 $ hg tip -q
144 147 2:d02f48003e62
145 148 $ ls .hg/blackbox.log*
146 149 .hg/blackbox.log
147 150 .hg/blackbox.log.1
148 151 .hg/blackbox.log.2
149 152 $ cd ..
150 153
151 154 $ hg init blackboxtest3
152 155 $ cd blackboxtest3
153 156 $ hg blackbox
154 1970/01/01 00:00:00 bob (5000)> blackbox
157 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> blackbox
155 158 $ mv .hg/blackbox.log .hg/blackbox.log-
156 159 $ mkdir .hg/blackbox.log
157 160 $ sed -e 's/\(.*test1.*\)/#\1/; s#\(.*commit2.*\)#os.rmdir(".hg/blackbox.log")\nos.rename(".hg/blackbox.log-", ".hg/blackbox.log")\n\1#' $TESTDIR/test-dispatch.py > ../test-dispatch.py
158 161 $ python ../test-dispatch.py
159 162 running: add foo
160 163 result: 0
161 164 running: commit -m commit1 -d 2000-01-01 foo
162 165 result: None
163 166 running: commit -m commit2 -d 2000-01-02 foo
164 167 result: None
165 168 running: log -r 0
166 169 changeset: 0:0e4634943879
167 170 user: test
168 171 date: Sat Jan 01 00:00:00 2000 +0000
169 172 summary: commit1
170 173
171 174 result: None
172 175 running: log -r tip
173 176 changeset: 1:45589e459b2e
174 177 tag: tip
175 178 user: test
176 179 date: Sun Jan 02 00:00:00 2000 +0000
177 180 summary: commit2
178 181
179 182 result: None
180 183 $ hg blackbox
181 1970/01/01 00:00:00 bob (5000)> blackbox
182 1970/01/01 00:00:00 bob (5000)> blackbox exited 0 after * seconds (glob)
183 1970/01/01 00:00:00 bob (5000)> blackbox
184 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> blackbox
185 1970/01/01 00:00:00 bob @(unknown) (5000)> blackbox exited 0 after * seconds (glob)
186 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> blackbox
184 187
185 188 cleanup
186 189 $ cd ..
@@ -1,116 +1,116 b''
1 1 $ cat >> $HGRCPATH << EOF
2 2 > [extensions]
3 3 > blackbox=
4 4 > rebase=
5 5 > mock=$TESTDIR/mockblackbox.py
6 6 >
7 7 > [experimental]
8 8 > evolution = createmarkers
9 9 > EOF
10 10
11 11 Create a repo with some tags
12 12
13 13 $ hg init repo
14 14 $ cd repo
15 15 $ echo initial > foo
16 16 $ hg -q commit -A -m initial
17 17 $ hg tag -m 'test tag' test1
18 18 $ echo first > first
19 19 $ hg -q commit -A -m first
20 20 $ hg tag -m 'test2 tag' test2
21 21 $ hg -q up -r 0
22 22 $ echo newhead > newhead
23 23 $ hg commit -A -m newhead
24 24 adding newhead
25 25 created new head
26 26 $ hg tag -m 'test head 2 tag' head2
27 27
28 28 $ hg log -G -T '{rev}:{node|short} {tags} {desc}\n'
29 29 @ 5:2942a772f72a tip test head 2 tag
30 30 |
31 31 o 4:042eb6bfcc49 head2 newhead
32 32 |
33 33 | o 3:c3cb30f2d2cd test2 tag
34 34 | |
35 35 | o 2:d75775ffbc6b test2 first
36 36 | |
37 37 | o 1:5f97d42da03f test tag
38 38 |/
39 39 o 0:55482a6fb4b1 test1 initial
40 40
41 41
42 42 Trigger tags cache population by doing something that accesses tags info
43 43
44 44 $ hg tags
45 45 tip 5:2942a772f72a
46 46 head2 4:042eb6bfcc49
47 47 test2 2:d75775ffbc6b
48 48 test1 0:55482a6fb4b1
49 49
50 50 $ cat .hg/cache/tags2-visible
51 51 5 2942a772f72a444bef4bef13874d515f50fa27b6
52 52 042eb6bfcc4909bad84a1cbf6eb1ddf0ab587d41 head2
53 53 55482a6fb4b1881fa8f746fd52cf6f096bb21c89 test1
54 54 d75775ffbc6bca1794d300f5571272879bd280da test2
55 55
56 56 Hiding a non-tip changeset should change filtered hash and cause tags recompute
57 57
58 58 $ hg debugobsolete -d '0 0' c3cb30f2d2cd0aae008cc91a07876e3c5131fd22 -u dummyuser
59 59
60 60 $ hg tags
61 61 tip 5:2942a772f72a
62 62 head2 4:042eb6bfcc49
63 63 test1 0:55482a6fb4b1
64 64
65 65 $ cat .hg/cache/tags2-visible
66 66 5 2942a772f72a444bef4bef13874d515f50fa27b6 f34fbc9a9769ba9eff5aff3d008a6b49f85c08b1
67 67 042eb6bfcc4909bad84a1cbf6eb1ddf0ab587d41 head2
68 68 55482a6fb4b1881fa8f746fd52cf6f096bb21c89 test1
69 69
70 70 $ hg blackbox -l 5
71 1970/01/01 00:00:00 bob (5000)> tags
72 1970/01/01 00:00:00 bob (5000)> 2/2 cache hits/lookups in * seconds (glob)
73 1970/01/01 00:00:00 bob (5000)> writing .hg/cache/tags2-visible with 2 tags
74 1970/01/01 00:00:00 bob (5000)> tags exited 0 after * seconds (glob)
75 1970/01/01 00:00:00 bob (5000)> blackbox -l 5
71 1970/01/01 00:00:00 bob @2942a772f72a444bef4bef13874d515f50fa27b6 (5000)> tags
72 1970/01/01 00:00:00 bob @2942a772f72a444bef4bef13874d515f50fa27b6 (5000)> 2/2 cache hits/lookups in * seconds (glob)
73 1970/01/01 00:00:00 bob @2942a772f72a444bef4bef13874d515f50fa27b6 (5000)> writing .hg/cache/tags2-visible with 2 tags
74 1970/01/01 00:00:00 bob @(unknown) (5000)> tags exited 0 after * seconds (glob)
75 1970/01/01 00:00:00 bob @2942a772f72a444bef4bef13874d515f50fa27b6 (5000)> blackbox -l 5
76 76
77 77 Hiding another changeset should cause the filtered hash to change
78 78
79 79 $ hg debugobsolete -d '0 0' d75775ffbc6bca1794d300f5571272879bd280da -u dummyuser
80 80 $ hg debugobsolete -d '0 0' 5f97d42da03fd56f3b228b03dfe48af5c0adf75b -u dummyuser
81 81
82 82 $ hg tags
83 83 tip 5:2942a772f72a
84 84 head2 4:042eb6bfcc49
85 85
86 86 $ cat .hg/cache/tags2-visible
87 87 5 2942a772f72a444bef4bef13874d515f50fa27b6 2fce1eec33263d08a4d04293960fc73a555230e4
88 88 042eb6bfcc4909bad84a1cbf6eb1ddf0ab587d41 head2
89 89
90 90 $ hg blackbox -l 5
91 1970/01/01 00:00:00 bob (5000)> tags
92 1970/01/01 00:00:00 bob (5000)> 1/1 cache hits/lookups in * seconds (glob)
93 1970/01/01 00:00:00 bob (5000)> writing .hg/cache/tags2-visible with 1 tags
94 1970/01/01 00:00:00 bob (5000)> tags exited 0 after * seconds (glob)
95 1970/01/01 00:00:00 bob (5000)> blackbox -l 5
91 1970/01/01 00:00:00 bob @2942a772f72a444bef4bef13874d515f50fa27b6 (5000)> tags
92 1970/01/01 00:00:00 bob @2942a772f72a444bef4bef13874d515f50fa27b6 (5000)> 1/1 cache hits/lookups in * seconds (glob)
93 1970/01/01 00:00:00 bob @2942a772f72a444bef4bef13874d515f50fa27b6 (5000)> writing .hg/cache/tags2-visible with 1 tags
94 1970/01/01 00:00:00 bob @(unknown) (5000)> tags exited 0 after * seconds (glob)
95 1970/01/01 00:00:00 bob @2942a772f72a444bef4bef13874d515f50fa27b6 (5000)> blackbox -l 5
96 96
97 97 Resolving tags on an unfiltered repo writes a separate tags cache
98 98
99 99 $ hg --hidden tags
100 100 tip 5:2942a772f72a
101 101 head2 4:042eb6bfcc49
102 102 test2 2:d75775ffbc6b
103 103 test1 0:55482a6fb4b1
104 104
105 105 $ cat .hg/cache/tags2
106 106 5 2942a772f72a444bef4bef13874d515f50fa27b6
107 107 042eb6bfcc4909bad84a1cbf6eb1ddf0ab587d41 head2
108 108 55482a6fb4b1881fa8f746fd52cf6f096bb21c89 test1
109 109 d75775ffbc6bca1794d300f5571272879bd280da test2
110 110
111 111 $ hg blackbox -l 5
112 1970/01/01 00:00:00 bob (5000)> --hidden tags
113 1970/01/01 00:00:00 bob (5000)> 2/2 cache hits/lookups in * seconds (glob)
114 1970/01/01 00:00:00 bob (5000)> writing .hg/cache/tags2 with 3 tags
115 1970/01/01 00:00:00 bob (5000)> --hidden tags exited 0 after * seconds (glob)
116 1970/01/01 00:00:00 bob (5000)> blackbox -l 5
112 1970/01/01 00:00:00 bob @2942a772f72a444bef4bef13874d515f50fa27b6 (5000)> --hidden tags
113 1970/01/01 00:00:00 bob @2942a772f72a444bef4bef13874d515f50fa27b6 (5000)> 2/2 cache hits/lookups in * seconds (glob)
114 1970/01/01 00:00:00 bob @2942a772f72a444bef4bef13874d515f50fa27b6 (5000)> writing .hg/cache/tags2 with 3 tags
115 1970/01/01 00:00:00 bob @(unknown) (5000)> --hidden tags exited 0 after * seconds (glob)
116 1970/01/01 00:00:00 bob @2942a772f72a444bef4bef13874d515f50fa27b6 (5000)> blackbox -l 5
@@ -1,712 +1,712 b''
1 1 setup
2 2
3 3 $ cat >> $HGRCPATH << EOF
4 4 > [extensions]
5 5 > blackbox=
6 6 > mock=$TESTDIR/mockblackbox.py
7 7 > EOF
8 8
9 9 Helper functions:
10 10
11 11 $ cacheexists() {
12 12 > [ -f .hg/cache/tags2-visible ] && echo "tag cache exists" || echo "no tag cache"
13 13 > }
14 14
15 15 $ fnodescacheexists() {
16 16 > [ -f .hg/cache/hgtagsfnodes1 ] && echo "fnodes cache exists" || echo "no fnodes cache"
17 17 > }
18 18
19 19 $ dumptags() {
20 20 > rev=$1
21 21 > echo "rev $rev: .hgtags:"
22 22 > hg cat -r$rev .hgtags
23 23 > }
24 24
25 25 # XXX need to test that the tag cache works when we strip an old head
26 26 # and add a new one rooted off non-tip: i.e. node and rev of tip are the
27 27 # same, but stuff has changed behind tip.
28 28
29 29 Setup:
30 30
31 31 $ hg init t
32 32 $ cd t
33 33 $ cacheexists
34 34 no tag cache
35 35 $ fnodescacheexists
36 36 no fnodes cache
37 37 $ hg id
38 38 000000000000 tip
39 39 $ cacheexists
40 40 no tag cache
41 41 $ fnodescacheexists
42 42 no fnodes cache
43 43 $ echo a > a
44 44 $ hg add a
45 45 $ hg commit -m "test"
46 46 $ hg co
47 47 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
48 48 $ hg identify
49 49 acb14030fe0a tip
50 50 $ hg identify -r 'wdir()'
51 51 acb14030fe0a tip
52 52 $ cacheexists
53 53 tag cache exists
54 54 No fnodes cache because .hgtags file doesn't exist
55 55 (this is an implementation detail)
56 56 $ fnodescacheexists
57 57 no fnodes cache
58 58
59 59 Try corrupting the cache
60 60
61 61 $ printf 'a b' > .hg/cache/tags2-visible
62 62 $ hg identify
63 63 acb14030fe0a tip
64 64 $ cacheexists
65 65 tag cache exists
66 66 $ fnodescacheexists
67 67 no fnodes cache
68 68 $ hg identify
69 69 acb14030fe0a tip
70 70
71 71 Create local tag with long name:
72 72
73 73 $ T=`hg identify --debug --id`
74 74 $ hg tag -l "This is a local tag with a really long name!"
75 75 $ hg tags
76 76 tip 0:acb14030fe0a
77 77 This is a local tag with a really long name! 0:acb14030fe0a
78 78 $ rm .hg/localtags
79 79
80 80 Create a tag behind hg's back:
81 81
82 82 $ echo "$T first" > .hgtags
83 83 $ cat .hgtags
84 84 acb14030fe0a21b60322c440ad2d20cf7685a376 first
85 85 $ hg add .hgtags
86 86 $ hg commit -m "add tags"
87 87 $ hg tags
88 88 tip 1:b9154636be93
89 89 first 0:acb14030fe0a
90 90 $ hg identify
91 91 b9154636be93 tip
92 92
93 93 We should have a fnodes cache now that we have a real tag
94 94 The cache should have an empty entry for rev 0 and a valid entry for rev 1.
95 95
96 96
97 97 $ fnodescacheexists
98 98 fnodes cache exists
99 99 $ f --size --hexdump .hg/cache/hgtagsfnodes1
100 100 .hg/cache/hgtagsfnodes1: size=48
101 101 0000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
102 102 0010: ff ff ff ff ff ff ff ff b9 15 46 36 26 b7 b4 a7 |..........F6&...|
103 103 0020: 73 e0 9e e3 c5 2f 51 0e 19 e0 5e 1f f9 66 d8 59 |s..../Q...^..f.Y|
104 104
105 105 Repeat with cold tag cache:
106 106
107 107 $ rm -f .hg/cache/tags2-visible .hg/cache/hgtagsfnodes1
108 108 $ hg identify
109 109 b9154636be93 tip
110 110
111 111 $ fnodescacheexists
112 112 fnodes cache exists
113 113 $ f --size --hexdump .hg/cache/hgtagsfnodes1
114 114 .hg/cache/hgtagsfnodes1: size=48
115 115 0000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
116 116 0010: ff ff ff ff ff ff ff ff b9 15 46 36 26 b7 b4 a7 |..........F6&...|
117 117 0020: 73 e0 9e e3 c5 2f 51 0e 19 e0 5e 1f f9 66 d8 59 |s..../Q...^..f.Y|
118 118
119 119 And again, but now unable to write tag cache or lock file:
120 120
121 121 #if unix-permissions
122 122 $ rm -f .hg/cache/tags2-visible .hg/cache/hgtagsfnodes1
123 123 $ chmod 555 .hg/cache
124 124 $ hg identify
125 125 b9154636be93 tip
126 126 $ chmod 755 .hg/cache
127 127
128 128 $ chmod 555 .hg
129 129 $ hg identify
130 130 b9154636be93 tip
131 131 $ chmod 755 .hg
132 132 #endif
133 133
134 134 Tag cache debug info written to blackbox log
135 135
136 136 $ rm -f .hg/cache/tags2-visible .hg/cache/hgtagsfnodes1
137 137 $ hg identify
138 138 b9154636be93 tip
139 139 $ hg blackbox -l 6
140 1970/01/01 00:00:00 bob (5000)> identify
141 1970/01/01 00:00:00 bob (5000)> writing 48 bytes to cache/hgtagsfnodes1
142 1970/01/01 00:00:00 bob (5000)> 0/1 cache hits/lookups in * seconds (glob)
143 1970/01/01 00:00:00 bob (5000)> writing .hg/cache/tags2-visible with 1 tags
144 1970/01/01 00:00:00 bob (5000)> identify exited 0 after * seconds (glob)
145 1970/01/01 00:00:00 bob (5000)> blackbox -l 6
140 1970/01/01 00:00:00 bob @b9154636be938d3d431e75a7c906504a079bfe07 (5000)> identify
141 1970/01/01 00:00:00 bob @b9154636be938d3d431e75a7c906504a079bfe07 (5000)> writing 48 bytes to cache/hgtagsfnodes1
142 1970/01/01 00:00:00 bob @b9154636be938d3d431e75a7c906504a079bfe07 (5000)> 0/1 cache hits/lookups in * seconds (glob)
143 1970/01/01 00:00:00 bob @b9154636be938d3d431e75a7c906504a079bfe07 (5000)> writing .hg/cache/tags2-visible with 1 tags
144 1970/01/01 00:00:00 bob @(unknown) (5000)> identify exited 0 after * seconds (glob)
145 1970/01/01 00:00:00 bob @b9154636be938d3d431e75a7c906504a079bfe07 (5000)> blackbox -l 6
146 146
147 147 Failure to acquire lock results in no write
148 148
149 149 $ rm -f .hg/cache/tags2-visible .hg/cache/hgtagsfnodes1
150 150 $ echo 'foo:1' > .hg/wlock
151 151 $ hg identify
152 152 b9154636be93 tip
153 153 $ hg blackbox -l 6
154 1970/01/01 00:00:00 bob (5000)> identify
155 1970/01/01 00:00:00 bob (5000)> not writing .hg/cache/hgtagsfnodes1 because lock cannot be acquired
156 1970/01/01 00:00:00 bob (5000)> 0/1 cache hits/lookups in * seconds (glob)
157 1970/01/01 00:00:00 bob (5000)> writing .hg/cache/tags2-visible with 1 tags
158 1970/01/01 00:00:00 bob (5000)> identify exited 0 after * seconds (glob)
159 1970/01/01 00:00:00 bob (5000)> blackbox -l 6
154 1970/01/01 00:00:00 bob @b9154636be938d3d431e75a7c906504a079bfe07 (5000)> identify
155 1970/01/01 00:00:00 bob @b9154636be938d3d431e75a7c906504a079bfe07 (5000)> not writing .hg/cache/hgtagsfnodes1 because lock cannot be acquired
156 1970/01/01 00:00:00 bob @b9154636be938d3d431e75a7c906504a079bfe07 (5000)> 0/1 cache hits/lookups in * seconds (glob)
157 1970/01/01 00:00:00 bob @b9154636be938d3d431e75a7c906504a079bfe07 (5000)> writing .hg/cache/tags2-visible with 1 tags
158 1970/01/01 00:00:00 bob @(unknown) (5000)> identify exited 0 after * seconds (glob)
159 1970/01/01 00:00:00 bob @b9154636be938d3d431e75a7c906504a079bfe07 (5000)> blackbox -l 6
160 160
161 161 $ fnodescacheexists
162 162 no fnodes cache
163 163
164 164 $ rm .hg/wlock
165 165
166 166 $ rm -f .hg/cache/tags2-visible .hg/cache/hgtagsfnodes1
167 167 $ hg identify
168 168 b9154636be93 tip
169 169
170 170 Create a branch:
171 171
172 172 $ echo bb > a
173 173 $ hg status
174 174 M a
175 175 $ hg identify
176 176 b9154636be93+ tip
177 177 $ hg co first
178 178 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
179 179 $ hg id
180 180 acb14030fe0a+ first
181 181 $ hg id -r 'wdir()'
182 182 acb14030fe0a+ first
183 183 $ hg -v id
184 184 acb14030fe0a+ first
185 185 $ hg status
186 186 M a
187 187 $ echo 1 > b
188 188 $ hg add b
189 189 $ hg commit -m "branch"
190 190 created new head
191 191
192 192 Creating a new commit shouldn't append the .hgtags fnodes cache until
193 193 tags info is accessed
194 194
195 195 $ f --size --hexdump .hg/cache/hgtagsfnodes1
196 196 .hg/cache/hgtagsfnodes1: size=48
197 197 0000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
198 198 0010: ff ff ff ff ff ff ff ff b9 15 46 36 26 b7 b4 a7 |..........F6&...|
199 199 0020: 73 e0 9e e3 c5 2f 51 0e 19 e0 5e 1f f9 66 d8 59 |s..../Q...^..f.Y|
200 200
201 201 $ hg id
202 202 c8edf04160c7 tip
203 203
204 204 First 4 bytes of record 3 are changeset fragment
205 205
206 206 $ f --size --hexdump .hg/cache/hgtagsfnodes1
207 207 .hg/cache/hgtagsfnodes1: size=72
208 208 0000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
209 209 0010: ff ff ff ff ff ff ff ff b9 15 46 36 26 b7 b4 a7 |..........F6&...|
210 210 0020: 73 e0 9e e3 c5 2f 51 0e 19 e0 5e 1f f9 66 d8 59 |s..../Q...^..f.Y|
211 211 0030: c8 ed f0 41 00 00 00 00 00 00 00 00 00 00 00 00 |...A............|
212 212 0040: 00 00 00 00 00 00 00 00 |........|
213 213
214 214 Merge the two heads:
215 215
216 216 $ hg merge 1
217 217 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
218 218 (branch merge, don't forget to commit)
219 219 $ hg id
220 220 c8edf04160c7+b9154636be93+ tip
221 221 $ hg status
222 222 M .hgtags
223 223 $ hg commit -m "merge"
224 224
225 225 Create a fake head, make sure tag not visible afterwards:
226 226
227 227 $ cp .hgtags tags
228 228 $ hg tag last
229 229 $ hg rm .hgtags
230 230 $ hg commit -m "remove"
231 231
232 232 $ mv tags .hgtags
233 233 $ hg add .hgtags
234 234 $ hg commit -m "readd"
235 235 $
236 236 $ hg tags
237 237 tip 6:35ff301afafe
238 238 first 0:acb14030fe0a
239 239
240 240 Add invalid tags:
241 241
242 242 $ echo "spam" >> .hgtags
243 243 $ echo >> .hgtags
244 244 $ echo "foo bar" >> .hgtags
245 245 $ echo "a5a5 invalid" >> .hg/localtags
246 246 $ cat .hgtags
247 247 acb14030fe0a21b60322c440ad2d20cf7685a376 first
248 248 spam
249 249
250 250 foo bar
251 251 $ hg commit -m "tags"
252 252
253 253 Report tag parse error on other head:
254 254
255 255 $ hg up 3
256 256 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
257 257 $ echo 'x y' >> .hgtags
258 258 $ hg commit -m "head"
259 259 created new head
260 260
261 261 $ hg tags
262 262 .hgtags@75d9f02dfe28, line 2: cannot parse entry
263 263 .hgtags@75d9f02dfe28, line 4: node 'foo' is not well formed
264 264 .hgtags@c4be69a18c11, line 2: node 'x' is not well formed
265 265 tip 8:c4be69a18c11
266 266 first 0:acb14030fe0a
267 267 $ hg tip
268 268 changeset: 8:c4be69a18c11
269 269 tag: tip
270 270 parent: 3:ac5e980c4dc0
271 271 user: test
272 272 date: Thu Jan 01 00:00:00 1970 +0000
273 273 summary: head
274 274
275 275
276 276 Test tag precedence rules:
277 277
278 278 $ cd ..
279 279 $ hg init t2
280 280 $ cd t2
281 281 $ echo foo > foo
282 282 $ hg add foo
283 283 $ hg ci -m 'add foo' # rev 0
284 284 $ hg tag bar # rev 1
285 285 $ echo >> foo
286 286 $ hg ci -m 'change foo 1' # rev 2
287 287 $ hg up -C 1
288 288 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
289 289 $ hg tag -r 1 -f bar # rev 3
290 290 $ hg up -C 1
291 291 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
292 292 $ echo >> foo
293 293 $ hg ci -m 'change foo 2' # rev 4
294 294 created new head
295 295 $ hg tags
296 296 tip 4:0c192d7d5e6b
297 297 bar 1:78391a272241
298 298
299 299 Repeat in case of cache effects:
300 300
301 301 $ hg tags
302 302 tip 4:0c192d7d5e6b
303 303 bar 1:78391a272241
304 304
305 305 Detailed dump of tag info:
306 306
307 307 $ hg heads -q # expect 4, 3, 2
308 308 4:0c192d7d5e6b
309 309 3:6fa450212aeb
310 310 2:7a94127795a3
311 311 $ dumptags 2
312 312 rev 2: .hgtags:
313 313 bbd179dfa0a71671c253b3ae0aa1513b60d199fa bar
314 314 $ dumptags 3
315 315 rev 3: .hgtags:
316 316 bbd179dfa0a71671c253b3ae0aa1513b60d199fa bar
317 317 bbd179dfa0a71671c253b3ae0aa1513b60d199fa bar
318 318 78391a272241d70354aa14c874552cad6b51bb42 bar
319 319 $ dumptags 4
320 320 rev 4: .hgtags:
321 321 bbd179dfa0a71671c253b3ae0aa1513b60d199fa bar
322 322
323 323 Dump cache:
324 324
325 325 $ cat .hg/cache/tags2-visible
326 326 4 0c192d7d5e6b78a714de54a2e9627952a877e25a
327 327 bbd179dfa0a71671c253b3ae0aa1513b60d199fa bar
328 328 bbd179dfa0a71671c253b3ae0aa1513b60d199fa bar
329 329 78391a272241d70354aa14c874552cad6b51bb42 bar
330 330
331 331 $ f --size --hexdump .hg/cache/hgtagsfnodes1
332 332 .hg/cache/hgtagsfnodes1: size=120
333 333 0000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
334 334 0010: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
335 335 0020: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
336 336 0030: 7a 94 12 77 0c 04 f2 a8 af 31 de 17 fa b7 42 28 |z..w.....1....B(|
337 337 0040: 78 ee 5a 2d ad bc 94 3d 6f a4 50 21 7d 3b 71 8c |x.Z-...=o.P!};q.|
338 338 0050: 96 4e f3 7b 89 e5 50 eb da fd 57 89 e7 6c e1 b0 |.N.{..P...W..l..|
339 339 0060: 0c 19 2d 7d 0c 04 f2 a8 af 31 de 17 fa b7 42 28 |..-}.....1....B(|
340 340 0070: 78 ee 5a 2d ad bc 94 3d |x.Z-...=|
341 341
342 342 Corrupt the .hgtags fnodes cache
343 343 Extra junk data at the end should get overwritten on next cache update
344 344
345 345 $ echo extra >> .hg/cache/hgtagsfnodes1
346 346 $ echo dummy1 > foo
347 347 $ hg commit -m throwaway1
348 348
349 349 $ hg tags
350 350 tip 5:8dbfe60eff30
351 351 bar 1:78391a272241
352 352
353 353 $ hg blackbox -l 6
354 1970/01/01 00:00:00 bob (5000)> tags
355 1970/01/01 00:00:00 bob (5000)> writing 24 bytes to cache/hgtagsfnodes1
356 1970/01/01 00:00:00 bob (5000)> 2/3 cache hits/lookups in * seconds (glob)
357 1970/01/01 00:00:00 bob (5000)> writing .hg/cache/tags2-visible with 1 tags
358 1970/01/01 00:00:00 bob (5000)> tags exited 0 after * seconds (glob)
359 1970/01/01 00:00:00 bob (5000)> blackbox -l 6
354 1970/01/01 00:00:00 bob @8dbfe60eff306a54259cfe007db9e330e7ecf866 (5000)> tags
355 1970/01/01 00:00:00 bob @8dbfe60eff306a54259cfe007db9e330e7ecf866 (5000)> writing 24 bytes to cache/hgtagsfnodes1
356 1970/01/01 00:00:00 bob @8dbfe60eff306a54259cfe007db9e330e7ecf866 (5000)> 2/3 cache hits/lookups in * seconds (glob)
357 1970/01/01 00:00:00 bob @8dbfe60eff306a54259cfe007db9e330e7ecf866 (5000)> writing .hg/cache/tags2-visible with 1 tags
358 1970/01/01 00:00:00 bob @(unknown) (5000)> tags exited 0 after * seconds (glob)
359 1970/01/01 00:00:00 bob @8dbfe60eff306a54259cfe007db9e330e7ecf866 (5000)> blackbox -l 6
360 360
361 361 #if unix-permissions no-root
362 362 Errors writing to .hgtags fnodes cache are silently ignored
363 363
364 364 $ echo dummy2 > foo
365 365 $ hg commit -m throwaway2
366 366
367 367 $ chmod a-w .hg/cache/hgtagsfnodes1
368 368 $ rm -f .hg/cache/tags2-visible
369 369
370 370 $ hg tags
371 371 tip 6:b968051b5cf3
372 372 bar 1:78391a272241
373 373
374 374 $ hg blackbox -l 6
375 1970/01/01 00:00:00 bob (5000)> tags
376 1970/01/01 00:00:00 bob (5000)> couldn't write cache/hgtagsfnodes1: [Errno 13] Permission denied: '$TESTTMP/t2/.hg/cache/hgtagsfnodes1' (glob)
377 1970/01/01 00:00:00 bob (5000)> 2/3 cache hits/lookups in * seconds (glob)
378 1970/01/01 00:00:00 bob (5000)> writing .hg/cache/tags2-visible with 1 tags
379 1970/01/01 00:00:00 bob (5000)> tags exited 0 after * seconds (glob)
380 1970/01/01 00:00:00 bob (5000)> blackbox -l 6
375 1970/01/01 00:00:00 bob @b968051b5cf3f624b771779c6d5f84f1d4c3fb5d (5000)> tags
376 1970/01/01 00:00:00 bob @b968051b5cf3f624b771779c6d5f84f1d4c3fb5d (5000)> couldn't write cache/hgtagsfnodes1: [Errno 13] Permission denied: '$TESTTMP/t2/.hg/cache/hgtagsfnodes1'
377 1970/01/01 00:00:00 bob @b968051b5cf3f624b771779c6d5f84f1d4c3fb5d (5000)> 2/3 cache hits/lookups in * seconds (glob)
378 1970/01/01 00:00:00 bob @b968051b5cf3f624b771779c6d5f84f1d4c3fb5d (5000)> writing .hg/cache/tags2-visible with 1 tags
379 1970/01/01 00:00:00 bob @(unknown) (5000)> tags exited 0 after * seconds (glob)
380 1970/01/01 00:00:00 bob @b968051b5cf3f624b771779c6d5f84f1d4c3fb5d (5000)> blackbox -l 6
381 381
382 382 $ chmod a+w .hg/cache/hgtagsfnodes1
383 383
384 384 $ rm -f .hg/cache/tags2-visible
385 385 $ hg tags
386 386 tip 6:b968051b5cf3
387 387 bar 1:78391a272241
388 388
389 389 $ hg blackbox -l 6
390 1970/01/01 00:00:00 bob (5000)> tags
391 1970/01/01 00:00:00 bob (5000)> writing 24 bytes to cache/hgtagsfnodes1
392 1970/01/01 00:00:00 bob (5000)> 2/3 cache hits/lookups in * seconds (glob)
393 1970/01/01 00:00:00 bob (5000)> writing .hg/cache/tags2-visible with 1 tags
394 1970/01/01 00:00:00 bob (5000)> tags exited 0 after * seconds (glob)
395 1970/01/01 00:00:00 bob (5000)> blackbox -l 6
390 1970/01/01 00:00:00 bob @b968051b5cf3f624b771779c6d5f84f1d4c3fb5d (5000)> tags
391 1970/01/01 00:00:00 bob @b968051b5cf3f624b771779c6d5f84f1d4c3fb5d (5000)> writing 24 bytes to cache/hgtagsfnodes1
392 1970/01/01 00:00:00 bob @b968051b5cf3f624b771779c6d5f84f1d4c3fb5d (5000)> 2/3 cache hits/lookups in * seconds (glob)
393 1970/01/01 00:00:00 bob @b968051b5cf3f624b771779c6d5f84f1d4c3fb5d (5000)> writing .hg/cache/tags2-visible with 1 tags
394 1970/01/01 00:00:00 bob @(unknown) (5000)> tags exited 0 after * seconds (glob)
395 1970/01/01 00:00:00 bob @b968051b5cf3f624b771779c6d5f84f1d4c3fb5d (5000)> blackbox -l 6
396 396
397 397 $ f --size .hg/cache/hgtagsfnodes1
398 398 .hg/cache/hgtagsfnodes1: size=168
399 399
400 400 $ hg -q --config extensions.strip= strip -r 6 --no-backup
401 401 #endif
402 402
403 403 Stripping doesn't truncate the tags cache until new data is available
404 404
405 405 $ rm -f .hg/cache/hgtagsfnodes1 .hg/cache/tags2-visible
406 406 $ hg tags
407 407 tip 5:8dbfe60eff30
408 408 bar 1:78391a272241
409 409
410 410 $ f --size .hg/cache/hgtagsfnodes1
411 411 .hg/cache/hgtagsfnodes1: size=144
412 412
413 413 $ hg -q --config extensions.strip= strip -r 5 --no-backup
414 414 $ hg tags
415 415 tip 4:0c192d7d5e6b
416 416 bar 1:78391a272241
417 417
418 418 $ hg blackbox -l 5
419 1970/01/01 00:00:00 bob (5000)> writing 24 bytes to cache/hgtagsfnodes1
420 1970/01/01 00:00:00 bob (5000)> 2/3 cache hits/lookups in * seconds (glob)
421 1970/01/01 00:00:00 bob (5000)> writing .hg/cache/tags2-visible with 1 tags
422 1970/01/01 00:00:00 bob (5000)> tags exited 0 after * seconds (glob)
423 1970/01/01 00:00:00 bob (5000)> blackbox -l 5
419 1970/01/01 00:00:00 bob @0c192d7d5e6b78a714de54a2e9627952a877e25a (5000)> writing 24 bytes to cache/hgtagsfnodes1
420 1970/01/01 00:00:00 bob @0c192d7d5e6b78a714de54a2e9627952a877e25a (5000)> 2/3 cache hits/lookups in * seconds (glob)
421 1970/01/01 00:00:00 bob @0c192d7d5e6b78a714de54a2e9627952a877e25a (5000)> writing .hg/cache/tags2-visible with 1 tags
422 1970/01/01 00:00:00 bob @(unknown) (5000)> tags exited 0 after * seconds (glob)
423 1970/01/01 00:00:00 bob @0c192d7d5e6b78a714de54a2e9627952a877e25a (5000)> blackbox -l 5
424 424
425 425 $ f --size .hg/cache/hgtagsfnodes1
426 426 .hg/cache/hgtagsfnodes1: size=120
427 427
428 428 $ echo dummy > foo
429 429 $ hg commit -m throwaway3
430 430
431 431 $ hg tags
432 432 tip 5:035f65efb448
433 433 bar 1:78391a272241
434 434
435 435 $ hg blackbox -l 6
436 1970/01/01 00:00:00 bob (5000)> tags
437 1970/01/01 00:00:00 bob (5000)> writing 24 bytes to cache/hgtagsfnodes1
438 1970/01/01 00:00:00 bob (5000)> 2/3 cache hits/lookups in * seconds (glob)
439 1970/01/01 00:00:00 bob (5000)> writing .hg/cache/tags2-visible with 1 tags
440 1970/01/01 00:00:00 bob (5000)> tags exited 0 after * seconds (glob)
441 1970/01/01 00:00:00 bob (5000)> blackbox -l 6
436 1970/01/01 00:00:00 bob @035f65efb448350f4772141702a81ab1df48c465 (5000)> tags
437 1970/01/01 00:00:00 bob @035f65efb448350f4772141702a81ab1df48c465 (5000)> writing 24 bytes to cache/hgtagsfnodes1
438 1970/01/01 00:00:00 bob @035f65efb448350f4772141702a81ab1df48c465 (5000)> 2/3 cache hits/lookups in * seconds (glob)
439 1970/01/01 00:00:00 bob @035f65efb448350f4772141702a81ab1df48c465 (5000)> writing .hg/cache/tags2-visible with 1 tags
440 1970/01/01 00:00:00 bob @(unknown) (5000)> tags exited 0 after * seconds (glob)
441 1970/01/01 00:00:00 bob @035f65efb448350f4772141702a81ab1df48c465 (5000)> blackbox -l 6
442 442 $ f --size .hg/cache/hgtagsfnodes1
443 443 .hg/cache/hgtagsfnodes1: size=144
444 444
445 445 $ hg -q --config extensions.strip= strip -r 5 --no-backup
446 446
447 447 Test tag removal:
448 448
449 449 $ hg tag --remove bar # rev 5
450 450 $ hg tip -vp
451 451 changeset: 5:5f6e8655b1c7
452 452 tag: tip
453 453 user: test
454 454 date: Thu Jan 01 00:00:00 1970 +0000
455 455 files: .hgtags
456 456 description:
457 457 Removed tag bar
458 458
459 459
460 460 diff -r 0c192d7d5e6b -r 5f6e8655b1c7 .hgtags
461 461 --- a/.hgtags Thu Jan 01 00:00:00 1970 +0000
462 462 +++ b/.hgtags Thu Jan 01 00:00:00 1970 +0000
463 463 @@ -1,1 +1,3 @@
464 464 bbd179dfa0a71671c253b3ae0aa1513b60d199fa bar
465 465 +78391a272241d70354aa14c874552cad6b51bb42 bar
466 466 +0000000000000000000000000000000000000000 bar
467 467
468 468 $ hg tags
469 469 tip 5:5f6e8655b1c7
470 470 $ hg tags # again, try to expose cache bugs
471 471 tip 5:5f6e8655b1c7
472 472
473 473 Remove nonexistent tag:
474 474
475 475 $ hg tag --remove foobar
476 476 abort: tag 'foobar' does not exist
477 477 [255]
478 478 $ hg tip
479 479 changeset: 5:5f6e8655b1c7
480 480 tag: tip
481 481 user: test
482 482 date: Thu Jan 01 00:00:00 1970 +0000
483 483 summary: Removed tag bar
484 484
485 485
486 486 Undo a tag with rollback:
487 487
488 488 $ hg rollback # destroy rev 5 (restore bar)
489 489 repository tip rolled back to revision 4 (undo commit)
490 490 working directory now based on revision 4
491 491 $ hg tags
492 492 tip 4:0c192d7d5e6b
493 493 bar 1:78391a272241
494 494 $ hg tags
495 495 tip 4:0c192d7d5e6b
496 496 bar 1:78391a272241
497 497
498 498 Test tag rank:
499 499
500 500 $ cd ..
501 501 $ hg init t3
502 502 $ cd t3
503 503 $ echo foo > foo
504 504 $ hg add foo
505 505 $ hg ci -m 'add foo' # rev 0
506 506 $ hg tag -f bar # rev 1 bar -> 0
507 507 $ hg tag -f bar # rev 2 bar -> 1
508 508 $ hg tag -fr 0 bar # rev 3 bar -> 0
509 509 $ hg tag -fr 1 bar # rev 4 bar -> 1
510 510 $ hg tag -fr 0 bar # rev 5 bar -> 0
511 511 $ hg tags
512 512 tip 5:85f05169d91d
513 513 bar 0:bbd179dfa0a7
514 514 $ hg co 3
515 515 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
516 516 $ echo barbar > foo
517 517 $ hg ci -m 'change foo' # rev 6
518 518 created new head
519 519 $ hg tags
520 520 tip 6:735c3ca72986
521 521 bar 0:bbd179dfa0a7
522 522
523 523 Don't allow moving tag without -f:
524 524
525 525 $ hg tag -r 3 bar
526 526 abort: tag 'bar' already exists (use -f to force)
527 527 [255]
528 528 $ hg tags
529 529 tip 6:735c3ca72986
530 530 bar 0:bbd179dfa0a7
531 531
532 532 Strip 1: expose an old head:
533 533
534 534 $ hg --config extensions.mq= strip 5
535 535 saved backup bundle to $TESTTMP/t3/.hg/strip-backup/*-backup.hg (glob)
536 536 $ hg tags # partly stale cache
537 537 tip 5:735c3ca72986
538 538 bar 1:78391a272241
539 539 $ hg tags # up-to-date cache
540 540 tip 5:735c3ca72986
541 541 bar 1:78391a272241
542 542
543 543 Strip 2: destroy whole branch, no old head exposed
544 544
545 545 $ hg --config extensions.mq= strip 4
546 546 saved backup bundle to $TESTTMP/t3/.hg/strip-backup/*-backup.hg (glob)
547 547 $ hg tags # partly stale
548 548 tip 4:735c3ca72986
549 549 bar 0:bbd179dfa0a7
550 550 $ rm -f .hg/cache/tags2-visible
551 551 $ hg tags # cold cache
552 552 tip 4:735c3ca72986
553 553 bar 0:bbd179dfa0a7
554 554
555 555 Test tag rank with 3 heads:
556 556
557 557 $ cd ..
558 558 $ hg init t4
559 559 $ cd t4
560 560 $ echo foo > foo
561 561 $ hg add
562 562 adding foo
563 563 $ hg ci -m 'add foo' # rev 0
564 564 $ hg tag bar # rev 1 bar -> 0
565 565 $ hg tag -f bar # rev 2 bar -> 1
566 566 $ hg up -qC 0
567 567 $ hg tag -fr 2 bar # rev 3 bar -> 2
568 568 $ hg tags
569 569 tip 3:197c21bbbf2c
570 570 bar 2:6fa450212aeb
571 571 $ hg up -qC 0
572 572 $ hg tag -m 'retag rev 0' -fr 0 bar # rev 4 bar -> 0, but bar stays at 2
573 573
574 574 Bar should still point to rev 2:
575 575
576 576 $ hg tags
577 577 tip 4:3b4b14ed0202
578 578 bar 2:6fa450212aeb
579 579
580 580 Test that removing global/local tags does not get confused when trying
581 581 to remove a tag of type X which actually only exists as a type Y:
582 582
583 583 $ cd ..
584 584 $ hg init t5
585 585 $ cd t5
586 586 $ echo foo > foo
587 587 $ hg add
588 588 adding foo
589 589 $ hg ci -m 'add foo' # rev 0
590 590
591 591 $ hg tag -r 0 -l localtag
592 592 $ hg tag --remove localtag
593 593 abort: tag 'localtag' is not a global tag
594 594 [255]
595 595 $
596 596 $ hg tag -r 0 globaltag
597 597 $ hg tag --remove -l globaltag
598 598 abort: tag 'globaltag' is not a local tag
599 599 [255]
600 600 $ hg tags -v
601 601 tip 1:a0b6fe111088
602 602 localtag 0:bbd179dfa0a7 local
603 603 globaltag 0:bbd179dfa0a7
604 604
605 605 Test for issue3911
606 606
607 607 $ hg tag -r 0 -l localtag2
608 608 $ hg tag -l --remove localtag2
609 609 $ hg tags -v
610 610 tip 1:a0b6fe111088
611 611 localtag 0:bbd179dfa0a7 local
612 612 globaltag 0:bbd179dfa0a7
613 613
614 614 $ hg tag -r 1 -f localtag
615 615 $ hg tags -v
616 616 tip 2:5c70a037bb37
617 617 localtag 1:a0b6fe111088
618 618 globaltag 0:bbd179dfa0a7
619 619
620 620 $ hg tags -v
621 621 tip 2:5c70a037bb37
622 622 localtag 1:a0b6fe111088
623 623 globaltag 0:bbd179dfa0a7
624 624
625 625 $ hg tag -r 1 localtag2
626 626 $ hg tags -v
627 627 tip 3:bbfb8cd42be2
628 628 localtag2 1:a0b6fe111088
629 629 localtag 1:a0b6fe111088
630 630 globaltag 0:bbd179dfa0a7
631 631
632 632 $ hg tags -v
633 633 tip 3:bbfb8cd42be2
634 634 localtag2 1:a0b6fe111088
635 635 localtag 1:a0b6fe111088
636 636 globaltag 0:bbd179dfa0a7
637 637
638 638 $ cd ..
639 639
640 640 Create a repository with tags data to test .hgtags fnodes transfer
641 641
642 642 $ hg init tagsserver
643 643 $ cd tagsserver
644 644 $ cat > .hg/hgrc << EOF
645 645 > [experimental]
646 646 > bundle2-exp=True
647 647 > EOF
648 648 $ touch foo
649 649 $ hg -q commit -A -m initial
650 650 $ hg tag -m 'tag 0.1' 0.1
651 651 $ echo second > foo
652 652 $ hg commit -m second
653 653 $ hg tag -m 'tag 0.2' 0.2
654 654 $ hg tags
655 655 tip 3:40f0358cb314
656 656 0.2 2:f63cc8fe54e4
657 657 0.1 0:96ee1d7354c4
658 658 $ cd ..
659 659
660 660 Cloning should pull down hgtags fnodes mappings and write the cache file
661 661
662 662 $ hg --config experimental.bundle2-exp=True clone --pull tagsserver tagsclient
663 663 requesting all changes
664 664 adding changesets
665 665 adding manifests
666 666 adding file changes
667 667 added 4 changesets with 4 changes to 2 files
668 668 updating to branch default
669 669 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
670 670
671 671 Missing tags2* files means the cache wasn't written through the normal mechanism.
672 672
673 673 $ ls tagsclient/.hg/cache
674 674 branch2-served
675 675 hgtagsfnodes1
676 676 rbc-names-v1
677 677 rbc-revs-v1
678 678
679 679 Cache should contain the head only, even though other nodes have tags data
680 680
681 681 $ f --size --hexdump tagsclient/.hg/cache/hgtagsfnodes1
682 682 tagsclient/.hg/cache/hgtagsfnodes1: size=96
683 683 0000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
684 684 0010: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
685 685 0020: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
686 686 0030: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
687 687 0040: ff ff ff ff ff ff ff ff 40 f0 35 8c 19 e0 a7 d3 |........@.5.....|
688 688 0050: 8a 5c 6a 82 4d cf fb a5 87 d0 2f a3 1e 4f 2f 8a |.\j.M...../..O/.|
689 689
690 690 Running hg tags should produce tags2* file and not change cache
691 691
692 692 $ hg -R tagsclient tags
693 693 tip 3:40f0358cb314
694 694 0.2 2:f63cc8fe54e4
695 695 0.1 0:96ee1d7354c4
696 696
697 697 $ ls tagsclient/.hg/cache
698 698 branch2-served
699 699 hgtagsfnodes1
700 700 rbc-names-v1
701 701 rbc-revs-v1
702 702 tags2-visible
703 703
704 704 $ f --size --hexdump tagsclient/.hg/cache/hgtagsfnodes1
705 705 tagsclient/.hg/cache/hgtagsfnodes1: size=96
706 706 0000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
707 707 0010: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
708 708 0020: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
709 709 0030: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
710 710 0040: ff ff ff ff ff ff ff ff 40 f0 35 8c 19 e0 a7 d3 |........@.5.....|
711 711 0050: 8a 5c 6a 82 4d cf fb a5 87 d0 2f a3 1e 4f 2f 8a |.\j.M...../..O/.|
712 712
General Comments 0
You need to be logged in to leave comments. Login now