Fossil Forum

How to move a directory to a new repository?
Login

How to move a directory to a new repository?

How to move a directory to a new repository?

(1) By anonymous on 2018-10-15 03:00:43 [link] [source]

Hi,

I have been trying to move a directory from a repository to its own repository by using fossil reconstruct, but at the end the new repository is empty (despite of having a size of 354k).

The procedure I made was this:

    fossil reconstruct ~/Programas/Dataviz/dataviz.fossil ~/Programas/Grafoscopio/Repo/Packages/Dataviz
    Reading files from directory "/home/offray/Programas/Grafoscopio/Repo/Packages/Dataviz"...
  7
    Building the Fossil repository...
      100.0% complete...
    project-id: c3079f3d0523d7ff431bb67888bf28fb76019c56
    server-id: 6519381b1119bf99f5f24124626c1a42aa1d2311
    admin-user: offray (initial password is "7de2fe")

(Curiously the 7 number at the beginning of the output is the name of files I have in the directory I want to convert into a new repository).

After that I did a fossil open dataviz.fossil and I got:

    project-name: <unnamed>
    repository:   /home/offray/Programas/Dataviz/dataviz.fossil
    local-root:   /home/offray/Programas/Dataviz/
    config-db:    /home/offray/.fossil
    project-code: c3079f3d0523d7ff431bb67888bf28fb76019c56
    check-ins:    0

With no files on the new repository. What I'm doing wrong?

Thanks,

Offray

Ps: The Markdown code for unformated text (using back tildes) seems not working properly in the Fossil Fourm and doesn't respect line breaks.

(2) By Stephan Beal (stephan) on 2018-10-15 03:30:36 in reply to 1 [link] [source]

You can't use reconstruct to import part of a repository - the deconstruct data is only intended to be able to completely reconstruct a whole repository with all of its data. There is no export/re-import mechanism which keeps history intact for subsets of a repository. You will have to simply copy those files to an existing checkout, "add" them there, and check them in.

(3) By anonymous on 2018-10-15 04:08:09 in reply to 2 [link] [source]

So, what should be on the new created repository after running fossil reconstruct FILENAME DIRECTORY?

There is a detailed procedure to have subset of the whole repository history (the one for a particular folder) in a new repository?

Thanks,

Offray

(4) By Stephan Beal (stephan) on 2018-10-15 04:21:50 in reply to 3 [link] [source]

The repository will be incomplete unless you import the whole thing, so it will not be a functional repository. It might physically contain the files you want, but without all of the checkin metadata and all blobs that metadata references, they're just useless noise to fossil. Reconstruction is not a feature users are intended to use unless a knowledgeable fossil developer suggests that they should.

Like i said in my first response, there is no mechanism for exporting or importing the history of a partial repository. What you are trying to do is not supported by fossil's data model.

(5) By Richard Hipp (drh) on 2018-10-15 11:48:08 in reply to 4 [link] [source]

To amplify Stephen's reply: It is theoretically possible to construct a new repository that contains some subset of the files in a reference repository, but all of the checkin hashes in the new repository would be different. It is a fundamental property of block-chain VCSes that you cannot add or remove files from a checkin without also changing the name of the checkin. This is a security feature. If you check out a version of some project based on its complete hash, then you are assured of getting exactly what was originally checked in, byte-for-byte, with no additions or deletions.

While it is theoretically possible to construct a "subset" or "slice" of a repository, there is no support for that built into Fossil currently. But you could, probably, write a script that would go through and check out each checkin, then add the subset of files you are interested in to a new repo. The --override-user and --override-date options to the "fossil commit" command will be useful to you there.

As Stephen already correctly observed, the "deconstruct" and "reconstruct" commands are not particularly helpful for this.

(6) By anonymous on 2018-11-01 17:11:27 in reply to 5 [source]

The method I used finally was:

  1. Convert the Fossil repository to Git:

    git fast-export --all | fossil import --git <my-repo.fossil>
    
  2. Use the GitHub guide for splitting a subfolder out into a new repository until step 7.

  3. Setup my email in the Git command line (I never did this before, thanks to Fossil ;-) ).

    git config --global user.email "<name@domain.something>"
    
  4. Add a remote origin to the GitHub repository I created previously:

    git remote add origin https://github.com/<user>/<repo>.git
    
  5. Push the subfolder repository to GitHub

    git push -u origin trunk
    
  6. Clone that repository:

    git clone https://github.com/<user>/<repo>.git
    
  7. Convert it back to Fossil:

    git fast-export --all | fossil import --git <my-subfolder-repo>.fossil
    
  8. The new Fossil repository contains the history of all artifacts in the subfolder. Checkins checksums are different compared to the checksums in the original one, but the history of modifications is preserved (which file was changed and by which modification in which order by who and when), that is the core of what I need to have (despite checksums).

Considering the query capabilities integrated into Fossil, thanks to SQLite, I think is possible to make this directly into Fossil, with the caveat that checksums will differ from the original ones but despite metadata being different, historical data would be the same (for most practical effects).

Cheers,

Offray