Show More
@@ -8,6 +8,7 b'' | |||||
8 | from node import * |
|
8 | from node import * | |
9 | from i18n import _ |
|
9 | from i18n import _ | |
10 | import os, sys, atexit, signal, pdb, traceback, socket, errno, shlex |
|
10 | import os, sys, atexit, signal, pdb, traceback, socket, errno, shlex | |
|
11 | import bisect, stat | |||
11 | import mdiff, bdiff, util, templater, patch, commands, hg, lock, time |
|
12 | import mdiff, bdiff, util, templater, patch, commands, hg, lock, time | |
12 | import fancyopts, revlog, version, extensions, hook |
|
13 | import fancyopts, revlog, version, extensions, hook | |
13 |
|
14 | |||
@@ -1275,3 +1276,45 b' def walkchangerevs(ui, repo, pats, chang' | |||||
1275 | for rev in nrevs: |
|
1276 | for rev in nrevs: | |
1276 | yield 'iter', rev, None |
|
1277 | yield 'iter', rev, None | |
1277 | return iterate(), matchfn |
|
1278 | return iterate(), matchfn | |
|
1279 | ||||
|
1280 | def commit(ui, repo, commitfunc, pats, opts): | |||
|
1281 | '''commit the specified files or all outstanding changes''' | |||
|
1282 | message = logmessage(opts) | |||
|
1283 | ||||
|
1284 | if opts['addremove']: | |||
|
1285 | addremove(repo, pats, opts) | |||
|
1286 | fns, match, anypats = matchpats(repo, pats, opts) | |||
|
1287 | if pats: | |||
|
1288 | status = repo.status(files=fns, match=match) | |||
|
1289 | modified, added, removed, deleted, unknown = status[:5] | |||
|
1290 | files = modified + added + removed | |||
|
1291 | slist = None | |||
|
1292 | for f in fns: | |||
|
1293 | if f == '.': | |||
|
1294 | continue | |||
|
1295 | if f not in files: | |||
|
1296 | rf = repo.wjoin(f) | |||
|
1297 | try: | |||
|
1298 | mode = os.lstat(rf)[stat.ST_MODE] | |||
|
1299 | except OSError: | |||
|
1300 | raise util.Abort(_("file %s not found!") % rf) | |||
|
1301 | if stat.S_ISDIR(mode): | |||
|
1302 | name = f + '/' | |||
|
1303 | if slist is None: | |||
|
1304 | slist = list(files) | |||
|
1305 | slist.sort() | |||
|
1306 | i = bisect.bisect(slist, name) | |||
|
1307 | if i >= len(slist) or not slist[i].startswith(name): | |||
|
1308 | raise util.Abort(_("no match under directory %s!") | |||
|
1309 | % rf) | |||
|
1310 | elif not (stat.S_ISREG(mode) or stat.S_ISLNK(mode)): | |||
|
1311 | raise util.Abort(_("can't commit %s: " | |||
|
1312 | "unsupported file type!") % rf) | |||
|
1313 | elif f not in repo.dirstate: | |||
|
1314 | raise util.Abort(_("file %s not tracked!") % rf) | |||
|
1315 | else: | |||
|
1316 | files = [] | |||
|
1317 | try: | |||
|
1318 | return commitfunc(ui, repo, files, message, match, opts) | |||
|
1319 | except ValueError, inst: | |||
|
1320 | raise util.Abort(str(inst)) |
@@ -8,7 +8,7 b'' | |||||
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 |
|
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 | |
@@ -428,46 +428,10 b' def commit(ui, repo, *pats, **opts):' | |||||
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 |
|
|
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 |
General Comments 0
You need to be logged in to leave comments.
Login now