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