如何从Bitbucket上的Mercurial标签创建pull request?

14

可以将 Mercurial 书签推送到 Bitbucket,但有没有人知道如何从中创建拉取请求?

2个回答

8

我刚试了一下,除非我要创建拉取请求的书签本身是一个head,否则它无法正常工作。因此,如果您有一个线性更改,比如:A --- B(标记为feature-1)--- C(标记为feature-2),您将无法为feature-1的哈希创建PR(因为它不是head)。 - martian111

5

我和我的团队很积极地使用书签来进行拉取请求,已经有几周了。以下是我的操作方式:

  1. Create bookmark, called master on default branch:

    hg bo master -r default
    

    If you don't do this, then after creating two branches on default, when one is named with bookmark, then other will be left as anonymous branch. So master bookmark is needed to name this anonymous branch.

  2. Make this master branch public in your fork repository and in upstream repository:

    hg push -B master
    hg push upstream -B master
    

    You can manage repository aliases in .hg/hgrc file (relative to your repository), example:

    [paths]
    default = ssh://hg@bitbucket.org/foo/upstream
    upstream = ssh://hg@bitbucket.org/upstream/upstream
    
  3. Ask your team to pull master bookmark:

    hg pull -B master
    
  4. Start to work on a feature, using bookmark:

    hg bo feature-1
    hg ci -m "Some changes."
    hg push
    
  5. In Bitbucket, press "Pull request" button, or type "x" then "p".

  6. On left side, select you branch, to create pull request from it. If your default has only one branch (to check that, see hg heads default), then your bookmark branch will be displayed as default, but if you have more than one branch on default, then you will see some think like this default (0932c9ab2029), you can find correct one by matching hash value from hg bo. After selecting branch, pull request title will be filled with last commit from selected branch.

  7. Press "Create pull request" button at the bottom, and that's it, your pull request will be created.

  8. To create new pull request, first pull changes from upstream repository:

    hg pull upstream
    
  9. Update to master:

    hg up master
    
  10. And start your new feature branch using bookmark:

    hg bo feature-2
    

如果你无法要求团队使用master作为原始default的标签,那么我建议你创建一个以你的昵称命名的个人分支,并使用个人命名的分支来处理书签,而不是在default上工作。在这种情况下,工作流程将如下:

  1. Create your personal named branch:

    hg branch nickname
    hg ci -m "Starting my personal branch for feature branch management."
    
  2. Create local master bookmark:

    hg bo master
    
  3. Start to work on a feature, using bookmark:

    hg bo feature-1
    hg ci -m "Some changes."
    hg push
    
  4. In Bitbucket, press "Pull request" button, or type "x" then "p".

  5. On left side, select you branch, to create pull request from it. If your nickname named branch has only one head (to check that, see hg heads nickname), then your bookmark branch will be displayed as nickname, but if you have more than one branch on nickname, then you will see some think like this nickname (0932c9ab2029), you can find correct one by matching hash value from hg bo. After selecting branch, pull request title will be filled with last commit from selected branch.

  6. Press "Create pull request" button at the bottom, and that's it, your pull request will be created.

  7. To create new pull request, first pull changes from upstream repository:

    hg pull upstream
    
  8. Update to master:

    hg up master
    
  9. Merge default to master

    hg merge default
    hg ci -m merge
    
  10. And start your new feature branch using bookmark:

    hg bo feature-2
    

建议在 Git 中使用 @ 作为主分支的等效符号。@ 书签很特别,因为在新克隆时默认激活它。 - markand

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接