Mercurial: keep default branch “active”

后端 未结 2 1427
刺人心
刺人心 2021-02-05 15:55

I am using mercurial with named branches, and notice that when I create a new branch of default, default is marked as an inactive branch. Eg:

C:\\data\\solutions         


        
相关标签:
2条回答
  • 2021-02-05 16:21

    The notion of "active" and "inactive" branches is something we're moving away from in the Mercurial project. The problem is simply that branches can flip back and forth between the two states more or less randomly and at inconvenient times — as you've just seen.

    Instead, we're now focussing on "open" vs "closed". This is an explicit notion: to close a branch head, you do

    $ hg update feature-branch
    $ hg commit --close-branch -m "passes all tests, ready for merging"
    

    That will add a special changeset that marks the branch head as closed. When all heads on a branch are closed, the branch itself it considered closed and will disappear from hg branches. I recommend closing before merging, please see my named branch guide for a longer example.

    So I suggest you change your deployment system to show open branches (hg branches) instead of active branches (hg branches --active).

    0 讨论(0)
  • 2021-02-05 16:29

    Inactive only means it has not a head.

    In your case the graph is like this:

    default:        0 -\
    feature-branch:     \- 1 --- *
    

    * means the "working dir

    When you do more fixes in your feature (like nodes 2 and 3) this will be the aspect:

    default:        0 -\
    feature-branch:     \- 1 --- 2 --- 3 ---- *
    

    When you want to integrate feature-branch into the default just update to the default

    default:        0 -\--------------------- *
    feature-branch:     \- 1 --- 2 --- 3
    

    and then merge feature-branch into the default:

    default:        0 -\-------------------/- *
    feature-branch:     \- 1 --- 2 --- 3 -/
    

    The fact that it appears "inactive" is not meaning you can't work with it. For example, your "deployment scripts" can have a hg update --clean default that will perfectly work even if it appeared as "inactive".

    Inactive just meant it had no heads. Nothing else. After merging it will become active and it will be feature-branch which will become "inactive".

    Don't mind its active/inactive state, just work with it normally.

    0 讨论(0)
提交回复
热议问题