Bazaar: how put files from different locations in one repository? - emacs

I'm new to bazaar and would like to give it a try by storing my Emacs configuration files in one repository.
These files consist of a .emacs file in my home directory (on unixish systems) and a couple of Emacs Lisp source files in /usr/local/share/emacs/site-lisp
I'd really like to have one repo because some changes in my .emacs file go together with changes in other files.
What I couldn't work out from the manual is how to get these files together. The "bzr init" takes recursively all files from the current directory; for my situation this would mean to create the repo in the root directory...
What do you recommend? Try working with symbolic links? Is there a way to associate a revision from one repo to one from another repo, so that easier solution of having two separate repos could be a way to go?
There is an additional challenge: on a Windows machine, these Emacs files sit on completely different locations. How to treat that?
I have some perforce experience: there the solution is easy: you can just define a view that maps repo files to an arbitrary location on your hard disk.

This is more of a bzr question, but I can give you an Emacs answer.
The "new" way to structure your Emacs setup is to have a directory ~/.emacs.d and put everything under there. Rename your .emacs file to ~/.emacs.d/init.el and it will be found automatically. Next, create a ~/.emacs.d/lisp directory (actually you can name the dir whatever you want, but lisp is pretty standard), and move or copy the files the /usr/local/share/emacs/site-lisp files to that dir (and byte-compile them if you want to). Finally, put (add-to-list 'load-path "~/.emacs.d/lisp") at the top of your ~/.emacs/init.el file.
Now everything is under one tree, so bzr init it as usual. This setup will work on Windows also since Emacs understands ~ on there as well.

Related

Projectile - use .projectile instead of .gitignore for excluding file from projectile-find-file

I'm using projectile on emacs for managing project files. There are some files
which I've put in my .gitignore as they contain my local configuration settings
dev/resources/local.edn
.dir-locals.el etc.
The problem with this is when I use projectile-find-file, these files are not listed since
they are in .gitignore file. I do not want projectile to get the list of files to ignore from .gitignore and instead only rely on .projectile for that.
Keeping files out of git repository should not be confused with listing project files using projectile. They serve different purpose - .gitignore for git and .projectile to exclude from listing files using projectile.
Is there a way to do this ? I couldn't find any variables to tweak.
Thanks
I've found a possible solution - setting indexing method to native
(setq projectile-indexing-method 'native)
Based on Projectile Documentation you can change projectile-git-command variable.
I am using project detection based on git repository with no .projectile file.
For me to show also ignored files, this change works fine:
(setq projectile-git-command "git ls-files -zco")
It's possible to use little bit faster 'hybrid' method

Version control of sparse files

I need to put under version control sparse files.
I mean files like:
/etc/hosts
/opt/Sybase/config.ini
/usr/local/httpd/conf/httpd.conf
They are sparse in the sense that they are not in one single folder.
Git usually works in a single folder. Other version control tools do the same.
I need to put these files under version control because I need to track the entire configuration of a server.
Fossil allow to add single file and do not track the whole dir of it
Somehow tricky, but
Create new repo (or repos, if you have more than 1 LT in next step)
Define common base dir(s) for your files - it will be place of "permanent" Local Tree (common dir is important, because Fossil doesn't allow add files to repooutside open tree)
Open repo in this CommonBase
Add files
Commit
After it you can open repo in any other location into "working" Local Tree, get all files in it, edit-commit, but don't forget "update" after commits your "permanent" Local Tree
HTH

How can I add a directory tree to my github repo?

I've been working on a project that's fairly far a long now and I decided it's time to use some sort of version control etc. I decided to go with github. Before I get in too deep let me state explicitly that I am new to github.
My project resides in a directory that contains myriad subdirectories and files of all different kinds. I'd like to take my project directory as is (structure and all) and put it in my github repo.
I followed the tutorials on github's webpage, created the repo, and manually added some files. Obviously I don't want to manually add every file (there are several hundred). I'd like to know how I can add the root directory or for that matter any parent directory and all files/folders in said said directory. In other words I'm looking for a recursive add.
I read on this SO page (How to create folder in github repository?) that you can just use
git add directory/
That works fine for me when I'm dealing with the lowest level directory, but when I try the same command on a directory with subdirectories my terminal just sits there and I have to ctrl-c. I can't tell if it's just taking a long time (as I mentioned there are lots of files) or if this is just the wrong way to add a directory with subdirectories.
Apologies in advance if this is a super ignorant question -- I have looked at a lot of blogs/posts/etc and I cannot find a solution that seems to work.
Use the Current Working Directory
Assuming you're on Linux or OS X, from the command line you would do the following:
git add .
from the root of your repository tree. That will add all non-ignored files, including non-empty directories, into the repository.
From the root directory (the one with all the subdirectories), use git add -A.
If you have a ton of subdirectories and files, it may take a long while, so just let it sit there until it's done.

How to create a backup of .emacs every time Emacs starts

What is a good way to take a backup of my .emacs file each time Emacs starts? I want to keep multiple copies for when I need to get back to a previous version.
My first thought is to issue a shell command from within the .emacs file:
cp ~/.emacs ~/Backups/.emacs-yyyymmdd:hhmmss
... appending the current timestamp to get a unique filename. But as far as I know you can't issue shell commands from the .emacs file.
I've read about BackupEachSave and ForceBackups. Does anyone have experience with these? Do they work well?
EDIT:
Event_jr's answer about version control is a possible solution. I prefer using a shell command, though, because version control applies to all files and I don't need multiple backups of every single file.
I looked at the 'version control' variable. It's described in the Emacs manual:
Emacs can also make numbered backup files. Numbered backup file names contain ‘.~’, the >number, and another ‘~’ after the original file name. Thus, the backup files of eval.c >would
be called eval.c.~1~, eval.c.~2~, and so on, all the way through names like eval.c.~259~ >and beyond.
The variable version-control determines whether to make single backup files or multiple >numbered backup files.
So, I added this to my .emacs:
; Version control and backups:
(setq version-control t)
Works as advertised.
This section tells how to control backups on a per-file basis. I haven't explored it.
The question you should really be asking is how do I never lose a revision of any file I edit in Emacs, including ~/.emacs?
The answer is versioned backups. The variable that controls this feature is called version-control, which is kind of confusing, as it relates completely to backups, not VCS.
This is also a feature of Emacs; there is no additional package to install. Almost everything I work on is in VCS, but I still find it extremely useful to have all revisions of my work easily accessible. Storage is so cheap, so why not?
EDIT: describe the save-buffer aspect of backup every file.
You should read the documentation (C-h k C-x C-s) of save-buffer to understand the nuances, but basically passing it C-u C-u will force it to backup after every save. I actaully remap it to my own function
(defun le::save-buffer-force-backup (arg)
"save buffer, always with a 2 \\[universal-argument]'s
see `save-buffer'
With ARG, don't force backup.
"
(interactive "P")
(if (consp arg)
(save-buffer)
(save-buffer 16)))
(global-set-key [remap save-buffer] 'le::save-buffer-force-backup)
as far as I know you can't issue shell commands from the .emacs file.
Sure you can:
(shell-command "cp ~/.emacs ~/.emacs-`date +%Y%m%d:%H%M`")
A better solution is to use a version control system like git. It will be easier if you create an ~/.emacs.d directory and put your elisp files in there:
mkdir ~/.emacs.d
mv .emacs ~/.emacs.d/init.el
git init
git add init.el
git commit -m 'initial checkin'
Now each time you modify the init.el file you can use the following to save the changes:
git commit -a -m 'descriptive commit message here'
You can then add a function to after-save-hook, such as something like this gist to automatically add, commit, and push when files change. After the push you then have a local copy and a remote copy (e.g. on github).
Emacs also has integration with git via a package called magit.
You'll be greatly rewarded in the long run if you spend the time now to learn how to use a DVCS (Distributed Version Control System) and you'll find that magit makes it very convenient to use git.
You set backup properties as configuration; you can refer here.

How to massively mark files as moved with Bazaar?

I have moved 3 files from the top folder working copy under bazaar into a new directory Project.
Bazaar show me this screen.
Now, I want to mark every file as moved. It is possible to do this one file by one file - by selecting the missing one, the new one, and clicking mark as moved.
BUT it is not possible to massively do this for all files.
The screens capture are just an example, in my real project, I have ~40 files.
Any idea to do this for all files ?
EDIT with the accepted answer :
in TBZR > Run command and use : bzr mv --auto
You could try using bzr mv --auto from the command-line to auto-detect moved files. This works best if you haven't also changed the contents of the files.
You could also avoid this situation in the future by using bzr mv <src> <dest> to move the files, which also notifies Bazaar that they have moved.