topic-change: cleanup the locking and transaction mechanism
The previous code did not garanted we would release all lock (and was a bit more
complicated than needed.
--- a/hgext3rd/topic/__init__.py Wed Jun 21 07:21:50 2017 +0530
+++ b/hgext3rd/topic/__init__.py Wed Jun 21 13:21:08 2017 +0200
@@ -306,9 +306,10 @@
def _changetopics(ui, repo, revset, newtopic):
rewrote = 0
needevolve = False
- l = repo.lock()
- txn = repo.transaction('rewrite-topics')
+ l = txn = None
try:
+ l = repo.lock()
+ txn = repo.transaction('rewrite-topics')
p1 = None
p2 = None
successors = {}
@@ -358,14 +359,9 @@
obsolete.createmarkers(repo, [(c, (repo[newnode],))])
rewrote += 1
txn.close()
- except:
- try:
- txn.abort()
- finally:
- repo.invalidate()
- raise
finally:
lock.release(txn, l)
+ repo.invalidate()
ui.status('changed topic on %d changes\n' % rewrote)
if needevolve:
evolvetarget = 'topic(%s)' % newtopic if newtopic else 'not topic()'