436 lockmod.release(txn, l, wl) |
436 lockmod.release(txn, l, wl) |
437 repo.invalidate() |
437 repo.invalidate() |
438 return |
438 return |
439 |
439 |
440 if clear: |
440 if clear: |
|
441 ct = repo.currenttopic |
|
442 empty = stack.stackdata(repo, topic=ct)['changesetcount'] == 0 |
|
443 if empty: |
|
444 if ct: |
|
445 ui.status(_('clearing empty topic "%s"\n') % ct) |
441 return _changecurrenttopic(repo, None) |
446 return _changecurrenttopic(repo, None) |
442 |
447 |
443 if topic: |
448 if topic: |
444 return _changecurrenttopic(repo, topic) |
449 return _changecurrenttopic(repo, topic) |
445 |
450 |
850 # The mergeupdatewrap function makes the destination's topic as the |
855 # The mergeupdatewrap function makes the destination's topic as the |
851 # current topic. This is right for merge but wrong for rebase. We check |
856 # current topic. This is right for merge but wrong for rebase. We check |
852 # if rebase is running and update the currenttopic to topic of new |
857 # if rebase is running and update the currenttopic to topic of new |
853 # rebased commit. We have explicitly stored in config if rebase is |
858 # rebased commit. We have explicitly stored in config if rebase is |
854 # running. |
859 # running. |
|
860 ot = repo.currenttopic |
|
861 empty = stack.stackdata(repo, topic=ot)['changesetcount'] == 0 |
855 if repo.ui.hasconfig('experimental', 'topicrebase'): |
862 if repo.ui.hasconfig('experimental', 'topicrebase'): |
856 isrebase = True |
863 isrebase = True |
857 if repo.ui.configbool('_internal', 'keep-topic'): |
864 if repo.ui.configbool('_internal', 'keep-topic'): |
858 ist0 = True |
865 ist0 = True |
859 if ((not partial and not branchmerge) or isrebase) and not ist0: |
866 if ((not partial and not branchmerge) or isrebase) and not ist0: |
860 ot = repo.currenttopic |
|
861 t = '' |
867 t = '' |
862 pctx = repo[node] |
868 pctx = repo[node] |
863 if pctx.phase() > phases.public: |
869 if pctx.phase() > phases.public: |
864 t = pctx.topic() |
870 t = pctx.topic() |
865 with repo.vfs.open('topic', 'w') as f: |
871 with repo.vfs.open('topic', 'w') as f: |
866 f.write(t) |
872 f.write(t) |
867 if t and t != ot: |
873 if t and t != ot: |
868 repo.ui.status(_("switching to topic %s\n") % t) |
874 repo.ui.status(_("switching to topic %s\n") % t) |
|
875 if ot and not t and empty: |
|
876 repo.ui.status(_('clearing empty topic "%s"\n') % ot) |
869 elif ist0: |
877 elif ist0: |
870 repo.ui.status(_("preserving the current topic '%s'\n") % |
878 repo.ui.status(_("preserving the current topic '%s'\n") % ot) |
871 repo.currenttopic) |
|
872 return ret |
879 return ret |
873 finally: |
880 finally: |
874 wlock.release() |
881 wlock.release() |
875 |
882 |
876 def checkt0(orig, ui, repo, node=None, rev=None, *args, **kwargs): |
883 def checkt0(orig, ui, repo, node=None, rev=None, *args, **kwargs): |