Mercurial: delete a file from all changesets

I understand how to remove the entire set of changes from history, but it is not clear how to remove a subset.

For example, how to remove all DLL files from an existing set of changes, leaving only the source code?

+13
mercurial
Aug 24 '10 at 15:54
source share
2 answers

Since revision identifiers (e.g. a8d7641f ...) are based on a hash of a change set, it is actually not possible to remove a subset of the change set from the history.

However, it is possible to create a new repo with a parallel history, with the exception of a specific set of files, using the Convert extension. You convert the Mercurial repository to the Mercurial repository using a file card to exclude files that you don't need by adding exclude s. This will create a new, unrelated repository, which means that people with clones will no longer be able to pull it out of it and will have to re-clone from this new repo.

+17
Aug 24 '10 at 16:53
source share
  • Make sure all your teammates have made their local changes to the central repo (if any)
  • Backup repository
  • Create a map.txt file with the following contents:
      # this filemap is used to exclude specific files
     exclude "subdir / filename1.ext"
     exclude "subdir / filename2.ext"
     exclude "subdir2" 
  • Run this command:
      hg convert --filemap map.txt c: / oldrepo c: / newrepo 
    NOTE. You should use forward-slash in paths, even windows.
  • Wait and be patient
  • Now you have a new repo on c:\newrepo , but without files

PS. In the β€œtop” repo, you need to delete all changeets and click your new repo again .

SFC. I actually wrote a blog post about this that contains more detailed information (including breaking changes to Bitbucket, etc.

+13
Mar 24
source share



All Articles