mq: simplify and use context API
authorBenoit Boissinot <benoit.boissinot@ens-lyon.org>
Sat, 13 Mar 2010 12:57:20 +0100
changeset 10663 85e81d9bfb7a
parent 10662 e8e56d8377ab
child 10668 05856e682521
mq: simplify and use context API
hgext/mq.py
--- a/hgext/mq.py	Sat Mar 13 00:08:06 2010 +0100
+++ b/hgext/mq.py	Sat Mar 13 12:57:20 2010 +0100
@@ -1104,10 +1104,6 @@
             wlock.release()
 
     def pop(self, repo, patch=None, force=False, update=True, all=False):
-        def getfile(f, rev, flags):
-            t = repo.file(f).read(rev)
-            repo.wwrite(f, t, flags)
-
         wlock = repo.wlock()
         try:
             if patch:
@@ -1175,8 +1171,7 @@
             # form of hg.update.
             if update:
                 qp = self.qparents(repo, rev)
-                changes = repo.changelog.read(qp)
-                mmap = repo.manifest.read(changes[0])
+                ctx = repo[qp]
                 m, a, r, d = repo.status(qp, top)[:4]
                 if d:
                     raise util.Abort(_("deletions found between repo revs"))
@@ -1189,11 +1184,9 @@
                     try: os.removedirs(os.path.dirname(repo.wjoin(f)))
                     except: pass
                     repo.dirstate.forget(f)
-                for f in m:
-                    getfile(f, mmap[f], mmap.flags(f))
-                for f in r:
-                    getfile(f, mmap[f], mmap.flags(f))
                 for f in m + r:
+                    fctx = ctx[f]
+                    repo.wwrite(f, fctx.data(), fctx.flags())
                     repo.dirstate.normal(f)
                 repo.dirstate.setparents(qp, nullid)
             for patch in reversed(self.applied[start:end]):