mercurial/localrepo.py
changeset 8414 2348ce25849b
parent 8412 2bf4f380f6ab
child 8415 221a18019b2b
equal deleted inserted replaced
8413:36448afdadd4 8414:2348ce25849b
   827         """
   827         """
   828 
   828 
   829         tr = lock = None
   829         tr = lock = None
   830         valid = 0 # don't save the dirstate if this isn't set
   830         valid = 0 # don't save the dirstate if this isn't set
   831         remove = ctx.removed()
   831         remove = ctx.removed()
   832 
   832         p1, p2 = ctx.p1(), ctx.p2()
   833         p1, p2 = [p.node() for p in ctx.parents()]
   833         m1 = p1.manifest().copy()
   834         c1 = self.changelog.read(p1)
   834         m2 = p2.manifest()
   835         c2 = self.changelog.read(p2)
       
   836         m1 = self.manifest.read(c1[0]).copy()
       
   837         m2 = self.manifest.read(c2[0])
       
   838         user = ctx.user()
   835         user = ctx.user()
   839 
   836 
   840         xp1, xp2 = hex(p1), hex(p2)
   837         xp1, xp2 = p1.hex(), p2 and p2.hex() or ''
   841         if p2 == nullid:
       
   842             xp2 = ''
       
   843         self.hook("precommit", throw=True, parent1=xp1, parent2=xp2)
   838         self.hook("precommit", throw=True, parent1=xp1, parent2=xp2)
   844 
   839 
   845         lock = self.lock()
   840         lock = self.lock()
   846         try:
   841         try:
   847             tr = self.transaction()
   842             tr = self.transaction()
   882 
   877 
   883             for f in removed:
   878             for f in removed:
   884                 if f in m1:
   879                 if f in m1:
   885                     del m1[f]
   880                     del m1[f]
   886                     removed1.append(f)
   881                     removed1.append(f)
   887             mn = self.manifest.add(m1, trp, linkrev, c1[0], c2[0],
   882             mn = self.manifest.add(m1, trp, linkrev, p1.manifestnode(),
   888                                    (new, removed1))
   883                                    p2.manifestnode(), (new, removed1))
   889 
   884 
   890             text = ctx.description()
   885             text = ctx.description()
   891             if editor:
   886             if editor:
   892                 text = editor(self, ctx, added, updated, removed)
   887                 text = editor(self, ctx, added, updated, removed)
   893 
   888 
   895             while lines and not lines[0]:
   890             while lines and not lines[0]:
   896                 del lines[0]
   891                 del lines[0]
   897             text = '\n'.join(lines)
   892             text = '\n'.join(lines)
   898 
   893 
   899             self.changelog.delayupdate()
   894             self.changelog.delayupdate()
   900             n = self.changelog.add(mn, changed + removed, text, trp, p1, p2,
   895             n = self.changelog.add(mn, changed + removed, text, trp,
       
   896                                    p1.node(), p2.node(),
   901                                    user, ctx.date(), ctx.extra().copy())
   897                                    user, ctx.date(), ctx.extra().copy())
   902             p = lambda: self.changelog.writepending() and self.root or ""
   898             p = lambda: self.changelog.writepending() and self.root or ""
   903             self.hook('pretxncommit', throw=True, node=hex(n), parent1=xp1,
   899             self.hook('pretxncommit', throw=True, node=hex(n), parent1=xp1,
   904                       parent2=xp2, pending=p)
   900                       parent2=xp2, pending=p)
   905             self.changelog.finalize(trp)
   901             self.changelog.finalize(trp)