Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/cmdutil.py @ 8709:b9e0ddb04c5c
commit: move explicit file checking into repo.commit
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Mon, 01 Jun 2009 21:51:00 -0500 |
parents | 0550dfe4fca1 |
children | f037187a6f68 |
comparison
equal
deleted
inserted
replaced
8708:a645904c88c4 | 8709:b9e0ddb04c5c |
---|---|
1192 # extract addremove carefully -- this function can be called from a command | 1192 # extract addremove carefully -- this function can be called from a command |
1193 # that doesn't support addremove | 1193 # that doesn't support addremove |
1194 if opts.get('addremove'): | 1194 if opts.get('addremove'): |
1195 addremove(repo, pats, opts) | 1195 addremove(repo, pats, opts) |
1196 | 1196 |
1197 m = match(repo, pats, opts) | 1197 return commitfunc(ui, repo, message, match(repo, pats, opts), opts) |
1198 if pats: | |
1199 modified, added, removed = repo.status(match=m)[:3] | |
1200 files = sorted(modified + added + removed) | |
1201 | |
1202 def is_dir(f): | |
1203 name = f + '/' | |
1204 i = bisect.bisect(files, name) | |
1205 return i < len(files) and files[i].startswith(name) | |
1206 | |
1207 for f in m.files(): | |
1208 if f == '.': | |
1209 continue | |
1210 if f not in files: | |
1211 rf = repo.wjoin(f) | |
1212 rel = repo.pathto(f) | |
1213 try: | |
1214 mode = os.lstat(rf)[stat.ST_MODE] | |
1215 except OSError: | |
1216 if is_dir(f): # deleted directory ? | |
1217 continue | |
1218 raise util.Abort(_("file %s not found!") % rel) | |
1219 if stat.S_ISDIR(mode): | |
1220 if not is_dir(f): | |
1221 raise util.Abort(_("no match under directory %s!") | |
1222 % rel) | |
1223 elif not (stat.S_ISREG(mode) or stat.S_ISLNK(mode)): | |
1224 raise util.Abort(_("can't commit %s: " | |
1225 "unsupported file type!") % rel) | |
1226 elif f not in repo.dirstate: | |
1227 raise util.Abort(_("file %s not tracked!") % rel) | |
1228 m = matchfiles(repo, files) | |
1229 try: | |
1230 return commitfunc(ui, repo, message, m, opts) | |
1231 except ValueError, inst: | |
1232 raise util.Abort(str(inst)) | |
1233 | 1198 |
1234 def commiteditor(repo, ctx): | 1199 def commiteditor(repo, ctx): |
1235 if ctx.description(): | 1200 if ctx.description(): |
1236 return ctx.description() | 1201 return ctx.description() |
1237 return commitforceeditor(repo, ctx) | 1202 return commitforceeditor(repo, ctx) |