Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/commands.py @ 3786:8d603f8567ae
make hg commit <dirname> work again
author | Alexis S. L. Carvalho <alexis@cecm.usp.br> |
---|---|
date | Tue, 21 Nov 2006 20:00:15 -0200 |
parents | a88e02081a88 |
children | 17a11f4ff260 bd7011246fab |
comparison
equal
deleted
inserted
replaced
3785:6398ff7cb705 | 3786:8d603f8567ae |
---|---|
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 from demandload import demandload | 8 from demandload import demandload |
9 from node import * | 9 from node import * |
10 from i18n import gettext as _ | 10 from i18n import gettext as _ |
11 demandload(globals(), "os re sys signal imp urllib pdb shlex") | 11 demandload(globals(), "bisect os re sys signal imp urllib pdb shlex stat") |
12 demandload(globals(), "fancyopts ui hg util lock revlog bundlerepo") | 12 demandload(globals(), "fancyopts ui hg util lock revlog bundlerepo") |
13 demandload(globals(), "difflib patch time") | 13 demandload(globals(), "difflib patch time") |
14 demandload(globals(), "traceback errno version atexit") | 14 demandload(globals(), "traceback errno version atexit") |
15 demandload(globals(), "archival changegroup cmdutil hgweb.server sshserver") | 15 demandload(globals(), "archival changegroup cmdutil hgweb.server sshserver") |
16 | 16 |
421 fns, match, anypats = cmdutil.matchpats(repo, pats, opts) | 421 fns, match, anypats = cmdutil.matchpats(repo, pats, opts) |
422 if pats: | 422 if pats: |
423 status = repo.status(files=fns, match=match) | 423 status = repo.status(files=fns, match=match) |
424 modified, added, removed, deleted, unknown = status[:5] | 424 modified, added, removed, deleted, unknown = status[:5] |
425 files = modified + added + removed | 425 files = modified + added + removed |
426 slist = None | |
426 for f in fns: | 427 for f in fns: |
427 if f not in modified + added + removed: | 428 if f not in files: |
429 rf = repo.wjoin(f) | |
428 if f in unknown: | 430 if f in unknown: |
429 raise util.Abort(_("file %s not tracked!") % f) | 431 raise util.Abort(_("file %s not tracked!") % rf) |
430 else: | 432 try: |
431 raise util.Abort(_("file %s not found!") % f) | 433 mode = os.lstat(rf)[stat.ST_MODE] |
434 except OSError: | |
435 raise util.Abort(_("file %s not found!") % rf) | |
436 if stat.S_ISDIR(mode): | |
437 name = f + '/' | |
438 if slist is None: | |
439 slist = list(files) | |
440 slist.sort() | |
441 i = bisect.bisect(slist, name) | |
442 if i >= len(slist) or not slist[i].startswith(name): | |
443 raise util.Abort(_("no match under directory %s!") | |
444 % rf) | |
445 elif not stat.S_ISREG(mode): | |
446 raise util.Abort(_("can't commit %s: " | |
447 "unsupported file type!") % rf) | |
432 else: | 448 else: |
433 files = [] | 449 files = [] |
434 try: | 450 try: |
435 repo.commit(files, message, opts['user'], opts['date'], match, | 451 repo.commit(files, message, opts['user'], opts['date'], match, |
436 force_editor=opts.get('force_editor')) | 452 force_editor=opts.get('force_editor')) |