merge with qsync fix stable
authorPierre-Yves David <pierre-yves.david@logilab.fr>
Wed, 07 Nov 2012 17:22:41 +0100
branchstable
changeset 609 3e7ec61fbcdc
parent 605 e0847647fa6a (current diff)
parent 608 af29fbbefe7a (diff)
child 610 4a27cba047f5
child 616 279403a12565
merge with qsync fix
--- a/hgext/qsync.py	Fri Oct 26 18:02:51 2012 +0200
+++ b/hgext/qsync.py	Wed Nov 07 17:22:41 2012 +0100
@@ -67,64 +67,67 @@
     except error.RepoLookupError:
         parent = initqsubmit(mqrepo)
     store, data, touched = fillstore(repo, parent)
-    if not touched:
-        raise util.Abort('Nothing changed')
-    files = ['qsubmitdata', 'series'] + touched
-    # mark some as ready for review
-    message = 'qsubmit commit\n\n'
-    review_list = []
-    applied_list = []
-    if review:
-        olddata = get_old_data(parent)
-        oldfiles = dict([(name, bin(ctxhex)) for ctxhex, name in olddata])
+    try:
+        if not touched:
+            raise util.Abort('Nothing changed')
+        files = ['qsubmitdata', 'series'] + touched
+        # mark some as ready for review
+        message = 'qsubmit commit\n\n'
+        review_list = []
+        applied_list = []
+        if review:
+            olddata = get_old_data(parent)
+            oldfiles = dict([(name, bin(ctxhex)) for ctxhex, name in olddata])
 
-        for patch_name in touched:
-            try:
-                store.getfile(patch_name)
-                review_list.append(patch_name)
-            except IOError:
-                oldnode = oldfiles[patch_name]
-                evolve = extensions.find('evolve')
-                newnodes = evolve.successorssets(repo, oldnode)
-                if newnodes:
-                    newnodes = [n for n in newnodes if n and n[0] in repo] # remove killing
-                if not newnodes:
-                    # changeset has been killed (eg. reject)
-                    pass
-                else:
-                    assert len(newnodes) == 1 # conflict!!!
-                    newnode = newnodes[0]
-                    assert len(newnode) == 1 # split unsupported for now
-                    newnode = list(newnode)[0]
-                    # XXX unmanaged case where a cs is obsoleted by an unavailable one
-                    #if newnode.node() not in repo.changelog.nodemap:
-                    #    raise util.Abort('%s is obsoleted by an unknown node %s'% (oldnode, newnode))
-                    ctx = repo[newnode]
-                    if ctx.phase() == phases.public:
-                        # applied
-                        applied_list.append(patch_name)
-                    elif ctx.phase() == phases.secret:
-                        # already exported changeset is now secret
-                        repo.ui.warn("An already exported changeset is now secret!!!")
+            for patch_name in touched:
+                try:
+                    store.getfile(patch_name)
+                    review_list.append(patch_name)
+                except IOError:
+                    oldnode = oldfiles[patch_name]
+                    evolve = extensions.find('evolve')
+                    newnodes = evolve.successorssets(repo, oldnode)
+                    if newnodes:
+                        newnodes = [n for n in newnodes if n and n[0] in repo] # remove killing
+                    if not newnodes:
+                        # changeset has been killed (eg. reject)
+                        pass
                     else:
-                        # draft
-                        assert False, "Should be exported"
+                        assert len(newnodes) == 1 # conflict!!!
+                        newnode = newnodes[0]
+                        assert len(newnode) == 1 # split unsupported for now
+                        newnode = list(newnode)[0]
+                        # XXX unmanaged case where a cs is obsoleted by an unavailable one
+                        #if newnode.node() not in repo.changelog.nodemap:
+                        #    raise util.Abort('%s is obsoleted by an unknown node %s'% (oldnode, newnode))
+                        ctx = repo[newnode]
+                        if ctx.phase() == phases.public:
+                            # applied
+                            applied_list.append(patch_name)
+                        elif ctx.phase() == phases.secret:
+                            # already exported changeset is now secret
+                            repo.ui.warn("An already exported changeset is now secret!!!")
+                        else:
+                            # draft
+                            assert False, "Should be exported"
 
-    if review:
-        if applied_list:
-            message += '\n'.join('* applied %s' % x for x in applied_list) + '\n'
-        if review_list:
-            message += '\n'.join('* %s ready for review' % x for x in review_list) + '\n'
-    memctx = patch.makememctx(mqrepo, (parent.node(), nullid),
-                              message,
-                              None,
-                              None,
-                              parent.branch(), files, store,
-                              editor=None)
-    if review == 'edit':
-        memctx._text = cmdutil.commitforceeditor(mqrepo, memctx, [])
-    mqrepo.savecommitmessage(memctx.description())
-    n = memctx.commit()
+        if review:
+            if applied_list:
+                message += '\n'.join('* applied %s' % x for x in applied_list) + '\n'
+            if review_list:
+                message += '\n'.join('* %s ready for review' % x for x in review_list) + '\n'
+        memctx = patch.makememctx(mqrepo, (parent.node(), nullid),
+                                  message,
+                                  None,
+                                  None,
+                                  parent.branch(), files, store,
+                                  editor=None)
+        if review == 'edit':
+            memctx._text = cmdutil.commitforceeditor(mqrepo, memctx, [])
+        mqrepo.savecommitmessage(memctx.description())
+        n = memctx.commit()
+    finally:
+        store.close()
     return 0
 
 
@@ -237,8 +240,9 @@
         # export data to ease futur work
         store.setfile('qsubmitdata', json.dumps(data, indent=True),
                       (False, False))
-    finally:
+    except:
         store.close()
+	raise
     return store, data, touched