Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/localrepo.py @ 8415:221a18019b2b
commit: hoist up dirstate invalidate
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Thu, 14 May 2009 13:24:39 -0500 |
parents | 2348ce25849b |
children | 9dfee83c93c8 |
comparison
equal
deleted
inserted
replaced
8414:2348ce25849b | 8415:221a18019b2b |
---|---|
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 | 777 |
778 ret = None | |
778 wlock = self.wlock() | 779 wlock = self.wlock() |
779 try: | 780 try: |
780 p1, p2 = self.dirstate.parents() | 781 p1, p2 = self.dirstate.parents() |
781 | 782 |
782 if (not force and p2 != nullid and | 783 if (not force and p2 != nullid and |
809 if f in ms and ms[f] == 'u': | 810 if f in ms and ms[f] == 'u': |
810 raise util.Abort(_("unresolved merge conflicts " | 811 raise util.Abort(_("unresolved merge conflicts " |
811 "(see hg resolve)")) | 812 "(see hg resolve)")) |
812 wctx = context.workingctx(self, (p1, p2), text, user, date, | 813 wctx = context.workingctx(self, (p1, p2), text, user, date, |
813 extra, changes) | 814 extra, changes) |
814 r = self.commitctx(wctx, editor, True) | 815 ret = self.commitctx(wctx, editor, True) |
815 ms.reset() | 816 ms.reset() |
816 return r | 817 return ret |
817 | 818 |
818 finally: | 819 finally: |
820 if ret == None: | |
821 self.dirstate.invalidate() # didn't successfully commit | |
819 wlock.release() | 822 wlock.release() |
820 | 823 |
821 def commitctx(self, ctx, editor=None, working=False): | 824 def commitctx(self, ctx, editor=None, working=False): |
822 """Add a new revision to current repository. | 825 """Add a new revision to current repository. |
823 | 826 |
825 If editor is supplied, it is called to get a commit message. | 828 If editor is supplied, it is called to get a commit message. |
826 If working is set, the working directory is affected. | 829 If working is set, the working directory is affected. |
827 """ | 830 """ |
828 | 831 |
829 tr = lock = None | 832 tr = lock = None |
830 valid = 0 # don't save the dirstate if this isn't set | |
831 remove = ctx.removed() | 833 remove = ctx.removed() |
832 p1, p2 = ctx.p1(), ctx.p2() | 834 p1, p2 = ctx.p1(), ctx.p2() |
833 m1 = p1.manifest().copy() | 835 m1 = p1.manifest().copy() |
834 m2 = p2.manifest() | 836 m2 = p2.manifest() |
835 user = ctx.user() | 837 user = ctx.user() |
906 | 908 |
907 if working: | 909 if working: |
908 self.dirstate.setparents(n) | 910 self.dirstate.setparents(n) |
909 for f in removed: | 911 for f in removed: |
910 self.dirstate.forget(f) | 912 self.dirstate.forget(f) |
911 valid = 1 # our dirstate updates are complete | |
912 | 913 |
913 self.hook("commit", node=hex(n), parent1=xp1, parent2=xp2) | 914 self.hook("commit", node=hex(n), parent1=xp1, parent2=xp2) |
914 return n | 915 return n |
915 finally: | 916 finally: |
916 if not valid: # don't save our updated dirstate | |
917 self.dirstate.invalidate() | |
918 del tr | 917 del tr |
919 lock.release() | 918 lock.release() |
920 | 919 |
921 def walk(self, match, node=None): | 920 def walk(self, match, node=None): |
922 ''' | 921 ''' |