##// END OF EJS Templates
commitctx: replace two dirstate vars with working
Matt Mackall -
r8399:1c3d5c54 default
parent child Browse files
Show More
@@ -816,8 +816,7 b' class localrepository(repo.repository):'
816 "(see hg resolve)"))
816 "(see hg resolve)"))
817 wctx = context.workingctx(self, (p1, p2), text, user, date,
817 wctx = context.workingctx(self, (p1, p2), text, user, date,
818 extra, changes)
818 extra, changes)
819 r = self._commitctx(wctx, force, force_editor, empty_ok,
819 r = self._commitctx(wctx, force, force_editor, empty_ok, True)
820 True, True)
821 ms.reset()
820 ms.reset()
822 return r
821 return r
823
822
@@ -833,13 +832,12 b' class localrepository(repo.repository):'
833 lock = self.lock()
832 lock = self.lock()
834 try:
833 try:
835 return self._commitctx(ctx, force=True, force_editor=False,
834 return self._commitctx(ctx, force=True, force_editor=False,
836 empty_ok=True, use_dirstate=False,
835 empty_ok=True, working=False)
837 update_dirstate=False)
838 finally:
836 finally:
839 lock.release()
837 lock.release()
840
838
841 def _commitctx(self, wctx, force=False, force_editor=False, empty_ok=False,
839 def _commitctx(self, wctx, force=False, force_editor=False, empty_ok=False,
842 use_dirstate=True, update_dirstate=True):
840 working=True):
843 tr = None
841 tr = None
844 valid = 0 # don't save the dirstate if this isn't set
842 valid = 0 # don't save the dirstate if this isn't set
845 try:
843 try:
@@ -856,7 +854,7 b' class localrepository(repo.repository):'
856 m1 = self.manifest.read(c1[0]).copy()
854 m1 = self.manifest.read(c1[0]).copy()
857 m2 = self.manifest.read(c2[0])
855 m2 = self.manifest.read(c2[0])
858
856
859 if use_dirstate:
857 if working:
860 oldname = c1[5].get("branch") # stored in UTF-8
858 oldname = c1[5].get("branch") # stored in UTF-8
861 if (not commit and not remove and not force and p2 == nullid
859 if (not commit and not remove and not force and p2 == nullid
862 and branchname == oldname):
860 and branchname == oldname):
@@ -890,11 +888,11 b' class localrepository(repo.repository):'
890 if m1.flags(f) != newflags:
888 if m1.flags(f) != newflags:
891 changed.append(f)
889 changed.append(f)
892 m1.set(f, newflags)
890 m1.set(f, newflags)
893 if use_dirstate:
891 if working:
894 self.dirstate.normal(f)
892 self.dirstate.normal(f)
895
893
896 except (OSError, IOError):
894 except (OSError, IOError):
897 if use_dirstate:
895 if working:
898 self.ui.warn(_("trouble committing %s!\n") % f)
896 self.ui.warn(_("trouble committing %s!\n") % f)
899 raise
897 raise
900 else:
898 else:
@@ -950,7 +948,7 b' class localrepository(repo.repository):'
950 lines = [line.rstrip() for line in text.rstrip().splitlines()]
948 lines = [line.rstrip() for line in text.rstrip().splitlines()]
951 while lines and not lines[0]:
949 while lines and not lines[0]:
952 del lines[0]
950 del lines[0]
953 if not lines and use_dirstate:
951 if not lines and working:
954 raise util.Abort(_("empty commit message"))
952 raise util.Abort(_("empty commit message"))
955 text = '\n'.join(lines)
953 text = '\n'.join(lines)
956
954
@@ -966,11 +964,10 b' class localrepository(repo.repository):'
966 if self.branchcache:
964 if self.branchcache:
967 self.branchtags()
965 self.branchtags()
968
966
969 if use_dirstate or update_dirstate:
967 if working:
970 self.dirstate.setparents(n)
968 self.dirstate.setparents(n)
971 if use_dirstate:
969 for f in removed:
972 for f in removed:
970 self.dirstate.forget(f)
973 self.dirstate.forget(f)
974 valid = 1 # our dirstate updates are complete
971 valid = 1 # our dirstate updates are complete
975
972
976 self.hook("commit", node=hex(n), parent1=xp1, parent2=xp2)
973 self.hook("commit", node=hex(n), parent1=xp1, parent2=xp2)
General Comments 0
You need to be logged in to leave comments. Login now