changeset 26880:fa7f8b686633 stable

changegroup: fix the scope of a try finally The try finally is here to ensure we release the just-created transaction. Therefore we should not do half a dozen operations before actually entry the try scope.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Fri, 06 Nov 2015 12:39:06 -0500
parents 78d05778907b
children 6b1ea6961554
files mercurial/changegroup.py
diffstat 1 files changed, 12 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/changegroup.py	Sun Nov 01 21:19:09 2015 +0900
+++ b/mercurial/changegroup.py	Fri Nov 06 12:39:06 2015 -0500
@@ -322,19 +322,19 @@
         changesets = files = revisions = 0
 
         tr = repo.transaction("\n".join([srctype, util.hidepassword(url)]))
-        # The transaction could have been created before and already
-        # carries source information. In this case we use the top
-        # level data. We overwrite the argument because we need to use
-        # the top level value (if they exist) in this function.
-        srctype = tr.hookargs.setdefault('source', srctype)
-        url = tr.hookargs.setdefault('url', url)
+        try:
+            # The transaction could have been created before and already
+            # carries source information. In this case we use the top
+            # level data. We overwrite the argument because we need to use
+            # the top level value (if they exist) in this function.
+            srctype = tr.hookargs.setdefault('source', srctype)
+            url = tr.hookargs.setdefault('url', url)
 
-        # write changelog data to temp files so concurrent readers will not see
-        # inconsistent view
-        cl = repo.changelog
-        cl.delayupdate(tr)
-        oldheads = cl.heads()
-        try:
+            # write changelog data to temp files so concurrent readers
+            # will not see an inconsistent view
+            cl = repo.changelog
+            cl.delayupdate(tr)
+            oldheads = cl.heads()
             repo.hook('prechangegroup', throw=True, **tr.hookargs)
 
             trp = weakref.proxy(tr)