Can I add a parameter to hg pull (in order to use the rebaseif extension)?

I'd like to be able to use the rebaseif extension when I pull. It's also somewhat important to be able to decide for each pull whether to rebaseif. The mercurial syntax is simply 'hg pull --rebaseif'

Is there a way to add the arguments?

2 answers

1 accepted

1 vote
Accepted answer

You can't add arguments to the in-built Pull, but you can define a Custom Action instead, which can be anything that's callable on the command line. Please see this blog post for details:

I think that's the right angle, thanks, but still having trouble. hg pull --rebaseif works properly on the command line, but it breaks in a custom action. (I also tried hg root and hg with no arguments, with the same results.)

In each case, I get the following message as the first part of the output (referencing 3 extensions not mentioned in my ~/.hgrc)

*** failed to import extension hgext.hgsubversion: No module named hgsubversion
*** failed to import extension hgext.hgattic: No module named hgattic
*** failed to import extension hgext.hgflow: No module named hgflow

In the case of --rebaseif, which is installed on my account and adds itself as an optional argument to pull, it outputs a usage message showing it doesn't recognize the --rebaseif argument (after the fail-to-import messages)

I also tried actions for 'which hg' and 'where hg', which did not work. I tried 'hg version' which showed it was using the same version I have installed on the commandline, but also gave the fail-to-import errors.

hg showconfig, as a custom action, shows the "failed to import" errors, but it also shows that it *is* reading all of the customizations in my ~/.hgrc

Sorry for all the details, but any thoughts on what might be making it not recognize the installed rebaseif extension, and why the odd error fail-to-import messages?


I tried two more things before finishing. One works, but I'd like to better undertand why.

First I tried a wrapper script: hg pull --rebaseif, which couldn't find hg. Then finally I got it to work by putting a full path in a wrapper script: /usr/local/bin/hg pull --rebaseif.

The uptake for me is that there needs to be more substantial documentation about the shell/environment for custom actions to help us understand what's needed. Perhaps there could be another blog post (linked from the first) going through all my examples and explaining why they don't work. When is a wrapper needed? Thanks!

Ah, you tried what I would have suggested. The reason why using a wrapper script works is that it goes via your shell, which then picks up all your terminal environment. Mac OS X apps do not inherit all your PATH and other environment settings because they're not launched from the terminal, they're launched by a system daemon called 'launchd'. By using the wrapper script which is executed by sh/bash etc, you pick up your usual terminal environment which can sometimes be key if you're dependent on it. Whether you need it or not depends entirely on what you're calling - simple git commands etc normally work fine.

I'm all set now, but I still think some efforts should be put into making this better documented and making the documentation easier to find (both through google and from within sourcetree)


Suggest an answer

Log in or Sign up to answer
Community showcase

Scrum Roles Explained: the Do's and the Don'ts

Hello Community,  Today we are going to talk about the three Scrum Roles. There is the Development Team, the Scrum Master and the Product Owner. In my opinion these three are all really impo...

56 views 0 4
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you