Alerting myself of uncommitted changes
Asked by Evan Carter:

I've just set up SourceTree and BitBucket (with Mercurial) so that I can track revisions of my personal scripts and libraries and access them from other machines on occasion. I'm concerned about forgetting to commit changes I make, so I'd like to set up a cron job (or actually, a launchd job, since I'm using a Mac) to check for uncommitted changes and alert me if there are any. I'm new to cloud source control, but I think what I want is to run the equivalent of "hg diff". My working copy will always be in the same place. I ran "Install command line tools" in SourceTree but as far as I can tell that only gave me a tool called stree that serves a different purpose. What should I do? Should I install regular command line Mercurial (looks like from <http://mercurial.berkwood.com/>) or will that installation fight with SourceTree?


Answers:
author: Timothy
body: You can choose which hg binaries you want to use in SourceTree preference which means you can use both binaries at the same time.

I used this ([](http://www.macupdate.com/app/mac/7486/cronnix)<http://www.macupdate.com/app/mac/7486/cronnix>) to run bash scripts. You could create your own scripts and check if there are any files that are not changed:

* hg diff -r START -r END

You can test out the various scenarios, grep the output and do something with it ([](http://apple.stackexchange.com/questions/57412/how-can-i-trigger-a-notification-center-notification-from-an-applescript-or-shel)<http://apple.stackexchange.com/questions/57412/how-can-i-trigger-a-notification-center-notification-from-an-applescript-or-shel>)

comments: author: Evan Carter
body: Thank you, Timothy. Am I right that SourceTree's embedded Mercurial is not accessible (e.g., from the command line)?


author: Timothy
body: Not sure. Never tried to find them before.


author: Seth
body: Does SourceTree for Mac have a terminal button? If so, does it launch a terminal emulator (on windows it launches mingw), or just the standard Mac terminal in a special location?


author: KieranA
body: Yes, ST for Mac has a terminal button. It just opens up the regular terminal at the location of the repository on disk.


author: Seth
body: Then I expect you can run embedded Mercurial from the terminal.


author: Evan Carter
body: > Then I expect you can run embedded Mercurial from the terminal.

How would I do this? I've tried just running "hg diff" at the prompt, and "find / -name hg" does not find anything.


author: KieranA
body: Yes, you just need to be contextually specific. When you run any command from the terminal it uses your PATH as a reference. At the terminal, type "echo $PATH" and you'll see a load of output. Those are colon-separated paths which are used in order of appearance to find whatever it is you're calling from the terminal.

To call the SourceTree version in specific you'd have to specify the path explicitly, so "/path/to/the/hg/install/hg \<command\>".

Hope that helps


author: Seth
body: Kieran, do you know what the default path is to embedded hg?


author: KieranA
body: /Applications/SourceTree.app/Contents/Resources/mercurial_local/mercurial


author: Evan Carter
body: The command I wanted (to plug into a script as described by Timothy C.) was:

```
/Applications/SourceTree.app/Contents/Resources/mercurial_local/hg_local diff
```


author: Evan Carter
body: Thank you, everyone. For posterity the command I wanted was:

```
/Applications/SourceTree.app/Contents/Resources/mercurial_local/hg_local diff
```