merging & hgignore
tom.anderson at e2x.co.uk
Thu Jun 30 12:29:46 CDT 2011
On 30 June 2011 17:33, Matt Mackall <mpm at selenic.com> wrote:
> On Thu, 2011-06-30 at 11:17 -0400, Scott Palmer wrote:
>> On 2011-06-30, at 9:47 AM, Mads Kiilerich wrote:
>> > On 06/30/2011 03:34 PM, watlab wrote:
>> >> Quite simple use case:
>> >> Branch A contains file1 and a .hgignore file, which contains "file2".
>> >> Branch B contains file1 and file2 (and no .hgignore).
>> >> Now I want to merge changes in file1 from B into A. But of course, I don't
>> >> want to get file2 added to Branch A.
>> >> How can this be achieved?
>> > You can "hg rm file2" before you commit the merge.
>> It might be nice to have an option to "hg rm" to get it to re-evaluate the existing tracked files with the rules in .hgignores
>> Or even something as simple as a command to print a list of the tracked files that would or wouldn't be matched by the .hgignore rules. then you could generate a list of "hg rm" commands from it.
> In 1.9, to be released tomorrow:
> hg locate 'set:hgignore()'
> hg rm 'set:hgignore()'
In the mean time, if you have access to a sufficiently unixlike
environment, you can do this with the find command. Assuming your
.hgignore is in regexp format, uses only POSIX extended regexps (a
subset of what Python supports, i think), and contains no blank lines
or comments, then this will print all files that should be ignored:
find $REPO -path $REPO/.hg -prune -o -regextype posix-extended -regex
"$REPO/($(echo -n $(sed 's#^\^##; t $; s#^#(.*/)?#; :$ s#/$#$#;
s#.*#(&)#' $REPO/.hgignore) | tr ' ' '|')).*" -print
You can then pipe that to xargs hg rm. What could be easier?
Tom Anderson | e2x Ltd, 1 Norton Folgate, London E1 6DB
(e) tom at e2x.co.uk | (m) +44 (7960) 989794 | (f) +44 (20) 7100 3749
More information about the Mercurial