##// END OF EJS Templates
Break core of repo.tag into dirstate/hook-free repo._tag for convert-repo
Brendan Cully -
r4118:35b39097 default
parent child Browse files
Show More
@@ -217,6 +217,37 b' class localrepository(repo.repository):'
217 217
218 218 tag_disallowed = ':\r\n'
219 219
220 def _tag(self, name, node, message, local, user, date, parent=None):
221 use_dirstate = parent is None
222
223 for c in self.tag_disallowed:
224 if c in name:
225 raise util.Abort(_('%r cannot be used in a tag name') % c)
226
227 self.hook('pretag', throw=True, node=hex(node), tag=name, local=local)
228
229 if local:
230 # local tags are stored in the current charset
231 self.opener('localtags', 'a').write('%s %s\n' % (hex(node), name))
232 self.hook('tag', node=hex(node), tag=name, local=local)
233 return
234
235 # committed tags are stored in UTF-8
236 line = '%s %s\n' % (hex(node), util.fromlocal(name))
237 if use_dirstate:
238 self.wfile('.hgtags', 'ab').write(line)
239 else:
240 ntags = self.filectx('.hgtags', parent).data()
241 self.wfile('.hgtags', 'ab').write(ntags + line)
242 if use_dirstate and self.dirstate.state('.hgtags') == '?':
243 self.add(['.hgtags'])
244
245 tagnode = self.commit(['.hgtags'], message, user, date, p1=parent)
246
247 self.hook('tag', node=hex(node), tag=name, local=local)
248
249 return tagnode
250
220 251 def tag(self, name, node, message, local, user, date):
221 252 '''tag a revision with a symbolic name.
222 253
@@ -235,31 +266,13 b' class localrepository(repo.repository):'
235 266
236 267 date: date tuple to use if committing'''
237 268
238 for c in self.tag_disallowed:
239 if c in name:
240 raise util.Abort(_('%r cannot be used in a tag name') % c)
241
242 self.hook('pretag', throw=True, node=hex(node), tag=name, local=local)
243
244 if local:
245 # local tags are stored in the current charset
246 self.opener('localtags', 'a').write('%s %s\n' % (hex(node), name))
247 self.hook('tag', node=hex(node), tag=name, local=local)
248 return
249
250 269 for x in self.status()[:5]:
251 270 if '.hgtags' in x:
252 271 raise util.Abort(_('working copy of .hgtags is changed '
253 272 '(please commit .hgtags manually)'))
254 273
255 # committed tags are stored in UTF-8
256 line = '%s %s\n' % (hex(node), util.fromlocal(name))
257 self.wfile('.hgtags', 'ab').write(line)
258 if self.dirstate.state('.hgtags') == '?':
259 self.add(['.hgtags'])
260 274
261 self.commit(['.hgtags'], message, user, date)
262 self.hook('tag', node=hex(node), tag=name, local=local)
275 self._tag(name, node, message, local, user, date)
263 276
264 277 def tags(self):
265 278 '''return a mapping of tag to node'''
General Comments 0
You need to be logged in to leave comments. Login now