I would like to ignore all files that start with:
._
How would I write this in the .hgignore file?
$ cat .hgignore
syntax: glob
._*
Which I have tested thusly (with some "noise" like .. removed for clarity):
$ ls -aRF
.:
a ._a .hgignore sub/
./sub:
a ._a
$ hg stat
? .hgignore
? a
? sub/a
Related
I would like to export files from a repository, ignoring changes in the working tree. Furthermore, rather than exporting everything, I would like to see a subset of it. The destination directory might already contain some files and those must be overwritten.
Given:
project/some/sub/dir/
I would like to export it to:
output/dir/
In git, I can use:
git archive --prefix=dir/ HEAD -- some/sub/dir/ | tar -xv -C output
What is the equivalent command in hg? If I use hg archive -t files -I some/sub/dir output/, then I get output/some/sub/dir. I could pipe the result through tar, but then I have to manually calculate the prefix that should be dropped:
hg archive -t tar -I some/sub/dir/ - |
tar -xv -C output --strip-components=3
(in reality, I have some other tar patterns that should be ignored such as --exclude='.*'). Any ideas? This export will be done for three other directories located in the repository.
Current situation:
srcdir=some/sub/dir
dstdir=output/dir
# hg archive auto-adds a 'proj-version' prefix. Given the srcdir,
# proj-version/some/sub/dir/X should become dstdir/X, so strip 4 components
prefixlength=$(grep -c / <<<"/${srcdir%%/}/")
hg archive -t tar -I "$srcdir" - |
tar -xv -C "$dstdir" --strip-components=$prefixlength
You can
hg archive ... && cd output/some/sub/dir && tar ... isn't it?
Build intermediate repo (Convert Extension), where some/sub/dir/ will be root of this repository (understand also sample from Converting from Mercurial topic) and get tar'red archive directly from hg archive for intermediate repository
Situation
$ cat .hgignore
.hgignore
$ hg status
M file1
M file2
M src/project.xml
I don't want to track the project.xml so I run
echo "project.xml" >> .hgignore
and the result is
$ cat .hgignore
.hgignore
project.xml
$ hg status
M .hgignore
M file1
M file2
M src/project.xml
So the .hgignore is now as modified even though it shouldn't be tracked and nothing happend with the project.xml. What does this mean?
You wrote:
"M src/project.xml"
which means that src/project.xml is under version control.
A file already under version control cannot be ignored! The
.hgignore file is for ignoring files that are untracked (status
will show a "?").
You have two solutions to ignore your file:
You can either "hg forget" the file, the opposite of "hg add" (i.e.,
telling Mercurial not to track this file anymore), or
You can use the ”-X” option as a default for status/diff/commit
in your .hg/hgrc configuration file, e.g.,
[defaults]
status = -X <file>
diff = -X <file>
commit = -X <file>
which will tell hg not to include this file in the use of status, diff, and commit.
I have to get list of changed, added or removed files since last commit.
command: hg status gives me for example
M file_path
C other_file_path
I need:
file_path
other_file_path
Solution have to work in Unix & Windows.
If you want to list all of the files, you can simply add -n to the hg status command:
$ hg status
M modded.txt
A added.txt
R removed.txt
? unknown.txt
$ hg status -n
modded.txt
added.txt
removed.txt
unknown.txt
However, this will also list unknown files (those that are new, but have not been specifically added to the repository with a hg add command). You can get around this by adding either -q (as Lazy Badger points out), or by using filesets (see hg help filesets) to specify all files that aren't unknown:
$ hg status -n -q
modded.txt
added.txt
removed.txt
$ hg status -n "set:!unknown()"
modded.txt
added.txt
removed.txt
You can specify which types of files are listed by combining the other options (-a -r for example will show added and removed files). Alternatively you can do clever things with filesets: for example, only listing the names of files that are removed by using "set:removed()"
In the documentation they use a mapfile with these contents:
$ echo include subfoo > /tmp/myfilemap
$ echo rename subfoo . >> /tmp/myfilemap
$ hg convert --filemap /tmp/myfilemap /path/to/repo/foo /tmp/mysubfoo-repo
What are the advantages of merging 2 repos like. Is there a valid reason not to do this:
hg pull -f other_repo
hg merge
What are they accomplishing via the rename of subfoo to . ?
Their example (the subfoo filemap you posted in your question) is for converting a subdirectory of an existing repo to a repository of its own, with all the history of the files under that subdirectory. The rename of subfoo to . means that all files and directories of the directory subfoo in the source repo will now be under the root of the new repo.
You could use a filemap with rename to do the opposite and to make the contents of the root of repo A now the contents of a subdirectory, then combine it with repo B using pull:
> echo rename . subfoo > /tmp/myfilemap
> hg convert --filemap /tmp/myfilemap /path/to/repoA /path/to/repoA_converted
> hg -R /path/to/repoB pull -f /path/to/repoA_converted
> hg merge
However, subrepos might be a better alternative to that.
I know that Mercurial can track renames of files, but how do I get it to show me renames instead of adds/removes when I do hg status? For instance, instead of:
A bin/extract-csv-column.pl
A bin/find-mirna-binding.pl
A bin/xls2csv-separate-sheets.pl
A lib/Text/CSV/Euclid.pm
R src/extract-csv-column.pl
R src/find-mirna-binding.pl
R src/modules/Text/CSV/Euclid.pm
R src/xls2csv-separate-sheets.pl
I want some indication that four files have been moved.
I think I read somewhere that the output is like this to preserve backward-compatibility with something-or-other, but I'm not worried about that.
There are several ways to do this.
Before you commit, you can use hg diff --git to show what was renamed:
$ hg diff --git
diff --git a/theTest.txt b/aTest.txt
rename from theTest.txt
rename to aTest.txt
Note that this only works if you used hg mv, hg rename, or mv and hg addremove --similarity 100.
After you commit, you can still use hg diff, but you'll have to specify the change using -r:
$ hg diff -r 0 -r 1 --git
diff --git a/test.txt b/theTest.txt
rename from test.txt
rename to theTest.txt
For both hg status and hg log, use the -C command-line flag to see the source that a file was copied from.
$ hg status -C
A aTest.txt
theTest.txt
R theTest.txt
The line just below aTest.txt indicates the source it was copied from (theTest.txt).
$ hg log -v -C
changeset: 1:4d7b42489d9f
tag: tip
user: jhurne
date: Tue Apr 20 20:57:07 2010 -0400
files: test.txt theTest.txt
copies: theTest.txt (test.txt)
description:
Renamed test.txt
You can see the files that were affected (test.txt and theTest.txt), and that "theTest.txt" was copied from test.txt.
You can find out how many files have been renamed with hg summary. If you want to see the actual files that were renamed, the fastest way I've found is to do:
hg st -a -C
This will output something like this:
A <path\to\renamed\file>
<path\copied\from>
A <path\to\added\file>
A <path\to\renamed\file>
<path\copied\from>
Since hg status considers a rename to be a copy and a remove, your renamed files will list a copied from file. Files that were added but not renamed will not list a copied from file.