Package: mercurial_dynamic_username
Use different commit username per directory tree.With this extension you may commit asJohn Smith <john.smith@serious.com>in repositories below~/work, and asJohny <fastjohny@fantasy.net>in code under~/hobby- and set this
rule once, in~/.hgrc.1Example2Configuration syntax3Match priority4Testing configuration5Installation5.1Linux/Unix (from PyPI)5.2Linux/Unix (from source)5.3Windows6History7Repository, bug reports, enhancement suggestions8Additional notes1ExampleInstall the extension as described below.Write in your~/.hgrc:[extensions]
mercurial_dynamic_username =

[dynamic_username]
work.location = ~/work
work.username = John Smith <john.smith@serious.com>
hobby.location = ~/hobby ~/blogging
hobby.username = Johny <fastjohny@fantasy.net>and just commit. In any repository placed below~/workyou will commit asJohn Smith, in repos below~/hobbyasJohny, elsewhere default
setting (usernamefrom[ui]) will be used.2Configuration syntaxAll settings are defined in[dynamic_username]section, and have
the following form:«somelabel».location = «list of directory names»
«somelabel».username = «username used there»Labels are used only to join pairs of those settings together.Directory names specified in.locationare space or colon
separated, and can be quoted. Repository matches the rule if it
belongs to the directory tree(s) specified here. Tildas (~/..and~john/...) are properly expanded.Usernames have the same syntax as standardusername.Defining.locationwithout paired.usernameasks extension to
revert to standard username, for example:[ui]
username = Jake <jake@loose.net>

[dynamic_username]
work.location = ~/work
work.username = John Smith <john.smith@serious.com>
open.location = ~/work/open-sourcewill commit asJohn Smithin~/work/libs/veryimportant, but
will revert to defaultJakein~/work/open-source/libshared.3Match priorityIf more than one location matches repository, longest one is used
(like in theopen-sourceexample above).Longestis selected
using actual canonical path after tilda expansion (~/work/sthis
longer than/home/littlejohny/work).Dynamic usernames currently always win against[ui]-sectionusername, even if the latter is defined in per-repository.hg/hgrc. I would gladly give priority to the latter, but I have
no idea how to detect that without re-parsing the configuration.4Testing configurationYou can test your configuration by callling:hg showconfig ui.username(results should vary depending on the current working directory).
Handy way to compare:hg --cwd ~/work/libs/acme  showconfig ui.username
hg --cwd ~/hobby/blogging  showconfig ui.username5Installation5.1Linux/Unix (from PyPI)If you have workingpiporeasy_install:pip install --user mercurial_dynamic_usernameor maybe:sudo pip install mercurial_dynamic_username(or useeasy_installinstead ofpip). Then activate by:[extensions]
mercurial_dynamic_username =To upgrade, repeat the same command with--upgradeoption, for
example:pip install --user --upgrade mercurial_dynamic_username5.2Linux/Unix (from source)If you don’t havepip, or wish to follow development more closely:clone both this repository andmercurial_extension_utilsand put
them in the same directory, for example:cd ~/sources
hg clone https://foss.heptapod.net/mercurial/mercurial-extension_utils/
hg clone https://foss.heptapod.net/mercurial/mercurial-dynamic_username/update to newest tags,activate by:[extensions]
mercurial_dynamic_username = ~/sources/mercurial-dynamic_username/mercurial_dynamic_username.pyTo upgrade, pull and update.Note that directory names matter. Seemercurial_extension_utilsfor
longer description of this kind of installation.5.3WindowsIf you have any Python installed, you may install withpip:pip install mercurial_dynamic_usernameStill, as Mercurial (whether taken fromTortoiseHg, or own package)
uses it’s own bundled Python, you must activate by specifying the path:[extensions]
mercurial_dynamic_username = C:/Python27/Lib/site-packages/mercurial_dynamic_username.py
;; Or wherever pip installed itTo upgrade to new version:pip --upgrade mercurial_dynamic_usernameIf you don’t have any Python, clone repositories:cd c:\hgplugins
hg clone https://foss.heptapod.net/mercurial/mercurial-extension_utils/
hg clone https://foss.heptapod.net/mercurial/mercurial-dynamic_username/update to tagged versions and activate by path:[extensions]
mercurial_dynamic_username = C:/hgplugins/mercurial-dynamic_username/mercurial_dynamic_username.py
;; Or wherever you clonedSeemercurial_extension_utilsdocumentation for more details on
Windows installation.NoteDirectory names matter. Ifmercurial_dynamic_username.pycan’t findmercurial_extension_utils.pyin system path, it looks for it in
its own directory, in../mercurial_extension_utils, and in../extension_utils.6HistorySeeHISTORY.rst7Repository, bug reports, enhancement suggestionsDevelopment is tracked on HeptaPod, seehttps://foss.heptapod.net/mercurial/mercurial-dynamic_username/Use issue tracker there for bug reports and enhancement
suggestions.Thanks toOctobusandClever Cloudfor hosting this service.8Additional notesInformation about this extension is also available
on Mercurial Wiki:http://mercurial.selenic.com/wiki/DynamicUsernameExtensionCheck alsoother Mercurial extensions I wrote.