comparison mercurial/commands.py @ 5034:c0417a319e39

commands: move commit to cmdutil as wrapper for commit-like functions
author Bryan O'Sullivan <bos@serpentine.com>
date Tue, 31 Jul 2007 16:28:05 -0700
parents cf67b5f3743d
children 47a8ea1eb2c3
comparison
equal deleted inserted replaced
5033:1b07668b8cc3 5034:c0417a319e39
6 # of the GNU General Public License, incorporated herein by reference. 6 # of the GNU General Public License, incorporated herein by reference.
7 7
8 import demandimport; demandimport.enable() 8 import demandimport; demandimport.enable()
9 from node import * 9 from node import *
10 from i18n import _ 10 from i18n import _
11 import bisect, os, re, sys, urllib, stat 11 import os, re, sys, urllib
12 import ui, hg, util, revlog, bundlerepo, extensions 12 import ui, hg, util, revlog, bundlerepo, extensions
13 import difflib, patch, time, help, mdiff, tempfile 13 import difflib, patch, time, help, mdiff, tempfile
14 import errno, version, socket 14 import errno, version, socket
15 import archival, changegroup, cmdutil, hgweb.server, sshserver 15 import archival, changegroup, cmdutil, hgweb.server, sshserver
16 16
426 will be committed. 426 will be committed.
427 427
428 If no commit message is specified, the editor configured in your hgrc 428 If no commit message is specified, the editor configured in your hgrc
429 or in the EDITOR environment variable is started to enter a message. 429 or in the EDITOR environment variable is started to enter a message.
430 """ 430 """
431 message = cmdutil.logmessage(opts) 431 def commitfunc(ui, repo, files, message, match, opts):
432 432 return repo.commit(files, message, opts['user'], opts['date'], match,
433 if opts['addremove']: 433 force_editor=opts.get('force_editor'))
434 cmdutil.addremove(repo, pats, opts) 434 cmdutil.commit(ui, repo, commitfunc, pats, opts)
435 fns, match, anypats = cmdutil.matchpats(repo, pats, opts)
436 if pats:
437 status = repo.status(files=fns, match=match)
438 modified, added, removed, deleted, unknown = status[:5]
439 files = modified + added + removed
440 slist = None
441 for f in fns:
442 if f == '.':
443 continue
444 if f not in files:
445 rf = repo.wjoin(f)
446 try:
447 mode = os.lstat(rf)[stat.ST_MODE]
448 except OSError:
449 raise util.Abort(_("file %s not found!") % rf)
450 if stat.S_ISDIR(mode):
451 name = f + '/'
452 if slist is None:
453 slist = list(files)
454 slist.sort()
455 i = bisect.bisect(slist, name)
456 if i >= len(slist) or not slist[i].startswith(name):
457 raise util.Abort(_("no match under directory %s!")
458 % rf)
459 elif not (stat.S_ISREG(mode) or stat.S_ISLNK(mode)):
460 raise util.Abort(_("can't commit %s: "
461 "unsupported file type!") % rf)
462 elif f not in repo.dirstate:
463 raise util.Abort(_("file %s not tracked!") % rf)
464 else:
465 files = []
466 try:
467 repo.commit(files, message, opts['user'], opts['date'], match,
468 force_editor=opts.get('force_editor'))
469 except ValueError, inst:
470 raise util.Abort(str(inst))
471 435
472 def docopy(ui, repo, pats, opts): 436 def docopy(ui, repo, pats, opts):
473 # called with the repo lock held 437 # called with the repo lock held
474 # 438 #
475 # hgsep => pathname that uses "/" to separate directories 439 # hgsep => pathname that uses "/" to separate directories