# HG changeset patch # User timeless # Date 1459965137 0 # Node ID d77b790bd8d68f4d5c980dcd8f5eb7d3f45a14c5 # Parent f1de5a612a74fc3e5bb5e9df4553d906cc1e8052 localrepo: refactor commit argument check as checkcommitpatterns diff -r f1de5a612a74 -r d77b790bd8d6 mercurial/localrepo.py --- 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)