Repository specific special / dot files in Mercurial - configuration

What are the most important special / dot files when using a hg repo ?
Like configuration files and similar.

There are a lot of files that a Mercurial repo will use for configuration or keep track of state, but here are the ones that have the best chance to come in handy:
.hg/last-message.txt -- used by hg commit to store backup of the commit message in case the commit fails.
Example:
My commit message!
.hg/localtags -- define local tags which are not shared among repositories.
Example:
8a7b128ab80b58fc2e63258c9e2bf1f58a5be7c2 myfirsttag
08ff3a0b2e5af9a74becbfdf3e92d6e9a2d0c960 secondtag
6535d105ea795a38808481b160314f9857736c53 thirdtag
.hgignore -- regular expressions that describe file names that should be ignored by hg.
Example:
syntax: glob
*.elc
*.orig
*.rej
*~
*.mergebackup
*.o
*.so
*.dll
*.exe
*.pyd
*.pyc
.hg/hgrc -- defaults and configuration values for mercurial.
Example:
[ui]
verbose = True
username = Joe User <j.user#example.com>
[extensions]
hgext.churn = /home/user/hg/hg/contrib/churn.py
[hgk]
path = /home/user/hg/hg/contrib/hgk
.hgsub -- locations of all subrepositories and where subrepository checkouts came from.
Example:
subrepo1 = https://user#example.org/user/repo
subrepo2 = https://user#example.org/user2/repo2
.hgtags -- contains changeset hash values and text tag names
Example(same format as localtags):
8a7b128ab80b58fc2e63258c9e2bf1f58a5be7c2 myfirsttag
08ff3a0b2e5af9a74becbfdf3e92d6e9a2d0c960 secondtag
6535d105ea795a38808481b160314f9857736c53 thirdtag

Related

How to get the list of all files in all branches?

Is there any way to get the list of all files (say all js or all css files) in my repo across ALL THE BRANCHES.
For example:
In my 'default' branch, i might not have a file named file1.js.
But in another branch named 'NEW_BRANCH', file1.js may exists.
I wanted to get the list of all files from one place or one command.
What about getting all files from all revisions including those still present, renamed and deleted?
hg manifest --all
If you only want files from the top of all branches (thus heads, then we iterate over all named and unnamed branches), you'll have to resort to some bash or similar, e.g.
for h in $(hg heads -T"{rev}\n"); do hg ma -r$h; done | sort | uniq
Some thing as?:
for b in `hg branches|cut -d ' ' -f 1` ; do echo "${b}: " ; hg manifest -r "branch(${b})"|grep ".css" ; echo

Mercurial & Keyword ext.: updating keywords when tagging a revision

