mercurial/commands.py
changeset 813 80fd2958235a
parent 812 b65af904d6d7
child 814 0902ffece4b4
equal deleted inserted replaced
812:b65af904d6d7 813:80fd2958235a
   466     if not opts['noupdate']:
   466     if not opts['noupdate']:
   467         update(ui, repo)
   467         update(ui, repo)
   468 
   468 
   469     d.close()
   469     d.close()
   470 
   470 
   471 def commit(ui, repo, *files, **opts):
   471 def commit(ui, repo, *pats, **opts):
   472     """commit the specified files or all outstanding changes"""
   472     """commit the specified files or all outstanding changes"""
   473     if opts['text']:
   473     if opts['text']:
   474         ui.warn("Warning: -t and --text is deprecated,"
   474         ui.warn("Warning: -t and --text is deprecated,"
   475                 " please use -m or --message instead.\n")
   475                 " please use -m or --message instead.\n")
   476     message = opts['message'] or opts['text']
   476     message = opts['message'] or opts['text']
   480             message = open(logfile).read()
   480             message = open(logfile).read()
   481         except IOError, why:
   481         except IOError, why:
   482             ui.warn("Can't read commit message %s: %s\n" % (logfile, why))
   482             ui.warn("Can't read commit message %s: %s\n" % (logfile, why))
   483 
   483 
   484     if opts['addremove']:
   484     if opts['addremove']:
   485         addremove(ui, repo, *files)
   485         addremove(ui, repo, *pats, **opts)
   486     repo.commit(relpath(repo, files), message, opts['user'], opts['date'])
   486     cwd = repo.getcwd()
       
   487     if not pats and cwd:
       
   488         opts['include'] = [os.path.join(cwd, i) for i in opts['include']]
       
   489         opts['exclude'] = [os.path.join(cwd, x) for x in opts['exclude']]
       
   490     fns, match = matchpats((pats and repo.getcwd()) or '', pats, opts)
       
   491     if pats:
       
   492         c, a, d, u = repo.changes(files = fns, match = match)
       
   493         files = c + a + [fn for fn in d if repo.dirstate.state(fn) == 'r']
       
   494     else:
       
   495         files = []
       
   496     repo.commit(files, message, opts['user'], opts['date'], match)
   487 
   497 
   488 def copy(ui, repo, source, dest):
   498 def copy(ui, repo, source, dest):
   489     """mark a file as copied or renamed for the next commit"""
   499     """mark a file as copied or renamed for the next commit"""
   490     return repo.copy(*relpath(repo, (source, dest)))
   500     return repo.copy(*relpath(repo, (source, dest)))
   491 
   501 
  1138          [('U', 'noupdate', None, 'skip update after cloning')],
  1148          [('U', 'noupdate', None, 'skip update after cloning')],
  1139          'hg clone [-U] SOURCE [DEST]'),
  1149          'hg clone [-U] SOURCE [DEST]'),
  1140     "^commit|ci":
  1150     "^commit|ci":
  1141         (commit,
  1151         (commit,
  1142          [('A', 'addremove', None, 'run add/remove during commit'),
  1152          [('A', 'addremove', None, 'run add/remove during commit'),
       
  1153           ('I', 'include', [], 'include path in search'),
       
  1154           ('X', 'exclude', [], 'exclude path from search'),
  1143           ('m', 'message', "", 'commit message'),
  1155           ('m', 'message', "", 'commit message'),
  1144           ('t', 'text', "", 'commit message (deprecated: use -m)'),
  1156           ('t', 'text', "", 'commit message (deprecated: use -m)'),
  1145           ('l', 'logfile', "", 'commit message file'),
  1157           ('l', 'logfile', "", 'commit message file'),
  1146           ('d', 'date', "", 'date code'),
  1158           ('d', 'date', "", 'date code'),
  1147           ('u', 'user', "", 'user')],
  1159           ('u', 'user', "", 'user')],