sapling: How to change the commit editor - version-control

Meta's new Sapling SCM looks interesting, but can you change the commit editor, to e.g. vscode?
I can't find anything editor related in sl config.

Admittedly, config options need to be documented on the Sapling website. Until then, looking at historical Mercurial documentation is a good proxy.
For example, in this case, the config you want to set is ui.editor, just like in Mercurial. Though note that in the specific case of VS Code, you likely want to include the --wait flag, so I would set it as follows:
sl config --user ui.editor "/usr/local/bin/code --wait"

Related

Can you set the default save location for the git:clone command in vs code

I have not been able to find a configuration setting in vs code for the default git:clone command. Is there a config setting that allows me to set the default save location for the git:clone command in vs code?
There is no way to do that, yet. There is an open issue, which received a PR back in January to accomplish this, but since VSCode updated the internals to support more SCM (other than Git), they asked to the contributor to re-send the PR in the new git-extension.
So, it will probably be available in newer releases.

Shunning a directory with Fossil

Fossil has a shunning mechanism, which I believe may be used to keep certain files from version control.
I have a directory named R, which I wish to control except for a sub-directory inside of it, named library, which I wish to exclude. How can I "shun" the sub-directory?
My usual workflow is something like this:
fossil new ../fossils/R.fsl
fossil open ../fossils/R.fsl
fossil add .
fossil ci -m "a commit"
fossil close R.fsl
The help page is here, but I still couldn't figure it out:
http://www.fossil-scm.org/index.html/doc/trunk/www/shunning.wiki
If I read your question correctly, you're looking for a way to keep specific files out of version control.
In that case, you're probably looking for the ignore-glob setting.
That setting allows you to specify (chunks of) paths that should be left out of the repository.
For example, if you wanted to leave all files in the subdirectory skip, and you also wanted to keep all *.bak files everywhere out of your repo, you could achieve this with the following command:
fossil set ignore-glob "skip/,*.bak"
The fossil set ignore-glob takes a comma-separated list, so this means any file starting with skip/ will be ignored, and all files matching the *.bak glob will be ignored as well.
If you want to test your ignore-glob setting first (it can be a tad tricky to get right, in my experience), you can test it using the extras command. fossil extras will normally show all files present in the working folder (and its subfolders), but are not in the repository. You can override the ignore-glob setting using the --override command-line switch; thereby allowing you to test it. If it works OK, you can save that ignore-glob with the settings command, as described above.
Do NOT use shun for this!
As the documentation clearly says, shunning is not recommended. It should only be used with great care, and only if you understand exactly what it does, because you can seriously fuck up your repository if you use it the wrong way.
Your question makes it clear that you don't understand its use, so I strongly suggest forgetting about shun until you're more familiar with the working of Fossil.
Do not use shunning. Use this:
cd R
fossil settings ignore-glob "library/*"
fossil settings ignore-glob
fossil ls
fossil extra
Here is a good guide for start https://www.fossil-scm.org/xfer/doc/tip/www/quickstart.wiki

Egit : Prevent a commit if not formatted correctly

The company I work for gave me the project of moving their java project from CVS to Git.
For several reasons, they don't want to use another tool than Eclipse. So we're stuck with EGit.
I know it is possible to configure Eclipse to format code. But it seems like there is nothing that would prevent someone to use his own way of formatting the code.
So my question is, is it possible to refuse a commit with EGit if the code is not formatted correctly ? The reason behind this question is that we want to avoid conflicts due to the code format, which was a really big problem in CVS.
Thank you
I recommend setting the formatter and a save action to format code as a project-specific configuration. Then tracking the .settings directory in Git.
Because it's configured in the project and in version control, developers won't have to configure Eclipse themselves, it's automatic.
We have done this with several projects and if you do it from the start, you will never have any ill-formatted code or discussions about it.
If a developer is really reluctant and even goes as far as unchecking the project-specific formatter and using another one, maybe you should have a talk.
(By the way, a recommended option in the formatter is Never join already wrapped lines, because sometimes the formatter will do weird wrapping. This option makes it possible to have control over wrapping.)
An alternative to checking the code during the commit is a scenario where gerrit is used as review system. The developers would commit their code to gerrit instead of directly to the git repository. Gerrit can then trigger a build job on a Jenkins/Hudson server and that build job can run CheckStyle or any other format checking tool you prefer.
On successful check Jenkins could then also verify the change and merge it into the git repository (most projects prefer Jenkins to only verify the correctness of the code, and a human still needs to review the code afterwards). Commits failing the check would remain in gerrit (and a mail would go to the developer).
The advantage of this approach is that you can do much more than only style checks for each commit, especially run unit tests, static code analysis and code coverage. The major drawback is that you have to set up some more tools than just a git hook.
If you know a way to determine if the code is formatted correctly you can implement this in the hook pre-commit
This hook should be placed in .git/hooks
git comes with a sample, called pre-commit.sample, it either in the hooks directory already or you can find it in the /usr/share/git-core/templates/hooks/ (On Ubuntu).

