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.
Related
Closed: I started a hg clone... by error in the git repository and this created an empty hg repository. So hggit checks the differences with the empty hg repo and not the git conversion.
$ hg incoming -r branchname_bkm G1
comparing with /home/xxxx/src
abort: unknown revision 'branchname_bkm'
_bkm is the suffix I use between git branches and hg bookmarks.
I have a mercurial repository for long time (named HG0).
I converted it to git using the hggit extension, pushed it to gitlab.
I usually develop in the git repo (named G1) but our official repo is still mercurial.
When needed, I import a git branch (as bookmarks) this way:
update the hg-git map:
cd HG0
hg pull
hg update main_bkm # bookmark on default == main
hg git-cleanup
hg outgoing G1
import git branch:
hg in -r <branchname> G1
It worked perfectly during months.
For about 2 weeks, hg out shows me all the changesets, not only the new ones and hg in returns unknown revision!
I created a new git clone G2 from gitlab. hg out G2 is correct and only shows few revs as expected.
I could exchange my git branch from G1 to G2 and get it in HG0, ok.
How can I "re-synchronize" my hg repo with G1?
git-cleanup does not change anything.
I even tried to entirely rebuild the embedded .hg/git (~2 hours), no change.
If I grep a revision shown by hg out G1 in .hg/git-mapfile, it corresponds to the related revision in G1...
May git garbage collection process "hides" something used to identify the repo?
Thanks in advance.
I have a weird situation here:
when I go on my hg server and do a
sudo hg archive /project/export
It archives it, but in the hidden .hg_archival.txt file I see
branch: default
latesttag: null
latesttagdistance: 31
But the latest checkin was 33. Which seems ignored.
Previously I had to remove changeset 32
hg clone <old repo> <new repo> -r 31
And added later two new checkins...
Could this be the reason for the hickup? What can I do?
Thanks,
You likely aren't updated to the tip. Run hg parent. hg archive will archive the current parent, so you are probably on local revision 31, not 33. After you cloned to 31 and pulled the new checkins, did you hg update?
Here's what I did. I don't want two heads. How do I fix this?
~/src: hg push
pushing to ssh://hg#bitbucket.org/Neil/project
ruprojecting ssh hg#bitbucket.org 'hg -R Neil/project serve --stdio'
searching for changes
new remote heads on branch 'default'
new remote head e04226a528b5
abort: push creates new remote head e04226a528b5!
(did you forget to merge? use push -f to force)
~/src: hg push -f
pushing to ssh://hg#bitbucket.org/Neil/project
ruprojecting ssh hg#bitbucket.org 'hg -R Neil/project serve --stdio'
searching for changes
14 changesets found
remote: adding changesets
remote: adding manifests
remote: adding file changes
remote: added 14 changesets with 30 changes to 67 files (+1 heads)
remote: bb/acl: Neil is allowed. accepted payload.
~/src: hg pull
ruprojecting ssh hg#bitbucket.org 'hg -R Neil/project serve --stdio'
pulling from ssh://hg#bitbucket.org/Neil/project
searching for changes
no changes found
~/src: hg heads
changeset: 1177:e04226a528b5
tag: tip
parent: 1175:b5f77a454e64
user: Neil
date: Sat Feb 25 09:12:48 2012 -0800
files: src/experiments/distribution_combination.py
changeset: 1176:f7cc8d94f4f3
parent: 1162:b680e6f93f80
user: Neil
date: Thu Feb 23 15:32:36 2012 -0800
files: .hgignore src/CMakeLists.txt etc.
If you don't want additional heads - don't do it
Instead of dumb push -f:
hg incoming && hg pull
hg merge
hg commit
hg push
hg merge
That will prompt you to merge the two heads back into one. Rather, it will merge everything it can automatically, and prompt you about conflicts. Afterwards you can diff the result and submit it as a new changelist.
This is usually an indication that someone else has pushed since you last pulled. While you can provide the -f flag to force the push, as you have seen this just results in a new head.
The solution is to update to the head that you want to merge into, and run hg merge, then commit/push.
I'm trying to convert a Mercurial repository to move all the files into a subdirectory in preparation for merging two repositories into one. The problem that I am having is that some of my branches are being lost in the conversion process.
This is what I am doing:
hg convert --filemap filemap.txt SourceRepo DestRepo
My filemap.txt is as follows:
rename . subdir
When this command completes, DestRepo is missing all branches of SourceRepo that were created but which had no changes made to them.
The reason why I have branches that are exactly the same as the parent is because the original repository was an SVN repository so we used branches to tag versions.
Is there any way that I can complete this conversion without losing the branches?
EDIT: Answering Ry4n's question.
The source repo is a Mercurial repository which was created from an SVN repository using the hgsubversion extension.
Here is a log of the branch:
> hg log -b V3.02.55
changeset: 84:cf19dfac555c
branch: V3.02.55
parent: 71:aec56bf6ad9a
user: steve.kaye#868e8ea5-81c6-0a4c-a81c-ce52fb006997
date: Wed Aug 24 15:31:01 2011 +0000
summary: Branching V3.02.55
In Mercurial there is no such thing as a named branch with no changes on them. If your source repo is a Mercurial repository it either doesn't have those named branches or they have at least one change on them.
Is your source Mercurial?
If so, Can you provide the hg log -b NAME output for one of the branches you think exists but has no changes?
I have a local repository and I want to get the latest changes from a remote repository. I know i can clone but clone only works on new directories. I know i can delete the local repository and then clone but i want to know how do it the Mercurial way if there is one.
EDIT: hg pull -u doesn't work if there are conflicts. I don't want to resolve conflicts I just want to get a fresh copy of the remote repo regardless of local changes.
ANSWER: Short answer: Maybe it can be done (see answer below) but re-clone is easier.
Long answer: if you want to get the latest from a remote and disregard your local changes and commits then you'll have to clone to a new local repository or remove the local repository and clone another one. This is because if you have conflicting changes then hg will force you to resolve them manually.
Which is OK but I just wanted to know if it can be done without removing my local repo.
I think you're just looking for this:
hg pull
hg up --clean
That will pull latest set of revisions from the remote repoistory and then update your local repository with a clean copy, regardless of whether or not you have made any changes to the files. No merging necessary.
The only caveat is, if you have added files to your local repository, and they have not been committed, they will be orphaned (left in place, but not in the repository) after the update. If you do an hg stat you should see them denoted with question marks. If the added files have been committed to your local repository, Mercurial will properly clean up after them.
Here's the remote repository (remote rev 6):
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 3/24/2011 2:16 PM .hg
-a--- 3/24/2011 2:16 PM 83 addedtoremote.txt
-a--- 3/24/2011 1:56 PM 726 sample.txt
Here's the local repository (cloned from remote rev 4 earlier) with changed and added files (local rev 5):
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 3/24/2011 2:03 PM .hg
-a--- 3/24/2011 2:05 PM 9 sample.txt
-a--- 3/24/2011 2:05 PM 58 addedtolocal.txt
Here's the local repository after doing a pull and clean update (local rev 6):
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 3/24/2011 2:17 PM .hg
-a--- 3/24/2011 2:17 PM 83 addedtoremote.txt
-a--- 3/24/2011 2:15 PM 726 sample.txt
The changes to sample.txt have been wiped out, addedtolocal.txt has been deleted and addedtoremote.txt has been added.
Looks like you are looking for hg strip, which isn't part of the Mercurial core. It's available through the MqExtension. You can enable it by adding the following in your .hgrc or Mercurial.ini file (https://www.mercurial-scm.org/wiki/MqExtension)
[extensions]
mq =
Then you will be able to:
hg strip rev
This will remove your changesets to the point where you shouldn't have any merge conflicts. This will impact the branch history though. But then again, that's not so bad, if you keep them any good future changeset will have an ancestor that you decided to trash.
If you are just trying something out, you're better of doing it in a separate branch which is easy to close and abandon later.
If you really are looking to keep the bad changeset you can pass in configuration option to the merge command like this
hg --config ui.merge=internal:other merge
This is documented in Mercurial tips and tricks.
Just "pull" changes from the remote repo. Think that "pull" and "push" are change-sets transactions between repos.
Once done, you have to "update" the sources.
You can rebase your modifications, minimizing the need for merges. Just call hg pull --rebase
You'll have to have rebase extension enabled in your ~/.hgrc:
[extensions]
rebase =
Since this is such a common action, there is an extension that does a hg pull -u, hg merge and hg commit in one command:
hg fetch
From the hg book:
Enabling the fetch extension is easy.
Edit the .hgrc file in your home
directory, and either go to the
extensions section or create an
extensions section. Then add a line
that simply reads “fetch=”.
[extensions]
fetch =