evolve: drop useless wlock in rewrite
authorPierre-Yves David <pierre-yves.david@fb.com>
Wed, 06 Aug 2014 17:37:28 -0700
changeset 1017 186b72e41294
parent 1016 facb5efa8ea4
child 1018 30262465b932
evolve: drop useless wlock in rewrite
hgext/evolve.py
--- a/hgext/evolve.py	Wed Aug 06 16:55:41 2014 -0700
+++ b/hgext/evolve.py	Wed Aug 06 17:37:28 2014 -0700
@@ -767,72 +767,67 @@
     base = old.p1()
     updatebookmarks = _bookmarksupdater(repo, old.node())
 
-    wlock = repo.wlock()
-    try:
-
-        # commit a new version of the old changeset, including the update
-        # collect all files which might be affected
-        files = set(old.files())
-        for u in updates:
-            files.update(u.files())
-
-        # Recompute copies (avoid recording a -> b -> a)
-        copied = copies.pathcopies(base, head)
-
-
-        # prune files which were reverted by the updates
-        def samefile(f):
-            if f in head.manifest():
-                a = head.filectx(f)
-                if f in base.manifest():
-                    b = base.filectx(f)
-                    return (a.data() == b.data()
-                            and a.flags() == b.flags())
-                else:
-                    return False
+    # commit a new version of the old changeset, including the update
+    # collect all files which might be affected
+    files = set(old.files())
+    for u in updates:
+        files.update(u.files())
+
+    # Recompute copies (avoid recording a -> b -> a)
+    copied = copies.pathcopies(base, head)
+
+
+    # prune files which were reverted by the updates
+    def samefile(f):
+        if f in head.manifest():
+            a = head.filectx(f)
+            if f in base.manifest():
+                b = base.filectx(f)
+                return (a.data() == b.data()
+                        and a.flags() == b.flags())
             else:
-                return f not in base.manifest()
-        files = [f for f in files if not samefile(f)]
-        # commit version of these files as defined by head
-        headmf = head.manifest()
-        def filectxfn(repo, ctx, path):
-            if path in headmf:
-                fctx = head[path]
-                flags = fctx.flags()
-                mctx = memfilectx(repo, fctx.path(), fctx.data(),
-                                  islink='l' in flags,
-                                  isexec='x' in flags,
-                                  copied=copied.get(path))
-                return mctx
-            raise IOError()
-
-        message = cmdutil.logmessage(repo.ui, commitopts)
-        if not message:
-            message = old.description()
-
-        user = commitopts.get('user') or old.user()
-        date = commitopts.get('date') or None # old.date()
-        extra = dict(commitopts.get('extra', {}))
-        extra['branch'] = head.branch()
-
-        new = context.memctx(repo,
-                             parents=newbases,
-                             text=message,
-                             files=files,
-                             filectxfn=filectxfn,
-                             user=user,
-                             date=date,
-                             extra=extra)
-
-        if commitopts.get('edit'):
-            new._text = cmdutil.commitforceeditor(repo, new, [])
-        revcount = len(repo)
-        newid = repo.commitctx(new)
-        new = repo[newid]
-        created = len(repo) != revcount
-        updatebookmarks(newid)
-    finally:
-        wlock.release()
+                return False
+        else:
+            return f not in base.manifest()
+    files = [f for f in files if not samefile(f)]
+    # commit version of these files as defined by head
+    headmf = head.manifest()
+    def filectxfn(repo, ctx, path):
+        if path in headmf:
+            fctx = head[path]
+            flags = fctx.flags()
+            mctx = memfilectx(repo, fctx.path(), fctx.data(),
+                              islink='l' in flags,
+                              isexec='x' in flags,
+                              copied=copied.get(path))
+            return mctx
+        raise IOError()
+
+    message = cmdutil.logmessage(repo.ui, commitopts)
+    if not message:
+        message = old.description()
+
+    user = commitopts.get('user') or old.user()
+    date = commitopts.get('date') or None # old.date()
+    extra = dict(commitopts.get('extra', {}))
+    extra['branch'] = head.branch()
+
+    new = context.memctx(repo,
+                         parents=newbases,
+                         text=message,
+                         files=files,
+                         filectxfn=filectxfn,
+                         user=user,
+                         date=date,
+                         extra=extra)
+
+    if commitopts.get('edit'):
+        new._text = cmdutil.commitforceeditor(repo, new, [])
+    revcount = len(repo)
+    newid = repo.commitctx(new)
+    new = repo[newid]
+    created = len(repo) != revcount
+    updatebookmarks(newid)
 
     return newid, created