Query about mercurial heads diagram and heads counting - version-control

I need to understand in which of the following lines the number of heads are change. Im finding it hard to understand what is going on in line 15..
I know that when a repository doesn't have the same change-sets when pulling or pushing from another repository so there is +1 head.
My diagram looks like this when i tried to solve it:
Line 12: push from clone2 to main repository
Line 15: push from Clone2 to Clone1 (because r3 doesn't similar to r1)
Line 17: pull r2 & r1 from main repository, since r1 and r3 already there, i've added r2 .
Total heads created: +3
main
repository: O--------r2
\----r1
Clone 1: O--------r1
\---r3
\---r2
Clone 2: O------r2---------r3
\--r1--/
The mercurial commands are below:
1: /home/user> hg clone http://remoteserver/mainrepository clone1
2: /home/user> hg clone http://remoteserver/mainrepository clone2
3: /home/user> cd clone1
4: /home/user/clone1> echo one > a.txt
5: /home/user/clone1> hg add a.txt
6: /home/user/clone1> hg commit -m "Added a file"
7: /home/user/clone1> cd ../clone2
8: /home/user/clone2> echo two > b.txt
9: /home/user/clone2> hg add b.txt
10: /home/user/clone2> hg commit -m "Added a file"
11: /home/user/clone2> hg pull ../clone1
12: /home/user/clone2> hg push -f
13: /home/user/clone2> hg merge
14: /home/user/clone2> hg commit -m "Merged"
15: /home/user/clone2> hg push -f ../clone1
16: /home/user/clone2> cd ../clone1
17: /home/user/clone1> hg pull

While planetmaker's answer in linked question is perfectly full and valid, I'll note some mistakes, omissions and wrong assumptions in this situation
Clone2 got head+1 on step 11
>hg pull ..\Clone1
pulling from ..\Clone1
searching for changes
adding changesets
adding manifests
adding file changes
added 1 changesets with 1 changes to 1 files (+1 heads)
Main got head+1 on step 12
>hg push -f
pushing to Z:\Main
searching for changes
adding changesets
adding manifests
adding file changes
added 2 changesets with 2 changes to 2 files (+1 heads)
http://i.imgur.com/KKNU39d.png
Clone2 got head-1 on step 14
Clone1 DOES NOT got head+1 on step 15 (mergeset pushed, with previous heads in Clone2 as parents of mergeset), at this step Clone1 is equal (in DAG-terms) to Clone2
>hg push -f ..\Clone1
pushing to ..\Clone1
searching for changes
adding changesets
adding manifests
adding file changes
added 2 changesets with 1 changes to 1 files
http://i.imgur.com/9bY0URS.png
Steps 16-17 DO NOTHING, because Clone1 DAG is fuller than Main (it has mergeset from Clone2 on top of main-history)
>hg pull
pulling from Z:\Main
searching for changes
no changes found
In order to have full history in Main you must to push to it from any of clones (-f not needed and useless) to have mergeset as new single head in repository
>hg push
pushing to Z:\Main
searching for changes
adding changesets
adding manifests
adding file changes
added 1 changesets with 0 changes to 0 files (-1 heads)

Related

Undo or restore git filter-repo command

In the attempt to get rid of a large history file (.RDataTmp >> 100 Mb) that was causing GitHub to fail its synchronization, I used the git filter-repo command, and specifically the following:
User#mac MainDirectory % git filter-repo --path manuscript/code/.RDataTmp--invert-paths
This resulted in the following messages:
Parsed 142 commits
New history written in 0.92 seconds; now repacking/cleaning...
Repacking your repo and cleaning out old unneeded objects
Updating files: 100% (13768/13768), done.
Enumerating objects: 1, done.
Counting objects: 100% (1/1), done.
Writing objects: 100% (1/1), done.
Total 1 (delta 0), reused 0 (delta 0), pack-reused 0
Completely finished after 5.80 seconds.
After this I tried to synch the updated files with the repository, with the following commands:
(base) User#Mac MainDirectory % git stage .
(base) User#Mac MainDirectory % git commit -m "updates"
This had the following result
[master (root-commit) a413463] updates
57 files changed, 0 insertions(+), 0 deletions(-)
The it enter into a create mode 100644 with those 57 files and after this I pushed the repo. The result was a failed push, with the message:
"fatal: No configured push destination. Either specify the URL from
the command-line or configure a remote repository using git remote add
and then push using the remote name"
I then opened GitHub Desktop and pushed to another repository (new one), thinking that all my offline files would have been pushed online in the updated repository.
The conclusion is that I now have a bunch of folders, almost none of the files I had and no history from either the original repo or the new-named one.
Is there a way to revert this process?
Thanks

git status working directory nothing to commit, working directory to clean, add , commit NO GO

---I have the same problem but the fix does not seem to work.
I cloned a new repository. From it, I
a. created a new branch with git checkout -b
b. We updated our files in one of the directories, call it GAWBE
c. did our push to that branch
d. inspected the branch on the github.com site, It was fine
Then, I had to update files in a different directory to the master branch.
Call the directory PDBE
Thus, I did
git checkout master
went to the PDBE directory
updated several files there
did the git status
(I got the message
On branch master
nothing to commit, working directory clean
as indicated above)
I did the git branch --set-upstream-to origin/master
Got the message
Branch master set up to track remote branch master from origin.
f. I then did git status
Again, I got
# On branch master
nothing to commit, working directory clean
I tried
git pull origin
From https://github.com/doctorleff/u3e
*branch master -> FETCH_HEAD
Already up to date.
h. I tried git status again with the same working directoyr clean message
and git commit with the same message
Needless to say, I alo checked my .gitignore and .git/info/exclude
Nothing in the latter--former does not specify any of the files in question,
all .java
This as per the Issue 37269222
Also tried the rm -rf .git (Issue 37900326)
also tried git log as per issue 29578546, got error message:
fatal: bad default revision 'HEAD'
Thank you for suggesting that I create a minimal file to show the problem
with my branches and git hub.
On github, I created a new repository. (It is marked public.)
(It is doctorleff/TR
1) I created a directory TR to serve as my repository.
2) I put a single file there IncomeFile.java
3) git init
Told me Initialized empty Git repository in /home/leffstudent/TR/.git
4) git add IncomeFile.java
5) Created gitignore with *.class
6) git add .gitignore
7) git status told me
# On branch master
#
# Initial commit
#
# Changes to be committed:
# (use "git rm --cached <file>..." to unstage)
#
# new file: .gitignore
# new file: IncomeFile.java
8) `git commit -m "first commit"
Response was:
[master (root-commit) 6e71c52] first commit
2 files changed, 37 insertions(+)
create mode 100644 .gitignore
create mode 100644 IncomeFile.java
8) git remote add origin https:/github.com/doctorleff/TR.git
9) git push -u origin master
It asked me for my git login and password, then told me
Counting ojbects: 4, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (3/3), done
Writing objects: 100% (4/4), 681 bytes | 0 bytes/s, done.
10) git checkout -b TOMCAT
Told me:
Switched to a new branch 'TOMCAT'
11) I changed IncomeFile.java slightly
12) git add IncomeFile.java
13) git commit -m "testing tomcat branch"
[TOMCAT 54f1b57] testing tomcat branch
1 file changed, 1 insertion(+), 1 deletion (-)
14) git push origin tomcat
Again, I was asked for my github username and passwrd.
Then it told me:
error: src refspect tomcat does not match any.
error: failed to push some refs to 'https://github.com/doctorleff/TR.git'
15) When I did a git status
$On branch TOMCAT
nothing to commit, working directory clean
Same thing if I simply type git status
I tried git check-ignore -v -- IncomeFile.java
Just get back the prompt
My test directory now seems to be working. Thus, I went back to the original cloned repository about which I spoke earlier.
I followed some of the instructions in
StackOverflow issue 4089430. (See link below)
I compared the results on both the working TEST repository and the
repository that does not work. It appears that the local repository
lost track of its remote.
I was thinking, should I do a git clone right into the defective
repositories to reconnect them to the world.
Meanwhile, I worked around my problem by cloning to a different computer,
a Macintosh. I am able to work normally with
the remote repository. Thus, I don't believe there is any problem with it.
And I have, a slightly less convenient, way to proceed with our project.
[How can I determine the URL that a local Git repository was originally cloned from?
I have two transcripts (edited slightly from script). The first is from
the test repository, that shows things working--
thanks for asking me to try that--
and then from the real one
cd TR
git remote show origin
* remote origin
Fetch URL: https://github.com/doctorleff/TR.git
Push URL: https://github.com/doctorleff/TR.git
HEAD branch: master
Remote branches:
TOMCAT tracked
master tracked
Local branch configured for 'git pull':
master merges with remote master
Local refs configured for 'git push':
TOMCAT pushes to TOMCAT (up to date)
master pushes to master (up to date)
git remote show origin
* remote origin
Fetch URL: https://github.com/doctorleff/TR.git
Push URL: https://github.com/doctorleff/TR.git
HEAD branch: master
Remote branches:
TOMCAT tracked
master tracked
Local branch configured for 'git pull':
master merges with remote master
Local refs configured for 'git push':
TOMCAT pushes to TOMCAT (up to date)
master pushes to master (up to date)
git status
# On branch master
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: IncomeFile.java
#
no changes added to commit (use "git add" and/or "git commit -a")
git checkout -- IncomeFile.java
git checkout TOMCAT
Switched to branch 'TOMCAT'
git status
# On branch TOMCAT
nothing to commit, working directory clean
VI IncomeFile.java
git commit -m "changed mC to Mc"
# On branch TOMCAT
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: IncomeFile.java
#
no changes added to commit (use "git add" and/or "git commit -a")
git add IncomeFile.java
git commit -m "changed mC to Mc"
[TOMCAT 7b842b0] changed mC to Mc
1 file changed, 1 insertion(+), 1 deletion(-)
push origin
fatal: The current branch TOMCAT has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin TOMCAT
git push --setu-upstream origin TOMCAT
Username for 'https://github.com': doctorleff
Password for 'https://doctorleff#github.com':
Counting objects: 5, done.
Delta compression using up to 2 threads.
Compressing objects: 33% (1/3)
Compressing objects: 66% (2/3)
Compressing objects: 100% (3/3)
Compressing objects: 100% (3/3), done.
Writing objects: 33% (1/3)
Writing objects: 66% (2/3)
Writing objects: 100% (3/3)
Writing objects: 100% (3/3), 323 bytes | 0 bytes/s, done.
Total 3 (delta 1), reused 0 (delta 0)
remote: Resolving deltas: 0% (0/1) remote: Resolving deltas: 100% (1/1) [K
remote: Resolving deltas: 100% (1/1), completed with 1 local object.[K
To https://github.com/doctorleff/TR.git
ff102ee..7b842b0 TOMCAT -> TOMCAT
Branch TOMCAT set up to track remote branch TOMCAT from origin.
git add IncomeFile.java
"change M[KCa to aC"
[TOMCAT 1a6739c] change Ca to aC
1 file changed, 1 insertion(+), 1 deletion(-)
git push origin
Username for 'https://github.com': doctorleff
Password for 'https://doctorleff#github.com':
Counting objects: 5, done.
Delta compression using up to 2 threads.
Compressing objects: 33% (1/3)
Compressing objects: 66% (2/3)
Compressing objects: 100% (3/3)
Compressing objects: 100% (3/3), done.
Writing objects: 33% (1/3)
Writing objects: 66% (2/3)
Writing objects: 100% (3/3)
Writing objects: 100% (3/3), 324 bytes | 0 bytes/s, done.
Total 3 (delta 1), reused 0 (delta 0)
remote: Resolving deltas: 0% (0/1) [K
remote: Resolving deltas: 100% (1/1) Resolving deltas: 100% (1/1), completed with 1 local object.[K
To https://github.com/doctorleff/TR.git
7b842b0..1a6739c TOMCAT -> TOMCAT
THUS, I then tried to go back to one of the repositories that was corrupted.
cd sv/web/src
git status
# On branch master
#
# Initial commit
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
#LONG LIST OF FILES REMOVED for clarity
#
# Test.java
nothing added to commit but untracked files present (use "git add" to track)
git add Test.java
git commit -m "testing with Test.java"
[master (root-commit) 96c329f] testing with Test.java
1 file changed, 70 insertions(+)
create mode 100644 Test.java origin
fatal: The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin master
git push --set-upstream origin master
fatal: 'origin' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists
____________________________________________
git status
# On branch master
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# $
# .RatingEntryServletNew.java.swp
# 11in35tr.xls
# AdminFrontServlet.class
# AdminFrontServlet.java
# AgreementBackend.class
-- REST OF LONG LIST OF FILES GIVEN DELETED FOR BREVITY
nothing added to commit but untracked files present (use "git add" to track)
git remote show origin
fatal: 'origin' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
git config --get remote.origin.url
git remote -v
git ls-remote --get-r[Kurl
fatal: No remote configured to list refs from.
git ls-remote --get-url origin
origin
I also tried the git check-ignore -v -- on several files on the depository.
This was as suggested in the answer.
It just returns--I assume that means that these files are not affected by
any ignore rule.
____ response to VonC ___
In sv/web/src there is a .git subdirectory. FETCH_HEAD is zero bytes
HEAD syas refs: refs/heads/master That file exists and contains a long
hex code which I assume is a commit code, but I cannot find it at github.com.
The root (sv) also has a .git There, HEAD says refs/heads/tomcat
MY other local reposityory copy
sw/web/src also has a .git Its HEAD has
line ref: refs/heads/master But in that case, that file does not exist.
As suggested, I did try git remote -v on the two repositories in
question. Here is the output for sv
git remote -v
githubrepo https://github.com/doctorleff/u3e.git (fetch)
githubrepo https://github.com/doctorleff/u3e.git (push)
origin https://github.com/doctorleff/u3e.git (fetch)
origin https://github.com/doctorleff/u3e.git (push)
The second sw is showing that the repository is hopelessly corrupted:
git remote -v
fatal: Not a git repository (or any parent up to mount point /home)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
Since then, I have created a new local clone on this repository from github.
I went back and forth between the two branches and everything is OK.
Thus, please consider this matter closed as not reproducable and no longer
a problem for original poster.
~
I also checked my .gitignore and .git/info/exclude Nothing in the latter--former does not specify any of the files in question, all .java
Double-check with:
git check-ignore -v -- PDBE/yourFile
Sometime, gitignore rules can come from other sources (like an IDE).
The first push of the tomcat branch should be git push -u origin tomcat
If a repo is inside another one, it becomes a nested repo: it might not have an origin, while its parent (which includes said nested repo) have:
Do a git remote -v in each folder.
You can add a remote origin (in the nested repo folder) with git remote add origin /url/remote/repo. Then the push might work better.

Revert Mercurial Commit for Merge

I am working on a Hg repo in BitBucket. I forked this repo from another main repo.
Here's my scenario:
> hg paths
default = ssh://hg#bitbucket.org/shuwnyuantee/jstock-android-as
yccheok = ssh://hg#bitbucket.org/yccheok/jstock-android-as
default repo is my forked repo. yccheok is the main repo I forked from.
I did the below so I am on drive-wealth branch of default repo.
> hg pull
pulling from ssh://hg#bitbucket.org/shuwnyuantee/jstock-android-as
> hg update drive-wealth
128 files updated, 0 files merged, 1 files removed, 0 files unresolved
> hg branch
drive-wealth
> hg log -l 3
changeset: 2770:a210525cc123
branch: drive-wealth
tag: tip
parent: 2769:a0bacd6f326a
parent: 2768:0eb8c0268784
user: Shuwn Yuan Tee <s.yuan31tee#gmail.com>
date: Tue Mar 21 16:41:04 2017 +0800
summary: merge default branch
changeset: 2769:a0bacd6f326a
branch: drive-wealth
parent: 2676:7571be00648f
user: Shuwn Yuan Tee <s.yuan31tee#gmail.com>
date: Tue Mar 21 13:17:14 2017 +0800
summary: list all accounts API
changeset: 2768:0eb8c0268784
user: Yan Cheng Cheok <yccheok#yahoo.com>
date: Sat Mar 18 13:56:51 2017 +0800
summary: Add the missing tracker name.
I wish to revert commit 2770:a210525cc123 on drive-wealth branch & push to default repo. I tried hg strip --keep -r . suggested here. Some files appear as Modified as:
> hg status
M achartengine/build.gradle
M androidXml/build.gradle
M androidlockpattern/build.gradle
M gradle/wrapper/gradle-wrapper.properties
M jstockandroid/build.gradle
M jstockandroid/src/main/AndroidManifest.xml
......
My questions are:
1) Those files show changes in Merge, but not all files are reverted correctly, many changes are missing / not undone. Any idea?
2) If (1) successfully undo all, then what are steps to proceed? What I want to achieve is => simply revert commit 2770:a210525cc123 on branch drive-wealth for default repo & push to default repo?
Thanks!
don't you need to also trip 2769?
as 2770 is your merge commit
so
hg strip --keep -r 2770
hg strip --keep -r 2769
then push

Fatal: Unable to checkout working tree

I am cloning the master branch from a GitHub repo onto my system. It throws this error:
Checking connectivity ...done eate file Icon fatal:
unable to checkout working tree warning: Clone succeeded, but checkout
failed.
I've tried to include the suggestions for line ending problems in Windows as the help doc suggests
but still I am facing the same issue.
How can this be solved?
Windows 7
As I know of, you will want to modify any file names containing: \, /, :, *, ?, ", <, >, or |, as Windows does not comply with those symbols for file naming purposes.
A nice and simple "fix" would be to download the files as a zip archive (which is supported by github), then modify the troublesome file names in File Explorer and then, finally, extract the zip archive in your desired directory.
Some documents in the file name under Windows is illegal. Delete these files to, or use OS X to modify the file name and then clone under Windows.
Git can't checkout a repo from github
Check the error messages carefully. Some file names might be long or some other issues will be there concerning a file. Or maybe there is not enough space. But do git clone on command prompt and go through the last couple of error messages
I got this error trying to download some repos with blacklisted windows filenames:
error: invalid path 'drivers/gpu/drm/nouveau/nvkm/subdev/i2c/aux.c' notice the file is called aux.c which is a banned word in windows because AUX is a namespace for auxiliary port connections. Backwards compatibility to the stone ages basically.
More info: https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file?redirectedfrom=MSDN#win32-device-namespaces
For a full list of reserved keywords see second-last dotpoint: https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file?redirectedfrom=MSDN#naming-conventions
Check the error messages carefully. Some file names might be long or some other issues will be there concerning a file.
PS> git clone https://github.com/jonathanbaraldi/devops-ninja-multicloud-multicluster-pt.git
Cloning into 'devops-ninja-multicloud-multicluster-pt'...
remote: Enumerating objects: 1951, done.
remote: Counting objects: 100% (1951/1951), done.
remote: Compressing objects: 100% (1494/1494), done.
remote: Total 1951 (delta 377), reused 1934 (delta 364), pack-reused 0
Receiving objects: 100% (1951/1951), 6.40 MiB | 19.91 MiB/s, done.
Resolving deltas: 100% (377/377), done.
> error: invalid path 'doc/logos/1*afkK1deEdJkuN3IhnzuzKg.png'
>
> fatal: unable to checkout working tree
warning: Clone succeeded, but checkout failed.
You can inspect what was checked out with 'git status'
and retry with 'git restore --source=HEAD :/'
PS> git status
fatal: not a git repository (or any of the parent directories): .git
PS> cd .\devops-ninja-multicloud-multicluster-pt\
PS> git status
On branch main
Your branch is up to date with 'origin/main'.
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
deleted: .gitignore
deleted: LICENSE
deleted: README.md
deleted: app/api-book/Dockerfile
More info:
https://www.unidadvirtual.com/problema-al-clonar-un-proyecto-con-git-en-windows-error-filename-too-long
My case-specific issue was that someone on my team created a bunch of folders with a space at the end of the name.(e.g. 'my_folder ', with the path looking like 'my_folder2/my_folder /document.pdf')
This seems to be possible on Mac, but Windows doesn't allow spaces at the end of folder names. Removing those spaces solved the issue.

Recovering history in hg when move not done properly

So somebody on our team moved an entire folder into a subdirectory without using hg's rename feature. The directory structure is like we need it, but the history is now gone prior to the move. It shows it as a new file when the move occurred. Numerous large merges have happened since then, and so it is not really practical to go back in time and do it right.
I have tried hg log --follow and it does not help, since hg does not know about the rename. Is there any way to manually link the files to the old removed versions after the fact, or is there some facility like the way git can infer moves and renames based on hueristics? It would be nice if there was some way to explicitly say, "this file is a continuation of this old deleted file.", even though that would still take some time to fix it all up right.
We have all but given up on ever getting that history back, but it would be really nice to have it.
You need to redo the move correctly by explicitly telling Mercurial what files were moved, then merge the broken changesets. This way you will restore the history path to the original files.
Steps, assuming <x> is the move revision, and <y> is the current head revision.
Update to the revision before the move: hg update <x-1>
Redo the move, but now correctly using hg rename or hg rename --after
Commit
Merge with the original move revision (hg merge <x>), this should have no conflicts but if there are discard all changes.
Commit
Merge with the remaining changesets after the move (if any) (hg merge <y>)
Commit
Here is the basic process shown on the command line:
$ mkdir move-merge-test
$ cd move-merge-test
$ hg init
$ echo "x" > a
$ hg add a
$ hg commit -m "initial revision"
Move incorrectly:
$ mv a b
$ hg remove a
$ hg add b
$ hg status --copies
A b
R a
$ hg commit -m "incorrect move"
$ hg log --follow b
changeset: 1:b22f3e94133b
tag: tip
user: Laurens Holst <...>
date: Wed Oct 19 14:41:37 2011 +0200
summary: incorrect move
Correct the move:
$ hg update 0
1 files updated, 0 files merged, 1 files removed, 0 files unresolved
$ hg rename a b
$ hg status --copies
A b
a
R a
$ hg commit -m "correct move"
created new head
$ hg log --follow b
changeset: 2:5deabbcb5480
tag: tip
parent: 0:b82f89f0c7d9
user: Laurens Holst <...>
date: Wed Oct 19 14:46:35 2011 +0200
summary: correct move
changeset: 0:b82f89f0c7d9
user: Laurens Holst <...>
date: Wed Oct 19 14:36:35 2011 +0200
summary: initial revision
Merge it with the broken move:
$ hg merge 1
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
(branch merge, don't forget to commit)
$ hg commit -m "merge with broken move"
$ hg log --follow b
changeset: 3:ce65fc7b35e4
tag: tip
parent: 2:5deabbcb5480
parent: 1:b22f3e94133b
user: Laurens Holst <...>
date: Wed Oct 19 14:47:13 2011 +0200
summary: merge broken branch
changeset: 2:5deabbcb5480
parent: 0:b82f89f0c7d9
user: Laurens Holst <...>
date: Wed Oct 19 14:46:35 2011 +0200
summary: correct move
changeset: 1:b22f3e94133b
user: Laurens Holst <...>
date: Wed Oct 19 14:41:37 2011 +0200
summary: incorrect move
changeset: 0:b82f89f0c7d9
user: Laurens Holst <...>
date: Wed Oct 19 14:36:35 2011 +0200
summary: initial revision
As you can see, the history now correctly shows all affected changesets. If the files are moved in several commits, the basic principle stays the same just merge across more than just 1 commit. If you have any commits made after the move, I recommend to merge them in separately (step 6 in the steps above) in order to avoid spurious conflicts.
I had good luck with this kind of thing by deleting the new (the "moved") file, then going back to a revision when the file was still in place, doing the move properly (including commit) and merging the two heads.
There's a --after option to hg rename which lets you tell Mercurial about a rename after the fact, but it has to be done before you commit the rename.
You could try doing hg convert on the repository and specify the --filemap parameter, which will let you rename a files and directories.
https://www.mercurial-scm.org/wiki/ConvertExtension#A--filemap