changeset 1505:53a6dbc33e36

evolve: indentation change for making next patch more legible In the next patch: "evolve: use repo._bookmarks.recordchange instead of repo._bookmarks.write" we need to add a transaction in the rewrite function. To do so adds an indentation level and makes the patch harder to review. This patch makes the indentation change so that the next patch is easier to review.
author Laurent Charignon <lcharignon@fb.com>
date Wed, 16 Sep 2015 17:12:38 -0700
parents 415a51ac07a7
children a55c691f4cc0
files hgext/evolve.py
diffstat 1 files changed, 68 insertions(+), 67 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/evolve.py	Mon Sep 14 13:52:34 2015 -0700
+++ b/hgext/evolve.py	Wed Sep 16 17:12:38 2015 -0700
@@ -805,74 +805,75 @@
     nodeid was actually created. If created is False, nodeid
     references a changeset existing before the rewrite call.
     """
-    if len(old.parents()) > 1: #XXX remove this unecessary limitation.
-        raise error.Abort(_('cannot amend merge changesets'))
-    base = old.p1()
-    updatebookmarks = _bookmarksupdater(repo, old.node())
-
-    # 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())
+    if True:
+        if len(old.parents()) > 1: #XXX remove this unecessary limitation.
+            raise error.Abort(_('cannot amend merge changesets'))
+        base = old.p1()
+        updatebookmarks = _bookmarksupdater(repo, old.node())
+
+        # 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
             else:
-                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
-        return None
-
-    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
+                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
+            return None
+
+        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
 
 class MergeFailure(util.Abort):
     pass