$ hg status
M ...
M ...
M ...
? ...
? ...
? ...
I need to add all not tracked (? marked) files. Is it possible?
I can do "hg add *" but I will get many messages unwanted 'file already tracked'.
Just use hg add with no *.
When no files are given, it adds all untracked files, that is, all files with ? in front of the output of hg status.
Files that are ignored because of .hgignore will not be added by hg add without filenames.
Related
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
I know from this answer that I can do
hg status --rev x:y
to list files that have been changed between revisions x and y. Is there a way to get not the indiviual files but only the directories in which they are contained?
For example if the above command would yield
A Foo\Bar\SomeFile.txt
A Foo\Bar\AnotherFile.cs
M Baz\AnotherFile.txt
I want to get
Foo\Bar
Baz
instead.
Not a ready-to use solution (see end-notes), just hints
You can use templates for changing output format of hg st, as it can done for any "log-like" hg commands (see -T option)
in template you can filter output (filenames) with filter "dirname", which'll strip filename part of file
but I tried it and discovered (on my repos) some "oddities" (and expected troubles)
End-notes:
While default output of hg st eliminates duplicate filenames (if they appear) in result, your template will not (again, "by default")
I saw wrong (totally wrong) result of templated output for the same range of status
good
>hg st --rev 1170:tip
M hggit\__init__.py
M hggit\compat.py
M hggit\git_handler.py
M hggit\gitdirstate.py
M hggit\hg2git.py
M tests\test-illegal-contents.t
my
>hg st --rev 1170:tip --template "{files % '{file}\n'}"
hggit/__init__.py
hggit/__init__.py
hggit/__init__.py
hggit/__init__.py
hggit/__init__.py
hggit/__init__.py
(six times files from tip only instead of range)
Even with hg log -T instead of st (which give all files) you'll have problem from p.1: "more than one file-entry in output for the same file"
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
Is there a way to select only those files that have the Modified status?
And is it possible to chain the selection to add more specific selectors?
I want to export the changes in those Modified files, revert to a changeset before I installed the plugin, and re-import changes.
hg diff -I with pattern matching could help, but in this case, and very often, I just want to select files based on their status.
Example of hg st (actual content varies with different folder and filenames/extension):
M /readme.txt
M /dir1/somefile1.txt
M /dir2/somefile2.txt
M /dir3/somefile3.txt
M /dir4/somefile4.txt
! /plugin/lotsoffileshere.txt
! /plugin/lotsoffileshere.txt
! /plugin/lotsoffileshere.txt
Read about filesets in mercurial: hg help filesets
If you want get diff for all modified files (hg diff FILE1 FILE2 ... FILE), build filest for "modified files in repo" in will be (only help was used)
hg diff "set:modified()"
I've seen the posts for hgignore everything except, but I can't seem to transform the regex to work with subdirectories as well.
syntax: regexp
(?<!\.cfm)$
Works for the root directory but not subdirs/subsubdirs. I don't want to manually specify those.
This is what I see without the ignore:
>hg stat
? document.cfm
? document.txt
? subdir1\document.cfm
? subdir1\document.txt
? subdir1\subsubdir1\document.cfm
? subdir1\subsubdir1\document.txt
? subdir2\document.cfm
? subdir2\document.txt
This is what I see with the ignore:
>hg stat
M .hgignore
? document.cfm
This is what I want to see:
>hg stat
? document.cfm
? subdir1\document.cfm
? subdir1\subsubdir1\document.cfm
? subdir2\document.cfm
Adding a file overrides ignores, so for the .hgignore if you've already added it you don't need to worry about including it. That makes this much easier.
syntax: regexp
(?<!\.cfm)$
assuming that what you were trying to do is ignore everything except .cfm files. Example:
% hg stat --all
A .hgignore
I adir/file.cfm
In general, don't overcomplicate the regex lines -- if you're (un)ignoring two different categories of things use two lines.
The desired action is impossible. Python only does fixed-width negative lookups. Closing this question. Thanks to anyone who looked into it.