Show More
@@ -119,22 +119,43 b' class localrepository(repo.repository):' | |||
|
119 | 119 | |
|
120 | 120 | self.hook('pretag', throw=True, node=hex(node), tag=name, local=local) |
|
121 | 121 | |
|
122 | def writetag(fp, name, munge, prevtags): | |
|
123 | if prevtags and prevtags[-1] != '\n': | |
|
124 | fp.write('\n') | |
|
125 | fp.write('%s %s\n' % (hex(node), munge and munge(name) or name)) | |
|
126 | fp.close() | |
|
127 | self.hook('tag', node=hex(node), tag=name, local=local) | |
|
128 | ||
|
129 | prevtags = '' | |
|
122 | 130 | if local: |
|
131 | try: | |
|
132 | fp = self.opener('localtags', 'r+') | |
|
133 | except IOError, err: | |
|
134 | fp = self.opener('localtags', 'a') | |
|
135 | else: | |
|
136 | prevtags = fp.read() | |
|
137 | ||
|
123 | 138 | # local tags are stored in the current charset |
|
124 | self.opener('localtags', 'a').write('%s %s\n' % (hex(node), name)) | |
|
125 | self.hook('tag', node=hex(node), tag=name, local=local) | |
|
139 | writetag(fp, name, None, prevtags) | |
|
126 | 140 | return |
|
127 | 141 | |
|
142 | if use_dirstate: | |
|
143 | try: | |
|
144 | fp = self.wfile('.hgtags', 'rb+') | |
|
145 | except IOError, err: | |
|
146 | fp = self.wfile('.hgtags', 'ab') | |
|
147 | else: | |
|
148 | prevtags = fp.read() | |
|
149 | else: | |
|
150 | try: | |
|
151 | prevtags = self.filectx('.hgtags', parent).data() | |
|
152 | except revlog.LookupError: | |
|
153 | pass | |
|
154 | fp = self.wfile('.hgtags', 'wb') | |
|
155 | ||
|
128 | 156 | # committed tags are stored in UTF-8 |
|
129 | line = '%s %s\n' % (hex(node), util.fromlocal(name)) | |
|
130 | if use_dirstate: | |
|
131 | self.wfile('.hgtags', 'ab').write(line) | |
|
132 | else: | |
|
133 | try: | |
|
134 | ntags = self.filectx('.hgtags', parent).data() | |
|
135 | except revlog.LookupError: | |
|
136 | ntags = '' | |
|
137 | self.wfile('.hgtags', 'wb').write(ntags + line) | |
|
157 | writetag(fp, name, util.fromlocal, prevtags) | |
|
158 | ||
|
138 | 159 | if use_dirstate and self.dirstate.state('.hgtags') == '?': |
|
139 | 160 | self.add(['.hgtags']) |
|
140 | 161 |
@@ -40,6 +40,7 b' adding file changes' | |||
|
40 | 40 | added 3 changesets with 2 changes to 2 files |
|
41 | 41 | (run 'hg update' to get a working copy) |
|
42 | 42 | pretag hook: HG_LOCAL=0 HG_NODE=4c52fb2e402287dd5dc052090682536c8406c321 HG_TAG=a |
|
43 | tag hook: HG_LOCAL=0 HG_NODE=4c52fb2e402287dd5dc052090682536c8406c321 HG_TAG=a | |
|
43 | 44 | precommit hook: HG_PARENT1=4c52fb2e402287dd5dc052090682536c8406c321 |
|
44 | 45 | pretxncommit hook: HG_NODE=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 HG_PARENT1=4c52fb2e402287dd5dc052090682536c8406c321 |
|
45 | 46 | 4:8ea2ef7ad3e8 |
@@ -27,4 +27,17 b' cat .hg/localtags' | |||
|
27 | 27 | hg tag -l 'xx |
|
28 | 28 | newline' |
|
29 | 29 | hg tag -l 'xx:xx' |
|
30 | true | |
|
30 | ||
|
31 | echo % issue 601 | |
|
32 | mv .hg/localtags .hg/ltags | |
|
33 | head -1 .hg/ltags | tr -d '\n' > .hg/localtags | |
|
34 | cat .hg/localtags | |
|
35 | hg tag -l localnewline | |
|
36 | cat .hg/localtags | |
|
37 | ||
|
38 | mv .hgtags hgtags | |
|
39 | head -1 hgtags | tr -d '\n' > .hgtags | |
|
40 | hg ci -d '1000000 0' -m'broken manual edit of .hgtags' | |
|
41 | cat .hgtags | |
|
42 | hg tag -d '1000000 0' newline | |
|
43 | cat .hgtags |
@@ -30,3 +30,8 b' 0acdaf8983679e0aac16e811534eb49d7ee1f2b4' | |||
|
30 | 30 | 3ecf002a1c572a2f3bb4e665417e60fca65bbd42 bleah1 |
|
31 | 31 | abort: '\n' cannot be used in a tag name |
|
32 | 32 | abort: ':' cannot be used in a tag name |
|
33 | % issue 601 | |
|
34 | 3ecf002a1c572a2f3bb4e665417e60fca65bbd42 bleah13ecf002a1c572a2f3bb4e665417e60fca65bbd42 bleah1 | |
|
35 | f68b039e72eacbb2e68b0543e1f6e50990aa2bb5 localnewline | |
|
36 | 0acdaf8983679e0aac16e811534eb49d7ee1f2b4 foobar0acdaf8983679e0aac16e811534eb49d7ee1f2b4 foobar | |
|
37 | 6ae703d793c8b1f097116869275ecd97b2977a2b newline |
General Comments 0
You need to be logged in to leave comments.
Login now