[PATCH 1 of 3 STABLE] changegroup: fix the scope of a try finally

Pierre-Yves David pierre-yves.david at ens-lyon.org
Fri Nov 6 18:06:59 UTC 2015


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at fb.com>
# Date 1446831546 18000
#      Fri Nov 06 12:39:06 2015 -0500
# Branch stable
# Node ID 03916de16fe8f511a48b860bf8b7956d79ea8ef9
# Parent  10a1a4b3e775d6024a82937df6bcc4188a315124
# Available At http://hg.netv6.net/marmoute-wip/mercurial/
#              hg pull http://hg.netv6.net/marmoute-wip/mercurial/ -r 03916de16fe8
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.

diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py
--- a/mercurial/changegroup.py
+++ b/mercurial/changegroup.py
@@ -320,23 +320,23 @@ class cg1unpacker(object):
             return cl.rev(x)
 
         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
+            # inconsistent view
+            cl = repo.changelog
+            cl.delayupdate(tr)
+            oldheads = cl.heads()
             repo.hook('prechangegroup', throw=True, **tr.hookargs)
 
             trp = weakref.proxy(tr)
             # pull off the changeset group
             repo.ui.status(_("adding changesets\n"))


More information about the Mercurial-devel mailing list