How can I get mercurial to ignore a particular folder that has a space in its name - mercurial

There are plenty of examples of how to ignore folders in Mercurial but I'm having trouble ignoring a folder that has a space in its name. I want to ignore a folder called Translation Files
I've tried wrapping in it quotes but no success. Anybody know how to do it?

Unless there's something I'm not reading out of your question, the simple approach works best:
glob:Translation Files/
This works for me, I added this directory, added a file, verified that commit/addremove etc. wanted to add it, then redid the operation but added the ignore mask, and the file was ignored.

.hgignore:
syntax: glob
Tranlation Files/

Related

Batch file doesn't work properly unless I'm watching it

I've searched for a solution to my issue, but it's strange and I can't exactly figure out where it's going wrong.
I have a batch file that seems pretty straightforward. In a directory that has two files, it's supposed to delete one, copy the other, then rename it to what the file just deleted was named. Everything seems to work properly except for the renaming. It almost appears that the script runs twice, but I can't find any actual evidence of this. Please see below:
SET filepath="\\server-name\directory with a space\"
SET oldFile=filename.csv
SET curFile=filename_*.csv
REM ===Delete current filename.csv===
IF EXIST %filepath%%oldFile% DEL %filepath%%oldFile%
REM ===Copy all versions of .csv files that begin with filename_ to the Archive folder===
IF EXIST %filepath%%curFile% COPY /y %filepath%%curFile% %filepath%%Archive
REM ===Rename the .csv file beginning with filename_ to filename.csv===
IF EXIST %filepath%%curFile% RENAME %filepath%%curFile% %oldFile%
If I run this manually, it appears to work fine. However, when I let it be called from a Scheduled Task, it appears to run twice... that is, it deletes the filename.csv, copies the filename_*.csv to the correct place, but then seems to delete the second file rather than rename it.
As I said, I'm really unclear on what is actually being done. I've tried logging the results in an output file, but there isn't anything helpful within.
Can anyone see anything I'm missing?
Thanks in advance.
Examine
IF EXIST %filepath%%curFile% COPY /y %filepath%%curFile% %filepath%%Archive
Note that archive appears to have a leading % - is this meant to be a directory "archive" or is archive set to something you're not showing us and therefore it should be ...%filepath%%Archive%
The consequence of the (?missing/stray %) is that the file would be copied to a file named archive or to a directory named archive if that directory already exists.
Personally, I'd use
SET "filepath=\\server-name\directory with a space"
where the quotes delimit the string to be assigned (so no stray trailing spaces are assigned to the variable) and then construct the source/destination names using "%var1%\%var2%" which ensures no double-" appear and the directory is obvious (but this is a matter of style).
It is a best practice to quote paths. In this case, where a space is involved, it is a requirement. It is easier to omit quoting from the varaiable definition and provide them where needed when the variable is used.
SET filepath=\\server-name\sharename\directory with a space\
IF EXIST "%filepath%%oldFile%" DEL "%filepath%%oldFile%"
In my experience, it is best to leave the directory at the end of a path without the trailing backslash. Also, a UNC path should have a sharename.
SET "filepath=\\server-name\sharename\directory with a space"
IF EXIST "%filepath%\%oldFile%" (DEL "%filepath%\%oldFile%")
I've finally discovered the solution to this. Turns out there was a copy of the task running on an older server that our new environment had been migrated from. It was running at the exact same time as the one on the new server, which is why it would run perfectly fine any way I tried to run it before or after the time the task was set to run. Disabling the old version of the task resolved the issue.
Thank you to those who provided feedback and suggestions on my commands!

.hgignore - ignore some folders except one specific folder

__
Hello everybody,
My hgignore file contains following lines:
syntax:regexp
^data/dyn/.*
^data/config/.*
^data/temp/.*
^data/mediapool
^\.project
^\.buildpath
^\.settings/.*
^nbproject/.*
/\.git/
\.hg_archival.txt
syntax:glob
*.sublime-project
*.sublime-workspace
sftp-config.json
BUT, i want to "unignore" the folder data/dyn/xxx/yyy with it's files inside.
How can i solve my problem?
Many thanks!
Mercurial .hgignore files are a blacklist only. The only way to whitelist something is to blacklist the "outer" group and then hg add what you want not-ignore. Adding something with hg add always trumps ignoring it in .hgignore.
That works great for files, but not so great for directories since you can't add directories. You can add all the files in them, but any new files that land there will be ignored until you add them.
You can try using the "zero-length negative look-ahead" feature of regular expressions, but honestly it's easier to just add the files in that directory.

How do I change the template .hgignore used for new repositories?

When I create a new repository, I can ask TortoiseHG to give me a .hgignore file. Is there a way that I can customise what that file will look like, rather than having to go and get one manually from somewhere every time?
It's an old question, put still popped up as the first result on google, so here is an update:
In the TortoiseHg settings under the tab TortoiseHg users can specify the path of a Repo Skeleton. You can put your predefined .hgignore there, and it will be automatically copied during hg init.
See also:
#3569 Allow user-defined default .hgignore file when creating a new repository
TortoiseHG Docs
Like Tim already said in his comment, apparently it's not possible to do this.
Take a look at the following issue from TortoiseHG's bug tracker:
#966 Include some reasonable defaults in .hgignore on repo creation
Quotes from this link, both by Steve Borho (THG project lead):
This topic comes up on the Mercurial mailing list once a year or so and Matt always shoots it down. There is already support for user level ignore files; one could add these globs to a global file and be done with it.
and:
If a user has files or directories that they always want to ignore, they can add those to a global ignore file without having to introduce any new behaviors in THG.
So putting the things you always want ignored in a user-global ignore file seems to be the only option (even though it's not exactly what you're asking for):
Would like to create some defaults for my .hgignore files in TortoiseHG/Mercurial
(the question that I posted in my comment above)
Global hgignore usage

how to ignore dir-prop-base in .svn folder?

I've read several posts here about ignoring files in Mercurial but I'm stumped on this one.
I have a couple of .svn files in my repository (I'm using hg for local commits, then pushing to svn). The files are:
Apps\.svn\dir-prop-base
Apps\.svn\entries
I've got several ignore entries in my .hgignore but none of them seem to be covering these two files.
syntax: glob
.svn/*
**/.svn/**.*
syntax: regexp
\.svn\\*
I'm trying a couple of things to see which sticks there. To me, it looks like those files should be ignored twice. The strange thing is that Apps\.svn\all-wcprops is being ignored. Clearly I'm missing something. I'm checking whether the files are ignored by opening a new status window using TortoiseHg. I can't detect any difference between that and hg status.
Oben pointed me in the right direction. He declined making an answer, so here it is:
The files that you want to ignore can't be in an Add state when you are editing the ignore file (since Add takes precedence over Ignore apparently). So my solution was to do hg revert, edit the ignore file, then use hg status [directory] -i to see which files in the target directory would be ignored. Repeat until all the correct files are ignored, then use hg add.
syntax: regexp
^.*\.svn/dir-prop-base$
works for me.
The following simple .hgignore works fine for me to ignore all .svn folders (on Windows, hg 1.7):
syntax: glob
.svn

.hgignore whole directory tree excepting one specific file

Can anyone tell me the .hgignore pattern to track one specific file in a directory and to ignore everything else?
I have a "media" directory which contains a "default.png", for obvious purposes, and the rest of the directory will hold user media. We want hg to ignore everything in the media directory excepting the default file.
Try:
syntax: regex
^media/.*
or (leave it in the default glob and do)
media/**
and then manually hg add media/default.png.
In mercurial (unlike in CVS) you can add files that match your ignore patterns and they work fine. So ignore broadly and hg add what you want tracked.
syntax: regex
^media/(?!default.png$)
almost the same as John Mee's but matches to the end of the line, instead of anything that starts with default.png.
if you wanted to allow any .c file but nothing else, you could use:
^media/(?!.+\.c$)
Summing it up as a BKM (Best Known Method)
Either hgignore everything, and then hg add back the few files you want to track.
Or use a pattern such as
syntax: regex
^path/(?!files-that-you-want-not-to-ignore$)
(I just wanted to see the full answer in one place.)
Never mind this seems to work...
syntax: regex
^media/(?!default.png)