I'm using Mercurial with the keyword extention, and I'm very pleased with it. Expect one thing, expanding the version tag which is:
Version = {latesttag|nonempty}
All the keywords are expanded as expected on every check in. But when I'm tagging a revision, nothing happens at this moment. I expect/want to expand the tags in all files. Right now the version tag gets updated/expanded on the next commit of a file. I guess, I have to do this with a hook, but i stuck with this.
Any suggestions?
Thank you very much
Roland
Your filter do nothing, because for repository without tags `{latesttag} returns "null" text-string
Keywords in files have "this file" scope, not global, i.e reflect only state at the time of last change of file, and, for tagging (which commit only .hgtags) not changing $Version$ is expected
All the keywords are expanded as expected on every check in
Only for files in this changeset, not included files aren't touched. See at final content of two (originally identical) files in repo
Current version of file: $Version$ and $Revision$
each of which was committed some times separately
>hg log file.txt -l 1
changeset: 5:3ceaea734895
>hg log file2.txt -l 1
changeset: 3:09939c9b8243
file.txt
Current version of file: $Version: v 0.1 $ and $Revision: 3ceaea734895 $
file2.txt
Current version of file: $Version: v 0.1 $ and $Revision: 09939c9b8243 $
If you want to change keywords in all files for every commit, you can|have to include files in questions in every commit (it can be alias, which uses commit -I)

how do I open files with conflicts during git/mercurial merge in textmate/sublime

how do I open from terminal window only files with conflicts during git/mercurial merge in textmate/sublime text2 editors
You can use the following to open all files with git merge conflicts in sublime text:
git diff --name-only | uniq | xargs subl
I wanted to add another answer. git diff --name-only will give you all files that have diffs. This is why sometimes it will yield duplicate entries because it marks the file as "modified" as well as in a merge conflict state. Piping it into uniq is a good solution for this but git diff --name-only will also include files you might have purposely changed so it doesn't actually filter only files with merge conflicts. When you are in the middle of rebasing, this is probably not going to happen often though I would say in most cases #StephanRodemeier's answer works.
However, what you can do though is leverage the --diff-filter option which assigns a states to files. See more in the docs
--diff-filter=[(A|C|D|M|R|T|U|X|B)…​[*]]
Select only files that are Added (A), Copied (C), Deleted (D), Modified (M), Renamed (R), have their type (i.e. regular file, symlink, submodule, …​) changed (T), are Unmerged (U), are Unknown (X), or have had their pairing Broken (B). Any combination of the filter characters (including none) can be used. When * (All-or-none) is added to the combination, all paths are selected if there is any file that matches other criteria in the comparison; if there is no file that matches other criteria, nothing is selected.
It seems when files are in the both modified state, the diff status gets set to U (Unmerged) and M (Modified) so you can filter for only Unmerged files.
git diff --diff-filter=U --name-only | xargs subl
Should work without needing to pipe into uniq
Another thing you can consider is simply setting your editor as the difftool i.e. for VSCode documentation specifies how to do this by adding this to your .gitconfig
[diff]
tool = default-difftool
[difftool "default-difftool"]
cmd = code --wait --diff $LOCAL $REMOTE

Mercurial ignore all files except specific file names

I have a large file system in which almost every folder has a file called content.txt
I want to track every file named content.txt and automatically ignore everything else. I want the repo to automatically track new files named content.txt so I don't want to ignore everything in the .hgignore and then manually add.
Anyone know how to do this?
It has to be regexp mode, not glob
You must debug path-part of regexp, but "all except content.txt" draft is re:.*\.(?!content.txt) as hope
Alternative solution can be
* ignore all
* add content.txt files pattern to commit command (-I option), see hg help commit and hg help patterns
hg commit -I '**content.txt'
Edit
re:.*/(?!content.txt)
Try this:
syntax: regexp
\.(?!txt$)[^.]+$ # "*." is followed by "txt" and we're at the end
(?<!\.)txt$ # "txt" follows a "."
(?<!/)content\. # "content." follows path separator
(?<!content)\. # "." follows "content"
I left in the comments I made while experimenting, to make sense of it all. (That's glob syntax in the first one.)

Regarding Mercurial Security + recursive checkins of subrepositories

this is going to be a long post...sorry upfront.
I'm trying to wrap my head around how to hold together "Repositories for each project branch", and what the impact of that would be on a team.
Right now, it appears that
Can recursively checkin code of
nested checkins although hg status
doesn't give much info on file
changes within nested repos
It
appears that I -- and every team
member who wants to work on the same
project -- has to hand edit their
subrepositoies' .hgrc files in order
to make the checkin as painless and
automated as possible.
Can
recursively checkin, but recursively
checkout is not supported.
Is that a correct analysis of Hg's capabilities?
I'm really hoping not, as that's a lot more stick-shift coding (ie command prompt fiddling all over the place), than the average dev team I've seen could handle, while remaining productive. As I've understood it, refactoring a single assembly would probably grind the team to a halt as they stop to edit the .hgrc files to add location, user and password. No?
And I really want to double check that Hg can't recursively pull? Sounds like such an omission, that I feel I must have missed something.
Thanks!
PS:
For the brave or foolish, (and in case it helps), the notes I've been keeping as I work around the problem of projects that reference library modules that reference other library modules, is as follows (note the ???? QUESTIONS??? interspersed in them...
MERCURIAL
# requires an .hgsub with a ref to either
# an Hg Repo for only one Bin...?
# a website download...is that possible?
# an svn repo that allow referencing just one folder in it
# eg: "BIN/A3rdParty = svn:^/BinCache/A3rdParty/bin"
LibA\
hg\
.hgrc
# ??? QUESTION ???
# does each user have to edit their own files by hand
# to allow automatic push/pull?
# "default = https://user:pwd#bitbucket.org/xact/liba"
# "default-push = https://user:pwd#bitbucket.org/xact/liba"
.hgsub
# Map of nested repos as follows:
# "BIN/A3rdParty = svn:^/BinCache/A3rdParty/bin"
# "EXT/LibA = https://bitbucket.org/xact/liba"
# "EXT/LibB = https://bitbucket.org/xact/libb"
LibA.sln
BIN\
[A3rdParty\SomeLib.dll]
EXT\
SRC\
LibA\LibA.csproj
# ...which References "..\..\BIN\A3rdParty\SomeLib.dll"
LibA.Tests\LibA.Tests.csproj
# ...which References "..\LibA\LibA.csproj"
LibB\
hg\
.hgrc
# ??? QUESTION ???
# does each user have to edit their own files by hand
# to allow automatic push/pull?
# "default = https://user:pwd#bitbucket.org/xact/libb"
# "default-push = https://user:pwd#bitbucket.org/xact/libb"
.hgsub
# that contains:
# "BIN/A3rdParty = svn:^/BinCache/A3rdParty/bin"
# "EXT/LibA = https://bitbucket.org/xact/liba"
# ??? QUESTION ???
# do end users add user/pwd info here? or in the
# nested repos .hgrc file?
LibB.sln
BIN\
[A3rdParty\SomeLib.dll]
EXT\
LibA\
hg\
.hgrc
# ??? QUESTION ???
# does each user have to edit their own files by hand
# to allow automatic push/pull?
# "default = https://user:pwd#bitbucket.org/xact/liba"
# "default-push = https://user:pwd#bitbucket.org/xact/liba"
LibA.csproj
# ...which References "..\..\BIN\A3rdParty\SomeLib.dll"
LibA.Tests\LibA.Tests.csproj
# ...which References "..\LibA\LibA.csproj"
SRC\
LibB\LibB.csproj
# ...which References "..\..\EXT\LibA\LibA.csproj"
LibB.Tests\LibB.Tests.csproj
# ...which References "..\LibB\LibB.csproj"
ProjA\
hg\
.hgrc
# ??? QUESTION ???
# does each user have to edit their own files by hand
# to allow automatic push/pull?
# "default = https://user:pwd#bitbucket.org/xact/proja"
# "default-push = https://user:pwd#bitbucket.org/xact/proja"
.hgsub
# that contains:
# "BIN/A3rdParty = svn:^/BinCache/A3rdParty/bin"
# "EXT/LibA = https://bitbucket.org/xact/liba"
# "EXT/LibB = https://bitbucket.org/xact/libb"
# ??? QUESTION ???
# do end users add user/pwd info here? or in the
# nested repos .hgrc file?
BIN\
[A3rdParty\SomeLib.dll]
EXT\
LibA\
hg\
.hgrc
# ??? QUESTION ???
# does each user have to edit their own files by hand
# to allow automatic push/pull?
# "default = https://user:pwd#bitbucket.org/xact/liba"
# "default-push = https://user:pwd#bitbucket.org/xact/liba"
LibA.csproj
# ...which References "..\..\BIN\A3rdParty\SomeLib.dll"
LibA.Tests\LibA.Tests.csproj
# ...which References "..\LibA\LibA.csproj"
LibB\
hg\
.hgrc
# ??? QUESTION ???
# does each user have to edit their own files by hand
# to allow automatic push/pull?
# "default = https://user:pwd#bitbucket.org/xact/libb"
# "default-push = https://user:pwd#bitbucket.org/xact/libb"
LibB\LibB.csproj
# ...which References "..\..\EXT\LibA\LibA.csproj"
# Important: note that it is same path offset
# as when within context of LibB.sln
LibB.Tests\LibB.Tests.csproj
# ...which References "..\LibB\LibB.csproj"
SRC\
ProjA\ProjA.csproj
ProjA.Tests\ProjA.Tests.csproj
I will try to answer some of your questions though I really think you should discuss this with us instead of doing a Q&A here.
Right now, it appears that
Can recursively checkin code of nested checkins although hg status doesn't give much info on file changes within nested repos
See hg status --subrepos or hg status -S for short.
It appears that I -- and every team member who wants to work on the same project -- has to hand edit their subrepositoies' .hgrc files in order to make the checkin as painless and automated as possible.
No need to put usernamed and passwords into the .hg/hgrc files -- you should instead configure caching of HTTP credentials in Mercurial.
Can recursively checkin, but recursively checkout is not supported.
Checkout, i.e., update, is recursive. When you do hg clone to get a local repository, then Mercurial will notice the .hgsub and .hgsubstate files and it will recursively clone the subrepositories referenced there.
And I really want to double check that Hg can't recursively pull? Sounds like such an ommission, that I feel I must have missed something.
Yes, you're missing how Mercurial knows which subrepositories you want. Please see the documentation on the wiki or the Kick Start guide.