Hg

From Attie's Wiki
(Difference between revisions)
Jump to: navigation, search
m (~/.hgrc)
m
 
(8 intermediate revisions by one user not shown)
Line 3: Line 3:
 
{{note|By the way... there is a system-wide config file, here: <code>/etc/mercurial/hgrc</code>}}
 
{{note|By the way... there is a system-wide config file, here: <code>/etc/mercurial/hgrc</code>}}
  
==~/.hgrc==
+
{{:hgrc}}
<source lang="ini">
+
[ui]
+
username = Attie Grande <attie@attie.co.uk>
+
verbose = True
+
 
+
[defaults]
+
revert = --no-backup
+
 
+
[pager]
+
pager = less -FRSX
+
 
+
[color]
+
# configure colors for each possible hg status
+
status.modified = blue bold
+
status.added = green bold
+
status.removed = red bold
+
status.deleted = cyan bold
+
status.unknown = magenta bold
+
status.ignored = white bold
+
# and for hg diff output also
+
diff.diffline = bold
+
diff.extended = cyan bold
+
diff.file_a = white bold
+
diff.file_b = white bold
+
diff.hunk = cyan
+
diff.deleted = red
+
diff.inserted = green
+
diff.changed = white
+
diff.trailingwhitespace = bold red_background
+
 
+
[diff]
+
showfunc = true
+
 
+
[extensions]
+
hgext.convert =
+
pager =
+
color =
+
mq =
+
record =
+
</source>
+
  
 
==Git Conversion==
 
==Git Conversion==
 
{|class="wikitable"
 
{|class="wikitable"
! Git Command !! Hg Command
+
! Git Command !! Hg Command !! Comment
 
|-
 
|-
| git show HEAD || hg log -pr tip
+
| git show HEAD || hg log -pr tip ||
 
|-
 
|-
| git show ${COMMIT} || hg log -pr ${COMMIT}
+
| git show ''${COMMIT}'' || hg log -pr ''${COMMIT}'' ||
 +
|-
 +
| git commit -p || hg record ||
 +
|-
 +
| git pull || hg pull -u ||
 +
|-
 +
| git fetch || hg pull ||
 +
|-
 +
| git log || hg log -f || Mercurial's log lies... it includes everything - be careful!
 +
|-
 +
| git checkout -b ${BRANCH_NAME} || hg branch ${BRANCH_NAME} ||
 +
|-
 +
| git cherrypick ${COMMIT} || hg graft ${COMMIT} ||
 
|}
 
|}
 +
 +
For more see [http://mercurial.selenic.com/wiki/GitConcepts#Command_equivalence_table here]
  
 
==Default Push==
 
==Default Push==
Line 75: Line 49:
 
</source>
 
</source>
  
==Authentication==
+
==Authentication (HTTP)==
 
{{warning|You didn't hear this from me... You should never use it (think SSH with keys)}}
 
{{warning|You didn't hear this from me... You should never use it (think SSH with keys)}}
 +
If you're using the mercurial_keyring extension, then you can leave the '*.password' line out for slightly improved security.
 +
 
If you're using HTTP to access a repository, you can add the following section to your <code>~/.hgrc</code> file:
 
If you're using HTTP to access a repository, you can add the following section to your <code>~/.hgrc</code> file:
 
<source lang="ini">
 
<source lang="ini">
Line 83: Line 59:
 
svr.username = attie
 
svr.username = attie
 
svr.password = supersecret
 
svr.password = supersecret
 +
svr2.prefix = http://my.server2/
 +
svr2.username = attie
 +
svr2.password = supersecret
 +
</source>
 +
 +
==Authentication (TortoiseHg & SSH keys)==
 +
I've seen a number of computers have issues with using MercurialHg with PPK keys and pageant (<code>*.ppk</code> keys)...
 +
The fix isn't nice, but it works.
 +
Add the following to your </code>mercurial.ini</code>
 +
 +
<source lang="ini">
 +
[ui]
 +
ssh = tortpiseplink.exe -ssh -i "${KEY}"
 
</source>
 
</source>

Latest revision as of 12:16, 3 November 2015

My Mercurial cheat sheet! See also: git and svn

Note: By the way... there is a system-wide config file, here: /etc/mercurial/hgrc

Contents

[edit] ~/.hgrc

[ui]
username = Attie Grande <attie@attie.co.uk>
verbose = True
merge = internal:merge
ignore = ~/.hgignore
 
[defaults]
revert = --no-backup
 
[alias]
br = branches
lg = log -G --pager always
rev = parent --template '{node} {branch}\n'
ph = phase -r tip
drafts = log -r 'draft()'
 
[pager]
pager = less -FRSX
 
[diff]
showfunc = true
 
[color]
# configure colors for each possible hg status
status.modified = blue bold
status.added = green bold
status.removed = red bold
status.deleted = cyan bold
status.unknown = magenta bold
status.ignored = white bold
# and for hg diff output also
diff.diffline = bold
diff.extended = cyan bold
diff.file_a = white bold
diff.file_b = white bold
diff.hunk = cyan
diff.deleted = red
diff.inserted = green
diff.changed = white
diff.trailingwhitespace = bold red_background
 
[auth]
# this is a bad idea...
service1.schemes = http https
service1.prefix = service.domain.com/
service1.username = attie
service1.password = password
 
[extensions]
hgext.convert = 
pager = 
color = 
mq = 
record = 
shelve = 
graphlog = 
mercurial_keyring = 
histedit = 
rebase = 
 
[trusted]
users = alice, carl, dan

[edit] Git Conversion

Git Command Hg Command Comment
git show HEAD hg log -pr tip
git show ${COMMIT} hg log -pr ${COMMIT}
git commit -p hg record
git pull hg pull -u
git fetch hg pull
git log hg log -f Mercurial's log lies... it includes everything - be careful!
git checkout -b ${BRANCH_NAME} hg branch ${BRANCH_NAME}
git cherrypick ${COMMIT} hg graft ${COMMIT}

For more see here

[edit] Default Push

If you create a local repository, and later want to push it to a remote repo, then you'll need to setup the default-push target.
Put the following in your ./.hg/hgrc file:

[paths]
default = ${REMOTE_REPO}

[edit] Trust

If you've seen a message similar to the following:

Not trusting file /home/alice/repo/.hg/hgrc from untrusted user alice, group users

Add the following section to your ~/.hgrc file with one or both of the lines.

[trusted]
users = alice, carl, dan
groups = dev-team

[edit] Authentication (HTTP)

WARNING: You didn't hear this from me... You should never use it (think SSH with keys)

If you're using the mercurial_keyring extension, then you can leave the '*.password' line out for slightly improved security.

If you're using HTTP to access a repository, you can add the following section to your ~/.hgrc file:

[auth]
svr.prefix = http://my.server/
svr.username = attie
svr.password = supersecret
svr2.prefix = http://my.server2/
svr2.username = attie
svr2.password = supersecret

[edit] Authentication (TortoiseHg & SSH keys)

I've seen a number of computers have issues with using MercurialHg with PPK keys and pageant (*.ppk keys)... The fix isn't nice, but it works. Add the following to your </code>mercurial.ini</code>

[ui]
ssh = tortpiseplink.exe -ssh -i "${KEY}"
Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox