What are the best and must-have hg / mercurial extensions?
Solution 1
My own hit list:
The simple ones you must have:
-
color
: colorize output from commands likediff
andstatus
, which makes it easier to assess. -
pager
: browse long output a page at a time. -
fetch
: pull, update and merge from another repo in one step. -
graphlog
: display revision graphs in your shell, incredibly useful for looking at the branches in your log history. -
hgk
: browse the repository with a graphical interface (see also TortoiseHg and Murky)
If you enable pager
, you should configure it to not interfere with certain commands:
[pager]
pager = LESS='FSRX' less
ignore = version, help, update, serve, record
The intermediate extensions I highly recommend (and use frequently):
-
record
: lets you interactively select hunks of files to commit - perfect for when you are in the middle of one set of changes, and you end up fixing something that should have its own commit. -
extdiff
: configure an external diff tool (such as meld) -
share
: have multiple clones use the same repo history
The Advanced extensions I would not be without:
-
mq
: manage a stack of patches. Very powerful, allows layering of patches on top of the tree. -
notify
: send email notifications when a repo is changed. -
rebase
: reapply local changes on top of a new parent revision. -
largefiles
: work with large binary files outside the hg store
All the above are bundled with Mercurial, and are stable and well-tested. I highly recommend all of them.
Non-core extensions worth investigating:
-
shelve
: selectively put aside changes (at the granularity of hunks) and restore them. -
acl
: selectively allow access to different parts of the repository tree
Superseded extensions and migrated to core (info from @durin42):
-
forest
was been superseded by thesubrepo
support introduced in v1.3 -
bookmarks
is in core and always enabled -
transplant
is superseded bygraft
, a core command -
histedit
is in core as of v2.3, but is disabled by default -
inotify
is not recommended, as there is apparently a bug due to a race condition
Solution 2
graphlog
and mq
are especially tasty.
- Convert: convert to and from other systems
- Mq (Mercurial Queues): deal with changes as a stack of patches
- Forest: lets you commit to and update many nested Mercurial repositories at once
- Share: to save time and disk space when working with similar repositories
- Hgk: gives a graphical view of history
- Graphlog: I always type 'hg glog' not 'hg log'. An ascii art view of history
- Transplant: Useful when you only want to merge a few changesets from another branch. The newer
hg rebase
may have some overlap. - Rebase: A different way to deal with changes as a set of changesets on top of a branch.
git
users like to rebase. May replacemq
for many use cases. - Shelve: A place to stash the working copy's changes if you have to work on something else for a while.
- Bookmarks: Name the newest commit on a particular branch. Similar to
git
branches.
Solution 3
Not yet mentioned: mercurial_keyring
https://www.mercurial-scm.org/wiki/KeyringExtension
"Keyring extension uses services of the keyring library to securely save authentication passwords (HTTP/HTTPS and SMTP) using system specific password database (Gnome Keyring, KDE KWallet, OSXKeyChain, dedicated solutions for Win32 and command line)."
I use ssh to access my repos on GitHub and Bitbucket, and my keyphrase is held in the keychain. This extension lets Mercurial get it whenever needed.
Also required for me: hg-git
Mercurial plugin letting you pull and push git repos using hg as a client. Use it all the time.
Solution 4
If you're working with a slowish host like Bitbucket, progress is essential. Otherwise hg push
looks like it's hung :\
Solution 5
My list:
graphlog. I use it much more than hg log. (wish it could restrict to branches)
purge. remove all files not in Mercurial. I use this instead of or as a cleaner version of make clean.
Less used, but nice:
- children (lets you say "hg children -r XXX")
- parentrevspec: lets you say stuff like "foo~2 = foo^1^1 = foo^^ = first parent of first parent of foo"
I keep trying to use the history editing tools, but keep running into limitations. I want them to work.
- collapse
- histedit
- I consider rebase a history editing tol as well
By the way, beware: hgk and fetch are "unloved": https://www.mercurial-scm.org/wiki/UnlovedFeatures. But then, SubRepos are, not unloved, but a feature of last resort, and I use subrepos.
![JJ Rohrer](https://i.stack.imgur.com/gCbyJ.jpg?s=256&g=1)
JJ Rohrer
Engineer MBA - EdTech, Virtual Reality, and Parenthood (no particular order). Founder of School Twist and Ascendly.
Updated on July 09, 2022Comments
-
JJ Rohrer almost 2 years
I've been dabbling with hg / mercurial lately, namely in conjunction with Fogcreek's Kiln, and I'm trying to figure out what the must-have extensions are. Its a little tricky sifting through their extension list because I'm not interested in testing any buggy or impractical extensions, even if their description sounds awesome.
So, which hg extensions do you use?
See Using Extensions
-
JJ Rohrer over 14 yearsAny other comments on Subrepo vs. Forest? I'm not positive that either of them are actually useful/usable - which might imply I'm just 'doing it wrong.' I'm particularly interested in a robust improvement to SVN's 'extern'
-
Jerome over 14 yearscolor does not work on Windows (mercurial.selenic.com/bts/issue1579)
-
gavinb over 14 years@JJBigThoughts: I have recently started to experiment with subrepo support, with a view to using it for a very large project. According to the Mercurial authors, subrepo support is still somewhat experimental. Currently it works much like svn:externals, but only a few commands know about subrepos. The basics seem to work well, AFAICT. The main difference is that the version of each subrepo is effectively pinned, as the parent stores a reference to its revision number as well as location (which isn't necessarily a bad thing).
-
gavinb over 14 years@Jerome The colour extension seems to work fine in Cygwin.
-
tonfa over 14 yearsHow about patchbomb? I find it very handy, at least when you do open source stuff and review happens via mailing list.
-
Ry4an Brase over 14 yearsgraphlog is now built-in and always enabled with
-g
for the log command (and incoming an outgoing IIRC). -
Carl Meyer over 14 yearsRy4an: "now" meaning in tip? Not in 1.4.1 AFAICT.
-
gavinb over 14 years@tonfa: sure, patchbomb looks very useful; I just haven't tried it yet so I can't recommend or comment on it. On a related note, the extensions that Google developed for Go source reviews via Reitveld look very interesting.
-
jamessan almost 14 yearsThe
-g
flag for log is to enable git style diffs, which is completely different fromgraphlog
. -
alexandrul almost 14 years@Jerome color extension in ANSI mode + tpager are working fine for me on Windows (tpager can be fount on Bitbucket and CodePlex)
-
Jerome almost 14 yearscolor has been fixed in mercurial 1.6
-
Ry4an Brase about 12 yearsMy error. It's
-G
to get a graphlog out of graph, but you still need the extension enabled for now. -
durin42 almost 12 yearshistedit is part of the latest hg release (2.3), bigfiles became largefiles and is also now part of the tree (since at least 2.2, but maybe earlier). I'd be a little wary of inotify - it sometimes has races that result in weird status output. transplant is superseded by the core 'graft' command (which is smarter). Starting in 2.1 (I think) bookmarks are always on.
-
gavinb almost 12 years@durin42 I updated the answer based on comments here and in the recent HN article. Please let me know if there's anything I missed or needs updating.
-
Admin over 11 yearsyou can also add
progress
extension -
GabLeRoux over 7 yearsCreate an awesome list with this inside! :) There's one for git. I don't use mercurial much, but looks like there's plenty of good things for mercurial too!
-
GabLeRoux over 7 yearsThese from your list are marked as deprecated:
fetch
,graphlog
andrecord
. Saw this usinghg extensions help