How to change the default branch to push in mercurial?

前端 未结 3 807
情书的邮戳
情书的邮戳 2021-01-12 02:36

I like creating named branches in Mercurial to deal with features that might take a while to code, so when I push I do a hg push -r default to ensure I\'m only

相关标签:
3条回答
  • 2021-01-12 03:16

    Are you using Tortoise HG perhaps? Doing a full revert to an explicit branch name will cause Tortoise HG to remember the branch you're working on during subsequent commits. I'm not sure what metadata it gleans this from.

    hg up -r {branchname}
    

    e.g.

    hg up -r dev 
    
    0 讨论(0)
  • 2021-01-12 03:22

    Since normally you should push changesets in the current branch you are working, I modified the above answer made by ry4an-brase, to push current branch with a notice.

    #!/bin/sh
    HG=/usr/bin/hg # executable
    
    if echo $* | grep -P -q -- 'push\s*$' ; then
        printf "\033[1;31mChanged to: hg push -r .\033[0m\n"
        $HG $* -r .
    else
        $HG $*
    fi
    
    0 讨论(0)
  • 2021-01-12 03:30

    I don't think you can do it with pure mercurial, short of having a clone with only that branch in it (which I was was about to suggest until you said it wasn't your cup of tea). If it's really killing you you can create a tiny wrapper script like:

    #!/bin/sh
    HG=/full/path/to/hg # executable
    if echo $* | grep -P -q -- 'push.*\s-r($|\s)' ; then
       $HG $*
    else
       $HG $* -r default
    fi
    

    name it 'hg' and put it earlier in your path.

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