Ensuring a merge between branches happens in one direction

后端 未结 3 1675
清酒与你
清酒与你 2021-02-08 01:59

This morning I discovered that my co-worker had merged the wrong way between two branches in mercurial --we have a ver5 and ver6 branch, with extra files in ver6. Is there any w

3条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-08 02:53

    Whether you have ver5 merged into ver6 or ver6 merged into ver5 you're still ending up with a child of ver5 that has stuff from ver6 in it.

    If, however, you want to avoid a changeset whose branch name is ver5 having ancestors that are ver6 you could do that pretty easily with a hook. Just where you put that hook is the tricky part. If you make it a pretxnchangegroup hook you can prevent people from pushing an offending merge into the server-side repo, but they will have already committed it, and maybe some more changes on top of it, and they'll have a hard time figuring out what to do to fix it. If you can control their local setups you can put in a pretxncommit hook that prevents them from committing the merge, but you can't make them run that hook using only Mercurial tools.

    The actual hook, whichever type you make it, could use either of these strategies:

    • check if the branchname is ver5 and if so make sure no specific file/content from ver6 is presnet

    or

    • check if branchname is ver6 and if so make sure neither p1 nor p2 has branchname ver5

    TL;DR: It's probably more trouble than it's worth -- stick to shaming.

提交回复
热议问题