comparison mercurial/localrepo.py @ 8405:7cbf8fcd2453

commit: push repo lock down into _commitctx
author Matt Mackall <mpm@selenic.com>
date Thu, 14 May 2009 13:20:40 -0500
parents a2bc39ade36b
children 223000a687b0
comparison
equal deleted inserted replaced
8404:a2bc39ade36b 8405:7cbf8fcd2453
772 wlock = lock = None 772 wlock = lock = None
773 if extra.get("close"): 773 if extra.get("close"):
774 force = True 774 force = True
775 if files: 775 if files:
776 files = list(set(files)) 776 files = list(set(files))
777 try: 777
778 wlock = self.wlock() 778 wlock = self.wlock()
779 lock = self.lock() 779 try:
780
781 p1, p2 = self.dirstate.parents() 780 p1, p2 = self.dirstate.parents()
782 781
783 if (not force and p2 != nullid and 782 if (not force and p2 != nullid and
784 (match and (match.files() or match.anypats()))): 783 (match and (match.files() or match.anypats()))):
785 raise util.Abort(_('cannot partially commit a merge ' 784 raise util.Abort(_('cannot partially commit a merge '
815 r = self._commitctx(wctx, force, force_editor, empty_ok, True) 814 r = self._commitctx(wctx, force, force_editor, empty_ok, True)
816 ms.reset() 815 ms.reset()
817 return r 816 return r
818 817
819 finally: 818 finally:
820 release(lock, wlock) 819 wlock.release()
821 820
822 def commitctx(self, ctx): 821 def commitctx(self, ctx):
823 """Add a new revision to current repository. 822 """Add a new revision to current repository.
824 823
825 Revision information is passed in the context.memctx argument. 824 Revision information is passed in the context.memctx argument.
826 commitctx() does not touch the working directory. 825 commitctx() does not touch the working directory.
827 """ 826 """
828 lock = self.lock() 827 return self._commitctx(ctx, force=True, force_editor=False,
829 try: 828 empty_ok=True, working=False)
830 return self._commitctx(ctx, force=True, force_editor=False,
831 empty_ok=True, working=False)
832 finally:
833 lock.release()
834 829
835 def _commitctx(self, ctx, force=False, force_editor=False, empty_ok=False, 830 def _commitctx(self, ctx, force=False, force_editor=False, empty_ok=False,
836 working=True): 831 working=True):
832 lock = self.lock()
837 tr = None 833 tr = None
838 valid = 0 # don't save the dirstate if this isn't set 834 valid = 0 # don't save the dirstate if this isn't set
839 try: 835 try:
840 commit = sorted(ctx.modified() + ctx.added()) 836 commit = sorted(ctx.modified() + ctx.added())
841 remove = ctx.removed() 837 remove = ctx.removed()
956 return n 952 return n
957 finally: 953 finally:
958 if not valid: # don't save our updated dirstate 954 if not valid: # don't save our updated dirstate
959 self.dirstate.invalidate() 955 self.dirstate.invalidate()
960 del tr 956 del tr
957 lock.release()
961 958
962 def walk(self, match, node=None): 959 def walk(self, match, node=None):
963 ''' 960 '''
964 walk recursively through the directory tree or a given 961 walk recursively through the directory tree or a given
965 changeset, finding all files matched by the match 962 changeset, finding all files matched by the match