comparison mercurial/localrepo.py @ 8709:b9e0ddb04c5c

commit: move explicit file checking into repo.commit
author Matt Mackall <mpm@selenic.com>
date Mon, 01 Jun 2009 21:51:00 -0500
parents 0550dfe4fca1
children bcb6e5bebd93
comparison
equal deleted inserted replaced
8708:a645904c88c4 8709:b9e0ddb04c5c
12 import lock, transaction, store, encoding 12 import lock, transaction, store, encoding
13 import util, extensions, hook, error 13 import util, extensions, hook, error
14 import match as match_ 14 import match as match_
15 import merge as merge_ 15 import merge as merge_
16 from lock import release 16 from lock import release
17 import weakref, stat, errno, os, time, inspect 17 import weakref, stat, errno, os, time, inspect, bisect
18 propertycache = util.propertycache 18 propertycache = util.propertycache
19 19
20 class localrepository(repo.repository): 20 class localrepository(repo.repository):
21 capabilities = set(('lookup', 'changegroupsubset', 'branchmap')) 21 capabilities = set(('lookup', 'changegroupsubset', 'branchmap'))
22 supported = set('revlogv1 store fncache'.split()) 22 supported = set('revlogv1 store fncache'.split())
779 779
780 Revision information is gathered from the working directory, 780 Revision information is gathered from the working directory,
781 match can be used to filter the committed files. If editor is 781 match can be used to filter the committed files. If editor is
782 supplied, it is called to get a commit message. 782 supplied, it is called to get a commit message.
783 """ 783 """
784
784 wlock = self.wlock() 785 wlock = self.wlock()
785 try: 786 try:
786 p1, p2 = self.dirstate.parents() 787 p1, p2 = self.dirstate.parents()
787 788
788 if (not force and p2 != nullid and match and 789 if (not force and p2 != nullid and match and
789 (match.files() or match.anypats())): 790 (match.files() or match.anypats())):
790 raise util.Abort(_('cannot partially commit a merge ' 791 raise util.Abort(_('cannot partially commit a merge '
791 '(do not specify files or patterns)')) 792 '(do not specify files or patterns)'))
792 793
794 def fail(f, msg):
795 raise util.Abort('%s: %s' % (f, msg))
796
797 if not match:
798 match = match_.always(self.root, '')
799
800 if not force:
801 vdirs = []
802 match.dir = vdirs.append
803 match.bad = fail
804
793 changes = self.status(match=match, clean=force) 805 changes = self.status(match=match, clean=force)
794 if force: 806 if force:
795 changes[0].extend(changes[6]) # mq may commit unchanged files 807 changes[0].extend(changes[6]) # mq may commit unchanged files
808
809 # make sure all explicit patterns are matched
810 if not force and match.files():
811 files = sorted(changes[0] + changes[1] + changes[2])
812
813 for f in match.files():
814 if f == '.' or f in files: # matched
815 continue
816 if f in changes[3]: # missing
817 fail(f, _('file not found!'))
818 if f in vdirs: # visited directory
819 d = f + '/'
820 i = bisect.bisect(files, d)
821 if i >= len(files) or not files[i].startswith(d):
822 fail(f, _("no match under directory!"))
823 elif f not in self.dirstate:
824 fail(f, _("file not tracked!"))
796 825
797 if (not force and not extra.get("close") and p2 == nullid 826 if (not force and not extra.get("close") and p2 == nullid
798 and not (changes[0] or changes[1] or changes[2]) 827 and not (changes[0] or changes[1] or changes[2])
799 and self[None].branch() == self['.'].branch()): 828 and self[None].branch() == self['.'].branch()):
800 self.ui.status(_("nothing changed\n")) 829 self.ui.status(_("nothing changed\n"))