I have the following section in my ~/.hgrc file. Other settings there work perfectly well.
However this:
[committemplate]
changeset = {desc}\n\n
HG: Enter yo commit message. Lines beginning with 'HG:' are removed.
HG: {extramsg}
HG: --
HG: user: {author}\n{ifeq(p2rev, "-1", "",
"HG: branch merge\n")
}HG: branch '{branch}'\n{if(activebookmark,
"HG: bookmark '{activebookmark}'\n") }{subrepos %
"HG: subrepo {subrepo}\n" }{file_adds %
"HG: added {file}\n" }{file_mods %
"HG: changed {file}\n" }{file_dels %
"HG: removed {file}\n" }{if(files, "",
"HG: no files changed\n")}
Which I copied from help page about hgrc, and added the yo, to see if it worked. It didn't. I'm using mercurial 3.5, downloaded and installed today from https://www.mercurial-scm.org/
Related
Background: Mercurial Topics
Mercurial has a nice feature call topics as part of the evolve extension. These act as temporary lightweight local branches, and are an integral part of the Heptapod workflow, ensuring nice interactions with Git (via hg-git) for example. They are enabled by include the following in your ~/.hgrc file (or per-repo in .hg/hgrc):
# ~/.hgrc
...
[extensions]
evolve =
topics =
As these are designed for local work, when you push, the topics are not pushed to the server (but become temporary branches in git with the Heptapod workflow).
Question
How can I clone a repo locally to get the topics in my clone?
Part of the answer is to set the source repo to non-publishing: (One should probably do this in the cloned repo to after cloning).
# source_repo/.hg/hgrc
[phases]
publish = false
This keeps the draft phase of the changesets that are part of the topics.
Update: With python==3.9.7, mercurial==6.0.1, and hg-evolve==10.4.1 or higher, this seems to be sufficient. As #Craig points out in the comments, the original issue might have been because I was making the first commit a topic, but this is no longer an issue.
MWE (Old... This seems to work now.)
mkdir a
cd a
touch A.txt
hg init
hg add A.txt
hg topic "A"
hg commit -m "Initial commit of A"
cat > .hg/hgrc <<EOF
[phases]
publish = false
EOF
cd ..
hg clone a b
Now in a, there is a topic A and the commit is in the draft phase (shown by orange colour in the output):
$ hg log -v
changeset: 0:62c4... # orange, indicating draft phase
tag: tip
topic: A
user: Michael <...>
date: Wed ...
files: A.txt
description:
Initial commit of A
while in b, everything is the same, including the draft phase, but no topic:
$ hg log -v
changeset: 0:62c4... # orange, indicating draft phase
tag: tip
user: Michael <...>
date: Wed ...
files: A.txt
description:
Initial commit of A
Consider this a workaround, perhaps, but it should work.
If you're just working locally, you don't actually have to clone. You could just make a full copy of the entire working folder (the folder which contains the .hg folder).
Copy it anywhere you want, then when you run Mercurial commands within that path it will behave exactly like it was cloned, except it won't see your original as the default publishing repo, but instead the same one as your original. You can obviously change this in the .hgrc file if you need to.
Depending on your needs, you might want to do an hg up null beforehand to clear all the local working files, which will speed up the copy for a large repo.
It seems like this was a localized bug. Making the source repo publishing seems to be enough.
# source_repo/.hg/hgrc
[phases]
publish = false
I have modified, committed and pushed: fileA, fileB, and fileC. I should only have pushed "fileA" and "fileB", and my pull request has been declined due to this unwanted fileC.
Baring in mind that I have pushed these changes to the remote repository, is there a way for me to fix this locally so my pull request will not include fileC any more?
Simply create a new head with all necessary commits, starting to branch-off at the same parent where your 'wrong' changeset is based on. Then create a new pull-request for that new head you thus created.
Afterwards, you can opt to remove the unwanted head with the changeset(s) which include the unwanted fileC, however that should not be necessary. The strip command will come in handy for that (it's an extension and needs activation in your mercurial config file)
There are 2 ways doing that:
1- Fixing the repository and correcting the history so your incorrect commit is also cleaned from the history:
a- do a git log:
Desphilboy#computer:~/workspace/project(master)$ git log
commit dee4f318231b07ca3dbf213579dbfdeb89f72591
Author: Desphilboy<desphilboy#yahoo.com>
Date: Wed Jul 13 11:04:43 2016 +1000
feat(project): this is a wrong commit pushing FileC
commit e9772baa0abefc3423db2e6b518c71bade74abd9
Author: Somebody else<someoneelse#yahoo.com>
Date: Tue Jul 12 12:05:18 2016 +1000
feat(project): added new API endpoint
....
b- do a reset --soft to the hash code before that wrong commit:
Desphilboy#computer:~/workspace/project(master)$ git reset --soft e9772baa0abefc3423db2e6b518c71bade74abd9
this will revert your commit while keeping all your changes. if you do a git status now you will see all your changes after that commit
c- delete FileC and do another commit and push it again using -f switch
Desphilboy#computer:~/workspace/project(master)$ rm FileC
Desphilboy#computer:~/workspace/project(master)$ git rm FileC
Desphilboy#computer:~/workspace/project(master)$ git add .
Desphilboy#computer:~/workspace/project(master)$ git commit -m "some commit message"
Desphilboy#computer:~/workspace/project(master)$ git push -f
2- Keeping history:
you can simply delete the fileC, remove it from repo, commit and push your local to the master again. this will correct your problem but there will be an additional commit to the master and it will be shown in the history.
I have a Windows file structure like so:
Stable
ProjectA
SharedLibrary
Stable contains the main repo. ProjectA and SharedLibrary are subrepos of Stable. The .hgsub file contains:
ProjectA = ProjectA
SharedLibrary = SharedLibrary
Everything seems to work correctly for the most part. The main repo will recognize the subrepos, and I can do things like hg status -S on the main repo and it will recurse through the subrepos. commit also seems to work correctly.
When I try to clone from Stable (main repo), it fails when attempting to clone the ProjectA subrepo with the following message:
unknown revision 'a855f4fe17c393d5863409f1443fc93b36787fa9'
[command returned code 255 Mon Mar 12 09:25:47 2012]
However, I have verified that the revision is correct and present in the ProjectA subrepo. I can clone each subrepo without any problems.
So far I have tried:
1) Deleting each repository and starting over.
2) Re-installing TortoiseHg/Mercurial.
3) Making sure the revision listed in .hgsubstate is correct and present in each subrepo.
Any way to fix this?
EDIT:
When the clone of the Stable (main) repo fails, it leaves the target directory with a clone of Stable without any subrepos. I can go to the cloned Stable, do an hg update tip, and it will successfully clone the ProjectA subrepo but fail to clone SharedLibrary with the same 'unknown revision' error. I can then run hg update tip again, and it will successfully clone the SharedLibrary subrepo. At that point everything is correct as it would be if the clone had worked correctly in the first place.
EDIT 2: Contents of .hgsubstate:
a855f4fe17c393d5863409f1443fc93b36787fa9 ProjectAd72ef29a5656e5413322c1d20d5830448d558605 SharedLibrary
There is no space between ProjectA and the changeset id for SharedLibrary, but I guess that is just the way Mercurial does it. Both changesets in .hgsubstate are present in the respsective subrepo.
EDIT 3: hg log --debug -r tip from ProjectA subrepo. showing correct changeset is present
Z:\Programming\KSuite\Stable\Client\KClient>hg log --debug -r tip
changeset: 4:a855f4fe17c393d5863409f1443fc93b36787fa9
tag: tip
parent: 3:eb01e88027c893267422fcb67f035ba31d8cdbdc
parent: 2:5b5ffd7f96915ca792507820ccfbee35707148d0
manifest: 4:e90960833c0708ec7f99ccded11c46ca45b46542
user: Casey ******** <*redacted*#.com>
date: Fri Mar 09 18:22:50 2012 -0500
files: .hgignore
files-: KClient.suo
extra: branch=default
description:
Merging changes in Stable to Dev.
I've freshly cloned a Hg repository on Windows XP and hg status reports a lot of (all?) files as Modified. What could be the reason?
E:\myprojects\myproject>hg summary
parent: 206:03856faec803 tip
latest commit message
branch: default
commit: 78 modified
update: (current)
Even after having performed hg revert --all --no-backup, hg diff --git reports:
diff --git a/path/to/file1 b/path/to/file1
--- a/path/to/file1
+++ b/path/to/file1
## -1,332 +1,332 ##
-line1
-line2
...
-line332
+line1
+line2
...
+line332
diff --git a/path/to/file2 b/path/to/file2
--- a/path/to/file2
+++ b/path/to/file2
## -1,231 +1,231 ##
...
line231
\ No newline at end of file
If hg revert isn't able to restore a clean working directory, this most likely means that the repository doesn't contain the files in canonical form, but hg status gets them into canonical form before comparing against the repository contents. Usually this happens when eol-extension is turned on, but the repository contains files with CRLF. To be sure, turn eol-extension temporarily off and check whether the files are still modified. If so:
(1) turn it on again and commit the changes, so they will be in canonical form in the repository, too.
(2) make sure that other users accessing your repository have eol-extension turned on, otherwise this will be a never ending game :)
Try hg diff --git that will shows you what Mercurial thinks is modified about the files. My guess is the execute bit permission.
Is there a way to configure hg com so that in the commit message file that pops up in the external editor, instead of just showing which files were changed (in the HG: lines) it actually shows the full diff? I'd rather view the output and compose my commit message simultaneously from the comfort of my text editor as opposed to doing hg diff on the command line separately beforehand.
As of 2016, it's possible to do this with the committemplate configuration option. Adding the following to an hgrc file will include the diff in the editor window inline as you type your commit message.
[committemplate]
changeset = {desc}\n\n
HG: {extramsg}
HG: user: {author}\n{ifeq(p2rev, "-1", "",
"HG: branch merge\n")
}HG: branch '{branch}'\n{if(currentbookmark,
"HG: bookmark '{currentbookmark}'\n") }{subrepos %
"HG: subrepo {subrepo}\n" }
{splitlines(diff()) % 'HG: {line}\n'}
See hg help hgrc and search for committemplate for more information.
Mercurial doesn't have that as a built-in feature, but it's easy to simulate in your editor (as launched by commit).
Here's an example using VIM: https://www.mercurial-scm.org/wiki/DiffsInCommitMessageInVIM
The hgeditor script https://www.mercurial-scm.org/hg/hg-stable/raw-file/tip/hgeditor provides further examples.
The basic jist is:
at editor launch run hg diff redirecting to a temp file
have your editor load both the commit message file and the diff
TortoiseHg does this out of the box: a top panel for the commit message and below that, a left pane listing the affected files and a right pane showing the diffs, one after the other.