mercurial/commands.py
changeset 2694 0fb28dbf0dc7
parent 2673 109a22f5434a
child 2717 14ebe97542a7
equal deleted inserted replaced
2693:8342c0286184 2694:0fb28dbf0dc7
    37 def relpath(repo, args):
    37 def relpath(repo, args):
    38     cwd = repo.getcwd()
    38     cwd = repo.getcwd()
    39     if cwd:
    39     if cwd:
    40         return [util.normpath(os.path.join(cwd, x)) for x in args]
    40         return [util.normpath(os.path.join(cwd, x)) for x in args]
    41     return args
    41     return args
       
    42 
       
    43 def logmessage(**opts):
       
    44     """ get the log message according to -m and -l option """
       
    45     message = opts['message']
       
    46     logfile = opts['logfile']
       
    47 
       
    48     if message and logfile:
       
    49         raise util.Abort(_('options --message and --logfile are mutually '
       
    50                            'exclusive'))
       
    51     if not message and logfile:
       
    52         try:
       
    53             if logfile == '-':
       
    54                 message = sys.stdin.read()
       
    55             else:
       
    56                 message = open(logfile).read()
       
    57         except IOError, inst:
       
    58             raise util.Abort(_("can't read commit message '%s': %s") %
       
    59                              (logfile, inst.strerror))
       
    60     return message
    42 
    61 
    43 def matchpats(repo, pats=[], opts={}, head=''):
    62 def matchpats(repo, pats=[], opts={}, head=''):
    44     cwd = repo.getcwd()
    63     cwd = repo.getcwd()
    45     if not pats and cwd:
    64     if not pats and cwd:
    46         opts['include'] = [os.path.join(cwd, i) for i in opts['include']]
    65         opts['include'] = [os.path.join(cwd, i) for i in opts['include']]
   987     will be committed.
  1006     will be committed.
   988 
  1007 
   989     If no commit message is specified, the editor configured in your hgrc
  1008     If no commit message is specified, the editor configured in your hgrc
   990     or in the EDITOR environment variable is started to enter a message.
  1009     or in the EDITOR environment variable is started to enter a message.
   991     """
  1010     """
   992     message = opts['message']
  1011     message = logmessage(**opts)
   993     logfile = opts['logfile']
       
   994 
       
   995     if message and logfile:
       
   996         raise util.Abort(_('options --message and --logfile are mutually '
       
   997                            'exclusive'))
       
   998     if not message and logfile:
       
   999         try:
       
  1000             if logfile == '-':
       
  1001                 message = sys.stdin.read()
       
  1002             else:
       
  1003                 message = open(logfile).read()
       
  1004         except IOError, inst:
       
  1005             raise util.Abort(_("can't read commit message '%s': %s") %
       
  1006                              (logfile, inst.strerror))
       
  1007 
  1012 
  1008     if opts['addremove']:
  1013     if opts['addremove']:
  1009         addremove_lock(ui, repo, pats, opts)
  1014         addremove_lock(ui, repo, pats, opts)
  1010     fns, match, anypats = matchpats(repo, pats, opts)
  1015     fns, match, anypats = matchpats(repo, pats, opts)
  1011     if pats:
  1016     if pats: