mercurial .hgignore - won't ignore files - file

I'm trying to ignore a file in my project with .hgignore, and just can't figure it out. The file is located in app/views/patterns/_changes.erb (relative to the root of the project, where .hgignore is), and nothing I try seem to work:
#.hgignore
syntax: glob
app/views/patterns/_changes.erb
*changes.erb
public/files/* # this works
I read the .hgignore doesn't distinguish between folders and files, but can't really make it happen. Any clue? thanks.

If you just put:
_changes.erb
as an entry, that should work. It will ignore that file name, regardless of location. Note that if the file is already in the repository, it won't REMOVE it... it just won't prompt you to add it next time it sees a file with that name.
As a side note, if you want to remove a file from version control, use the command:
hg forget _changes.erb
(Note that this will remove the file from the current revision onwards. The file will always remain in past changesets -- i.e. it's not a total purge of the file.)

Related

Update file across multiple folder locations?

I need something that can copy a specified file any and everywhere on my drive (or computer) where that file already exists; i.e. update a file. I tried to search this site, in case I'm not the first, and found this:
CMD command line: copy file to multiple locations at the same time
But not quite the same.
Example:
Say I have a file called CurrentList.txt, and I have copies of it all over my hard drive.  But then I change it and I want all the copies to update.  So I want to copy the newer one over all the others.  It could 'copy if newer', but generally I know it's newer, so it could also just find every instance and copy over it.
I was originally going to use some kind of .bat file that would have to iterate over every folder seeking the file in question, but my batch file programming is limited/rusty.  Then I looked to see if xcopy could do it, but I don't think so...
For how I will use it most, I generally know where those files are going to be, so it actually might be as good or better if I could specify it to (using example), "copy CurrentList.txt, overwriting all other copies wherever found in the C:\Lists folder and all subfolders".
I would really like to be able to have it in a context menu, so I could (from a file explorer) right click on a file or selected files and choose the option to distribute it.
Thanks in advance for any ideas.
Use the "replace" command...
replace CurrentList.txt C:\Lists /s

.gitignore everything but .c and .h recursively

I would like to ignore everything in a certain folder and its subfolders, except for .c and .h files.
Yet locally, i need other files too. Do i have to have these files, which should not be tracked, in the git-repo before or after i add the .gitignore?
And how do i do this?:
#ignore all
*
#but:
!source/**/*.c
!source/**/*.h
This is my current solution, but it does not work. But i think this also relates to the point in time, where i have to add the files, that should be ignored, but need to be there locally?
EDIT:
The problem is, i got a copy of a project, that does all kinds of makefile magic and other things, i do not even know what kind of file-types and subfolders there are (i will only work in one folder of the massive project, so i don't think, that the gitignore needs to be so exclusive) ... and i can't just commit everything, because the "lib" has to be installed i think, so everybody needs to do this on his own ...
Ignoring * means ignore everything including top-level directories. After that git doesn't even look into subdirectories. To fix that unignore directories. Your entire .gitignore should look like this:
# Ignore all
*
# Unignore directories
!*/
# Unignore source code files
!source/**/*.c
!source/**/*.h
Another approach is to ignore everything but force-add necessary files with git add -f.
The problem is that the pattern
*
excludes all directories, too. According to the gitignore documentation,
It is not possible to re-include a file if a parent directory of that file is excluded.
To make this work, then, you'll need to use make sure that directories are not ignored. The gitignore pattern format does not provide a way to distinguish between directories and regular files, so you'll need to do that manually. One possibility would be to put a .gitignore file in each that directory that reincludes all its subdirectories, but it would be easier to just reinclude all directories. These can be matched (exclusively) with a pattern that ends with a '/':
!source/**/
Also, you are right when you say
But i think this also relates to the point in time, where i have to add the files, that should be ignored
in the sense that gitignore does not apply to files that are already tracked.

Unzip single zipped file into parts?

I have a single file that is zipped. I want to unzip this, but I don't have enough space on the computer. Is there a way to unzip it in parts? For example, first I'd want to unzip the first quarter (or x GB), then stop, look at the resulting file, delete it, and then unzip the next part. The parts do not have to fit together perfectly to form a new file.
I'm using Windows.
EDIT
The original pre-zipped file is only 1 file. This single file was zipped, and now I need to unzip it, but in parts.
Assuming it's a text file:
I'm not sure how to do this natively in Windows, but this is very easy to do under unix. You can download Cygwin which will give you access to the unix tools that can do this.
Then you can do:
/cygdrive/c/yourDisk/
$ zcat yourFile.zip | sed -n 1,1000p > file1.txt
This will give you the first thousand lines in a file in c:\yourDisk\file1.txt
Use your Windows Explorer to explore the zip file... it allows you to open subdirectories (folders) and for you to navigate anywhere within the zip as if it was a normal folder.
When you find something you want to view, either double click it, or drag it to another location in your drive. If you drag it, you will end up copying whatever you are dragging to a new location (say, your temporary work area). Note, copying is not the same as moving as the original compressed version will continue to exist within the zipped folder.
When you have finished with whatever you dragged out, you can delete it (the copy) and return to your original and pull out more data/files for inspection.
Look at my attached image... notice the directory path where I have the red arrow. It says I opened a file called myzipfile.zip (I did a right mouse button over the file and clicked Open With... and selected Windows Explorer).

Issues Using Wildcard in Batch-script to Copy a Variable File Name

My Process:
For version control, all my files are named with the format "fileName_v#.#"
I keep a folder called 'Live Environment', and as a new version is rolled out, the current file (ex. fileName_v1.0) is removed from 'Live Environment' folder, and the new version (ex. fileName_v2.0) is moved into 'Live Environment'.
My batch script is used to keep all users on the most current version. It works perfect, except with every version I need to go back and update the hard-coded file name in my script to the new file name.
I would like to use a wildcard to search this folder for whatever file is in the 'Live Environment' folder, and then perform the copy function.
Current Code:
::Sets the default install location as the user's desktop
set "DestinationFolder=%userprofile%\desktop"
::Copies and saves file to the user's Desktop
copy /-y "\\myUNCPath\Live Environment\fileName_v*.accdb" "%DestinationFolder%\copiedFile.accdb"
My Issue:
I've hardcoded the "fileName_v#.#.accdb" in for each version so far, and the code executes perfectly. The second I remove the hardcoded file version and add the "*" wildcard, the code errors. The copy function still runs, but simply creates an empty .accdb file on the users desktop, which when used gives the error:
"Unrecognized database format"
At this point I'm overthinking this and making it harder than it needs to be. A set of fresh eyes on the issue would be helpful. Any help would be greatly appreciated!
#aschipfl - that worked! Thanks for the comment.
Simply adding "/b" to the copy line fixed the issue.
copy /-y /b
(For more details see the aschipfl's comment posted below the question).

How to delete files with exclamation marks! using emacs' delete-file

I'm trying to make emacs' delete-file function delete files with exclamation marks in their names.
The particular use case is that I have set emacs to save all backup files in a single directory and to delete old backup files. However, when all backup files are placed in one directory, the directory separator / is replaced with !.
When delete-file is called on a file with an exclamation mark in its name, it returns zero and the file is not deleted. It doesn't signal any error. Normally, delete-file returns nil. Anyway, emacs' backup system uses delete-file for deletion, and I'd rather not redefine the entire function just to change a single line.
I've tried backslashing the exclamation marks and shell-quoting the filename string, and neither has worked. I found out that something in my config is causing this, but I haven't figured out what yet. I have tracked the source of the problem to my custom system-move-file-to-trash function, which I now have to debug.
So, how can I make this work?
Emacs version:
GNU Emacs 23.1.50.1
emacs-snapshot:
Installed: 1:20090730-1~jaunty1
M-x delete-file
Then just enter the name of the file, don't escape anything, just the name,
!home!blah!filename
and it just works. And the same goes for the lisp invocation,
(delete-file "!home!blah!filename")
I found the answer. My custom system-move-file-to-trash function, which delete-file will automatically use, inappropriately called shell-quote-argument on the file name. Apparently arguments to a command run using call-process do not need to be shell-quoted.

Resources