comparison mercurial/localrepo.py @ 8400:9eecc471aca3

commitctx: replace wctx with ctx
author Matt Mackall <mpm@selenic.com>
date Thu, 14 May 2009 13:20:40 -0500
parents 1c3d5c54cf1c
children ca7dc47eecc6
comparison
equal deleted inserted replaced
8399:1c3d5c54cf1c 8400:9eecc471aca3
834 return self._commitctx(ctx, force=True, force_editor=False, 834 return self._commitctx(ctx, force=True, force_editor=False,
835 empty_ok=True, working=False) 835 empty_ok=True, working=False)
836 finally: 836 finally:
837 lock.release() 837 lock.release()
838 838
839 def _commitctx(self, wctx, force=False, force_editor=False, empty_ok=False, 839 def _commitctx(self, ctx, force=False, force_editor=False, empty_ok=False,
840 working=True): 840 working=True):
841 tr = None 841 tr = None
842 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
843 try: 843 try:
844 commit = sorted(wctx.modified() + wctx.added()) 844 commit = sorted(ctx.modified() + ctx.added())
845 remove = wctx.removed() 845 remove = ctx.removed()
846 extra = wctx.extra().copy() 846 extra = ctx.extra().copy()
847 branchname = extra['branch'] 847 branchname = extra['branch']
848 user = wctx.user() 848 user = ctx.user()
849 text = wctx.description() 849 text = ctx.description()
850 850
851 p1, p2 = [p.node() for p in wctx.parents()] 851 p1, p2 = [p.node() for p in ctx.parents()]
852 c1 = self.changelog.read(p1) 852 c1 = self.changelog.read(p1)
853 c2 = self.changelog.read(p2) 853 c2 = self.changelog.read(p2)
854 m1 = self.manifest.read(c1[0]).copy() 854 m1 = self.manifest.read(c1[0]).copy()
855 m2 = self.manifest.read(c2[0]) 855 m2 = self.manifest.read(c2[0])
856 856
875 changed = [] 875 changed = []
876 linkrev = len(self) 876 linkrev = len(self)
877 for f in commit: 877 for f in commit:
878 self.ui.note(f + "\n") 878 self.ui.note(f + "\n")
879 try: 879 try:
880 fctx = wctx.filectx(f) 880 fctx = ctx.filectx(f)
881 newflags = fctx.flags() 881 newflags = fctx.flags()
882 new[f] = self.filecommit(fctx, m1, m2, linkrev, trp, changed) 882 new[f] = self.filecommit(fctx, m1, m2, linkrev, trp, changed)
883 if ((not changed or changed[-1] != f) and 883 if ((not changed or changed[-1] != f) and
884 m2.get(f) != new[f]): 884 m2.get(f) != new[f]):
885 # mention the file in the changelog if some 885 # mention the file in the changelog if some
952 raise util.Abort(_("empty commit message")) 952 raise util.Abort(_("empty commit message"))
953 text = '\n'.join(lines) 953 text = '\n'.join(lines)
954 954
955 self.changelog.delayupdate() 955 self.changelog.delayupdate()
956 n = self.changelog.add(mn, changed + removed, text, trp, p1, p2, 956 n = self.changelog.add(mn, changed + removed, text, trp, p1, p2,
957 user, wctx.date(), extra) 957 user, ctx.date(), extra)
958 p = lambda: self.changelog.writepending() and self.root or "" 958 p = lambda: self.changelog.writepending() and self.root or ""
959 self.hook('pretxncommit', throw=True, node=hex(n), parent1=xp1, 959 self.hook('pretxncommit', throw=True, node=hex(n), parent1=xp1,
960 parent2=xp2, pending=p) 960 parent2=xp2, pending=p)
961 self.changelog.finalize(trp) 961 self.changelog.finalize(trp)
962 tr.close() 962 tr.close()