commitctx: use contexts more fully
authorMatt Mackall <mpm@selenic.com>
Thu, 14 May 2009 13:24:26 -0500
changeset 8414 2348ce25849b
parent 8413 36448afdadd4
child 8415 221a18019b2b
commitctx: use contexts more fully
mercurial/localrepo.py
--- a/mercurial/localrepo.py	Thu May 14 13:21:20 2009 -0500
+++ b/mercurial/localrepo.py	Thu May 14 13:24:26 2009 -0500
@@ -829,17 +829,12 @@
         tr = lock = None
         valid = 0 # don't save the dirstate if this isn't set
         remove = ctx.removed()
-
-        p1, p2 = [p.node() for p in ctx.parents()]
-        c1 = self.changelog.read(p1)
-        c2 = self.changelog.read(p2)
-        m1 = self.manifest.read(c1[0]).copy()
-        m2 = self.manifest.read(c2[0])
+        p1, p2 = ctx.p1(), ctx.p2()
+        m1 = p1.manifest().copy()
+        m2 = p2.manifest()
         user = ctx.user()
 
-        xp1, xp2 = hex(p1), hex(p2)
-        if p2 == nullid:
-            xp2 = ''
+        xp1, xp2 = p1.hex(), p2 and p2.hex() or ''
         self.hook("precommit", throw=True, parent1=xp1, parent2=xp2)
 
         lock = self.lock()
@@ -884,8 +879,8 @@
                 if f in m1:
                     del m1[f]
                     removed1.append(f)
-            mn = self.manifest.add(m1, trp, linkrev, c1[0], c2[0],
-                                   (new, removed1))
+            mn = self.manifest.add(m1, trp, linkrev, p1.manifestnode(),
+                                   p2.manifestnode(), (new, removed1))
 
             text = ctx.description()
             if editor:
@@ -897,7 +892,8 @@
             text = '\n'.join(lines)
 
             self.changelog.delayupdate()
-            n = self.changelog.add(mn, changed + removed, text, trp, p1, p2,
+            n = self.changelog.add(mn, changed + removed, text, trp,
+                                   p1.node(), p2.node(),
                                    user, ctx.date(), ctx.extra().copy())
             p = lambda: self.changelog.writepending() and self.root or ""
             self.hook('pretxncommit', throw=True, node=hex(n), parent1=xp1,