Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6712289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:14:30+00:00 2026-05-26T08:14:30+00:00

So somebody on our team moved an entire folder into a subdirectory without using

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T08:14:31+00:00Added an answer on May 26, 2026 at 8:14 am

    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.

    1. Update to the revision before the move: hg update <x-1>
    2. Redo the move, but now correctly using hg rename or hg rename --after
    3. Commit
    4. Merge with the original move revision (hg merge <x>), this should have no conflicts but if there are discard all changes.
    5. Commit
    6. Merge with the remaining changesets after the move (if any) (hg merge <y>)
    7. 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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Our team is evaluating using WCF Data Services (formerly ADO.NET Data Services), and have
Does somebody know a Java library which serializes a Java object hierarchy into Java
we deliver micro-site content for our client. Our content is injected into a wrapper
I'm using Add-in-Express to develop a prototype of our plugin for Outlook and what
The project, I have involved, has an architecture-oriented project's file/folder structure: Root |____ Node1
One of our team is working on an ASMX service. The service use to
We have implemented a feature in our web app that updates the GUI in
I would like to use Sharedcache (sharedcache.codeplex.com) in our Silverlight v4.0 project. However, we
how can i manage in django multiple domains? Our website will be configured like
I am running into the following issue: Our members have a desire for personalized

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.