Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

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

joshgold October 31, 2012

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
Answer accepted
stevestreeting
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 31, 2012

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: http://blog.sourcetreeapp.com/2012/02/08/custom-actions-more-power-to-you/

joshgold October 31, 2012

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!

stevestreeting
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 1, 2012

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.

0 votes
joshgold November 5, 2012

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)

Thanks!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events