Mercurial > hg
changeset 28813:d77b790bd8d6
localrepo: refactor commit argument check as checkcommitpatterns
author | timeless <timeless@mozdev.org> |
---|---|
date | Wed, 06 Apr 2016 17:52:17 +0000 |
parents | f1de5a612a74 |
children | 1f65f291a5b7 |
files | mercurial/localrepo.py |
diffstat | 1 files changed, 24 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/localrepo.py Tue Apr 05 04:26:20 2016 +0000 +++ b/mercurial/localrepo.py Wed Apr 06 17:52:17 2016 +0000 @@ -1477,6 +1477,28 @@ return fparent1 + def checkcommitpatterns(self, wctx, vdirs, match, status, fail): + """check for commit arguments that aren't commitable""" + force = False + if not force and (match.isexact() or match.prefix()): + matched = set(status.modified + status.added + status.removed) + + for f in match.files(): + f = self.dirstate.normalize(f) + if f == '.' or f in matched or f in wctx.substate: + continue + if f in status.deleted: + fail(f, _('file not found!')) + if f in vdirs: # visited directory + d = f + '/' + for mf in matched: + if mf.startswith(d): + break + else: + fail(f, _("no match under directory!")) + elif f not in self.dirstate: + fail(f, _("file not tracked!")) + @unfilteredmethod def commit(self, text="", user=None, date=None, match=None, force=False, editor=False, extra=None): @@ -1571,24 +1593,8 @@ status.removed.insert(0, '.hgsubstate') # make sure all explicit patterns are matched - if not force and (match.isexact() or match.prefix()): - matched = set(status.modified + status.added + status.removed) - - for f in match.files(): - f = self.dirstate.normalize(f) - if f == '.' or f in matched or f in wctx.substate: - continue - if f in status.deleted: - fail(f, _('file not found!')) - if f in vdirs: # visited directory - d = f + '/' - for mf in matched: - if mf.startswith(d): - break - else: - fail(f, _("no match under directory!")) - elif f not in self.dirstate: - fail(f, _("file not tracked!")) + if not force: + self.checkcommitpatterns(wctx, vdirs, match, status, fail) cctx = context.workingcommitctx(self, status, text, user, date, extra)