# HG changeset patch # User Bryan O'Sullivan # Date 1122678147 28800 # Node ID 80fd2958235a06021cff7c5c9f9d5bf0a6d123a3 # Parent b65af904d6d7ca1bc82f204ab5af74db820bdb6d Adapt commit to use file matching code. The code is slightly complicated by the need to commit all outstanding changes in the repository if no file names are given (other commands operate on the current directory and its subdirectories in this case). localrepository.changes has acquired an optional match parameter, to let it filter out include/exclude options. diff -r b65af904d6d7 -r 80fd2958235a doc/hg.1.txt --- a/doc/hg.1.txt Fri Jul 29 12:30:12 2005 -0800 +++ b/doc/hg.1.txt Fri Jul 29 15:02:27 2005 -0800 @@ -100,11 +100,11 @@ options: -U, --noupdate do not update the new working directory -commit [-A -t -l -m -u -d ] [files...]:: +commit [options] [files...]:: Commit changes to the given files into the repository. If a list of files is omitted, all changes reported by "hg status" - will be commited. + from the root of the repository will be commited. The HGEDITOR or EDITOR environment variables are used to start an editor to add a commit comment. @@ -112,6 +112,8 @@ Options: -A, --addremove run addremove during commit + -I, --include include names matching the given patterns + -X, --exclude exclude names matching the given patterns -m, --message use as commit message -l, --logfile show the commit message for the given file -d, --date record datecode as commit date diff -r b65af904d6d7 -r 80fd2958235a mercurial/commands.py --- a/mercurial/commands.py Fri Jul 29 12:30:12 2005 -0800 +++ b/mercurial/commands.py Fri Jul 29 15:02:27 2005 -0800 @@ -468,7 +468,7 @@ d.close() -def commit(ui, repo, *files, **opts): +def commit(ui, repo, *pats, **opts): """commit the specified files or all outstanding changes""" if opts['text']: ui.warn("Warning: -t and --text is deprecated," @@ -482,8 +482,18 @@ ui.warn("Can't read commit message %s: %s\n" % (logfile, why)) if opts['addremove']: - addremove(ui, repo, *files) - repo.commit(relpath(repo, files), message, opts['user'], opts['date']) + addremove(ui, repo, *pats, **opts) + cwd = repo.getcwd() + if not pats and cwd: + opts['include'] = [os.path.join(cwd, i) for i in opts['include']] + opts['exclude'] = [os.path.join(cwd, x) for x in opts['exclude']] + fns, match = matchpats((pats and repo.getcwd()) or '', pats, opts) + if pats: + c, a, d, u = repo.changes(files = fns, match = match) + files = c + a + [fn for fn in d if repo.dirstate.state(fn) == 'r'] + else: + files = [] + repo.commit(files, message, opts['user'], opts['date'], match) def copy(ui, repo, source, dest): """mark a file as copied or renamed for the next commit""" @@ -1140,6 +1150,8 @@ "^commit|ci": (commit, [('A', 'addremove', None, 'run add/remove during commit'), + ('I', 'include', [], 'include path in search'), + ('X', 'exclude', [], 'exclude path from search'), ('m', 'message', "", 'commit message'), ('t', 'text', "", 'commit message (deprecated: use -m)'), ('l', 'logfile', "", 'commit message file'), diff -r b65af904d6d7 -r 80fd2958235a mercurial/hg.py --- a/mercurial/hg.py Fri Jul 29 12:30:12 2005 -0800 +++ b/mercurial/hg.py Fri Jul 29 15:02:27 2005 -0800 @@ -773,7 +773,8 @@ if update_dirstate: self.dirstate.setparents(n, nullid) - def commit(self, files = None, text = "", user = None, date = None): + def commit(self, files = None, text = "", user = None, date = None, + match = util.always): commit = [] remove = [] if files: @@ -786,7 +787,7 @@ else: self.ui.warn("%s not tracked!\n" % f) else: - (c, a, d, u) = self.changes() + (c, a, d, u) = self.changes(match = match) commit = c + a remove = d