mercurial/commands.py
changeset 401 af4848f83e68
parent 396 8f8bb77d560e
child 403 fda7bb480020
equal deleted inserted replaced
400:8b067bde6679 401:af4848f83e68
   563 
   563 
   564     for f in c: print "C", f
   564     for f in c: print "C", f
   565     for f in a: print "A", f
   565     for f in a: print "A", f
   566     for f in d: print "R", f
   566     for f in d: print "R", f
   567     for f in u: print "?", f
   567     for f in u: print "?", f
       
   568 
       
   569 def tag(ui, repo, name, rev = None, **opts):
       
   570     """add a tag for the current tip or a given revision"""
       
   571     
       
   572     if name == "tip":
       
   573 	ui.warn("abort: 'tip' is a reserved name!\n")
       
   574 	return -1
       
   575 
       
   576     (c, a, d, u) = repo.diffdir(repo.root)
       
   577     for x in (c, a, d, u):
       
   578 	if ".hgtags" in x:
       
   579 	    ui.warn("abort: working copy of .hgtags is changed!\n")
       
   580             ui.status("(please commit .hgtags manually)\n")
       
   581 	    return -1
       
   582 
       
   583     if rev:
       
   584         r = hg.hex(repo.lookup(rev))
       
   585     else:
       
   586         r = hg.hex(repo.changelog.tip())
       
   587 
       
   588     add = 0
       
   589     if not os.path.exists(repo.wjoin(".hgtags")): add = 1
       
   590     repo.wfile(".hgtags", "a").write("%s %s\n" % (r, name))
       
   591     if add: repo.add([".hgtags"])
       
   592 
       
   593     if not opts['text']:
       
   594         opts['text'] = "Added tag %s for changeset %s" % (name, r)
       
   595 
       
   596     repo.commit([".hgtags"], opts['text'], opts['user'], opts['date'])
   568 
   597 
   569 def tags(ui, repo):
   598 def tags(ui, repo):
   570     """list repository tags"""
   599     """list repository tags"""
   571     
   600     
   572     l = repo.tagslist()
   601     l = repo.tagslist()
   665                       ('a', 'address', '', 'interface address'),
   694                       ('a', 'address', '', 'interface address'),
   666                       ('n', 'name', os.getcwd(), 'repository name'),
   695                       ('n', 'name', os.getcwd(), 'repository name'),
   667                       ('t', 'templates', "", 'template map')],
   696                       ('t', 'templates', "", 'template map')],
   668               "hg serve [options]"),
   697               "hg serve [options]"),
   669     "status": (status, [], 'hg status'),
   698     "status": (status, [], 'hg status'),
       
   699     "tag": (tag,  [('t', 'text', "", 'commit text'),
       
   700                    ('d', 'date', "", 'date'),
       
   701                    ('u', 'user', "", 'user')],
       
   702             'hg tag [options] <name> [rev]'),
   670     "tags": (tags, [], 'hg tags'),
   703     "tags": (tags, [], 'hg tags'),
   671     "tip": (tip, [], 'hg tip'),
   704     "tip": (tip, [], 'hg tip'),
   672     "undo": (undo, [], 'hg undo'),
   705     "undo": (undo, [], 'hg undo'),
   673     "update|up|checkout|co|resolve": (update,
   706     "update|up|checkout|co|resolve": (update,
   674                                       [('m', 'merge', None,
   707                                       [('m', 'merge', None,