Half-ignored files in VCS - is this supported?

I am using Eclipse and Subversion for Java development, and I find myself wishing for a feature in version control systems (one that is not available in SVN, to the best of my knowledge).
I would like my project settings files to be half-ignored. To be more precise, I want them to be available in VCS, I want merge to occur when someone checks in changes, but. I want my own changes ignored unless I very explicitly tell the system to take them.
This would allow me to have my local paths (and other settings) in my local configuration w/o screwing up other people's configuration. But, when I have a substantial change, I can still check it in (very very carefully, may be temporarily removing my other local changes) and have it delivered to other people.
Now, the actual question: is there any VCS that supports this feature? Or may be I am missing something in SVN? How do other people solve this problem in Eclipse?
Yes, Git support that feature through filter driver (a clean script can run upon commit, allowing you to clean the content from any of your changes if you want).
But another way would be to never version that setting file, and only version:
a template file
a value file
a script able to replace variables in the template files with the values from the value file, in order to generate the actual (and "private", as in "not versioned") setting file.
That way, you can modifying it at your heart's content without ever committing your changes.
.gitignore for git, .hgignore for mercurial and file paths and patterns can be added that will not be committed. There similar in SVN but i never worked out how to use it myself but my sysop did set it up form me.
git supports this with
git update-index --assume-unchanged <file>
and the complementary
git update-index --no-assume-unchanged <file>
See http://blog.pagebakers.nl/2009/01/29/git-ignoring-changes-in-tracked-files and http://kernel.org/pub/software/scm/git/docs/git-update-index.html#_options for more details.

Mercurial: How to ignore changes to a tracked file

I have a file with database settings in my project which I have set to some defaults. The file is tracked by Mercurial and checked in. Since this file will be edited with different values various developer machines, is there a way I can tell Mercurial to ignore new changes to this file?
I tried adding the file to the .hgignore file, but since the file is tracked it isn't ignored. This is alright and good in other situations, but I am wondering if there is something I can do here?
Using a file template is definitely the best solution.
For example, if you have a database.ini file, commit a database.ini.template file and ignore database.ini in .hgignore
If you always want to ignore the file, you can add the -X option as a default for commit to your .hg/hgrc configuration file:
[defaults]
commit = -X program.conf
We wrote an extension for this called exclude. It will automatically add the -X options on the commands that support them -- so hg status and hg commit wont see the modified file. It works by reading a .hgexclude file from the root of your repository, just like the .hgignore file. You add the files that you want to exclude there:
syntax: glob
db.conf
The extension works quite well, but there is a known situation where it fails: merges and the commit that follows a merge (this is documented on the wiki). It would need to be improved so that it would save the modifications away to a temporary file and then restore them afterwards. Please get in contact if you need this feature.
There is no truly automated process, but you can try (as in this SO question) the -X option on hg commit:
% hg stat
M myfile
% hg commit -X 'myfile'
(other solutions might involve shelve or hq)
However, this is not the "right" solution. I would rather recommend versioning:
a file template
a script able to generate the final file (that you modify but can ignore altogether)
If you are using TortoiseHG, open the Settings for the repo, go to the Commit section (2nd icon down on the left) & add the file name(s) to the Auto Exclude list on the right (~ 3rd from the bottom in the list).
From https://tortoisehg.readthedocs.io/en/latest/settings.html#commit
Typically you would check in a reference copy of the file and track it then have the developers make a copy of that for local development, you wouldn't really want developers editing the source controlled file for their own environments.
If your configuration system supports it, it's even easier if you can use an override file that simply override values in the reference copy (e.g. the database connection string). That way devs only have to keep a very minimal local set of override values.
If the file is already being tracked, you can issue the Forget command to the file. If you're using TortoiseHg just right click the file during commit and select Forget. The file must also be already in the ignore list.
I had the same problem as yours, I file keeps on appearing on every commit even-though its already in the ignore list. I tried the Forget command and it did the trick.
You can try hg forget.
For more details, see the official manual about the same command.
It worked for me.
I think, something like this is closer to a correct answer to the original question Mercurial: How to ignore changes to a tracked file, rather than the others suggesting a template, etc.