Revert local changes in fossil - version-control

How do I clean/revert/undo local, un-commited changes in a single source file with Fossil?
The clean command looks to me like it should do the trick, but no, the local changes are still there. I am looking for the same effect as "git checkout filename.c" would have.

fossil revert <filename>
.
>fossil help revert
Usage: fossil revert ?-r REVISION? ?FILE ...?
Revert to the current repository version of FILE, or to
the version associated with baseline REVISION if the -r flag
appears.
If FILE was part of a rename operation, both the original file
and the renamed file are reverted.
Revert all files if no file name is provided.
If a file is reverted accidently, it can be restored using
the "fossil undo" command.
Options:
-r REVISION revert given FILE(s) back to given REVISION
See also: redo, undo, update

Related

Exclude File from Uncommitted Changes

I have a config.debug.json file that I update frequently based on which server I'm pointing to. Is there anyway to exclude this file from Uncommitted changes? In sourcetree and vs code it shows up as an uncommitted change, but I never want to commit the change.
Try adding config.debug.json to your .gitignore. This will exclude the file from source control, which should prevent it from showing up in the changes section for vscode and sourcetree
Update
If you've already added the file at some, you first need to untrack it by running:
git rm --cached config.debug.json
This will leave the file on your system but stop tracking it

How to view all current uncommmited changes to a specific file in hg?

How to look at all uncommited changes to a file in hg? If we use TortoiseHG it's clear, but what about command line?
You probably want some combination of
hg status -mad to list all Modified, Added and Deleted files,
and hg diff <filename> to show the changes in a particular file.

How to keep track with some reverted old file version in fossil?

There is a repository repository repo.fossil
bug.c modified many times (eg. revision 10a3->34bd->152c).
There are many files changes in 10a3, 34bd and 152c revision.
Bug will fixed if combine 152c revision with bug.c at 34bd.
How to keep such version, I use following command but failed?
fossil open ~/fs/repo.fossil # contains many files
fossil update -r 34bd bug.c
fossil ci <-- why there is no change?
This seems to be two questions packed into one
1 Why is there no change.
There is no change because you have not made any changes. You have have opened ( copied into the working directory ) the file that belong to "old_revision". You have not changed anything It remains identical to the file for the version as stored in the repository.
2 How to revert a particular file
fossil open ~/fs/repo # contains many files
fossil revert-r <old_revision> one_file
fossil ci
Notice that I am using the revert command, NOT the update command
Here are the details of the revert command http://www.fossil-scm.org/fossil/help?cmd=revert

Replace local file by remote file

How do I replace a local file by its latest version in the repository?
Is there also a way of replacing all local files which are conflicting with the corresponding files from the repository?
Both hg update -C and hg revert will do what you are looking for - replace a locally modified file with the clean version in the repository. Personally I prefer hg revert but hg up -C will also do the job
hg revert
Some further details from the help for hg revert
With no revision specified, revert the specified files or directories to
the contents they had in the parent of the working directory. This
restores the contents of files to an unmodified state and unschedules
adds, removes, copies, and renames. If the working directory has two
parents, you must explicitly specify a revision.
Using the -r/--rev or -d/--date options, revert the given files or
directories to their states as of a specific revision. Because revert does
not change the working directory parents, this will cause these files to
appear modified. This can be helpful to "back out" some or all of an
earlier change. See "hg backout" for a related method.
Modified files are saved with a .orig suffix before reverting. To disable
these backups, use --no-backup.
Hope that helps
Chris
svn update ?
Or delete your folder, and svn checkout...
Or try the option --force.

What is the difference between hg forget and hg remove?

I want mercurial to remove several files from the current state of the repository. However, I want the files to exist in prior history.
How do forget and remove differ, and can they do what I want?
'hg forget' is just shorthand for 'hg remove -Af'. From the 'hg remove' help:
...and -Af can be used to remove files
from the next revision without
deleting them from the working
directory.
Bottom line: 'remove' deletes the file from your working copy on disk (unless you uses -Af) and 'forget' doesn't.
The best way to put is that hg forget is identical to hg remove except that it leaves the files behind in your working copy. The files are left behind as untracked files and can now optionally be ignored with a pattern in .hgignore.
In other words, I cannot tell if you used hg forget or hg remove when I pull from you. A file that you ran hg forget on will be deleted when I update to that changeset — just as if you had used hg remove instead.
From the documentation, you can apparently use either command to keep the file in the project history. Looks like you want remove, since it also deletes the file from the working directory.
From the Mercurial book at http://hgbook.red-bean.com/read/:
Removing a file does not affect its
history. It is important to
understand that removing a file has
only two effects. It removes the
current version of the file from the
working directory. It stops Mercurial
from tracking changes to the file,
from the time of the next commit.
Removing a file does not in any way
alter the history of the file.
The man page hg(1) says this about forget:
Mark the specified files so they will
no longer be tracked after the next
commit. This only removes files from
the current branch, not from the
entire project history, and it does
not delete them from the working
directory.
And this about remove:
Schedule the indicated files for
removal from the repository. This
only removes files from the current
branch, not from the entire project
history.
If you use "hg remove b" against a file with "A" status, which means it has been added but not commited, Mercurial will respond:
not removing b: file has been marked for add (use forget to undo)
This response is a very clear explication of the difference between remove and forget.
My understanding is that "hg forget" is for undoing an added but not committed file so that it is not tracked by version control; while "hg remove" is for taking out a committed file from version control.
This thread has a example for using hg remove against files of 7 different types of status.
A file can be tracked or not, you use hg add to track a file and
hg remove or hg forget to un-track it. Using hg remove without
flags will both delete the file and un-track it, hg forget will
simply un-track it without deleting it.