git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Fixing branches from a (really messed up) subversion repository

From
JSJoshua Shrader <jshrader83@gmail.com>
Date
Jun 18, 2010, 21:40 UTC
Message-ID
<AANLkTin0zwH8KLr9Cem-piRZ0mn9Q9ZScmFJF2r_DTi4@mail.gmail.com>
In-Reply-To
<AANLkTimxivcSShukg0kFPF_7ignIv3d3TUl8KELKUksF@mail.gmail.com>

I started with svnadmin dump /path/to/repo > svn.dump. Then I had to manually edit svn.dump (I'm sure someone smarter then me could roll this into the Perl script I used in the next step) to create a "trunk" and "branches" directory in the first commit. I found the commits that added "trunk" and "branches" when we re-organized our repo to follow this convention, and deleted them. Then I had to locate where all of the branches were created - looked like

Node-path: branchname
Node-kind: dir
Node-action: add
Node-copyfrom-rev: 23
Node-copyfrom-path:

and change that blank "Node-copyfrom-path: " to "Node-copyfrom-path: trunk". The blank path is what really caused issues because everytime a branch was created, it would contain copies of branches which contained copies of branches, etc... So branch2 had a subfolder branch1, and branch3 contained branch2 and branch 1, where branch 2 contained branch 1...

Then, I removed all of the contents of the commits (not the commits themselves) where we re-organized the repo. i.e.

Node-path: trunk/src
Node-action: add
Node-copyfrom-ref: 23
Node-copyfrom-path: src

and the ones where we deleted nested branches and moved the individual branches into a "branches" directory.

I made these edits and saved them. Then I ran that file through a perl filter, tried to svnadmin load newrepo < filteredDumpFile, and if I got errors, I iterated - changed the pre-filtered file, blow away the svn repo that gave me an error during load, re-create it, and re-load. I iterated this over several days, as I discovered more and more inconsistencies with my edited dump file. I think I have all of the steps above, but I may be missing one or two, and if I am, I apologize. I'd imagine everyone's situation would be a bit different, so adjust accordingly.

Now, I'm quite the Perl hack so I doubt you want to look at the script. It essentially did the following:

Read each line of the dump file.
If the line doesn't start with "Node-path:" or "Node-copyfrom-path:",
then just print it un-altered.
If it does,
  does what follows the ':' start with "trunk", "branches", or "tags"?
 If so, then just print un-altered.
Otherwise,
  for each $branchname(@branchnames) if what follows the ':' begins
with $branchname, replace it with "branches/$branchname", and print.
If none of the branch names match,
  prepend "trunk" to the beginning of the path, and print.

This essentially re-writes all of the paths so that everything not in a branch, or already under "branches", "tags", or "trunk", is put under trunk. It also moves all of the /branchenames to /branches/branchnames.

After this, we did svnadmin hotcopy repo repo-backup rm -rf repo svnadmin create repo svnadmin load repo <filteredDumpFile

Changed the ownership to match the ownership of the original repository, copied over the contents of the repo-backup/hooks directory into the new repo/hooks, and we were all set.

git svn clone --stdlayout... then worked fine. Now I just need to work on a workflow for my co-workers how want to also use git (i.e. create a bare git repo, and keep that in sync with the git-svn repo). Ideally, all of us git users can clone the bare repo and push to it, then every once in a while, I can pull from the bare into the git-svn repo, and do a dcommit, but I've ran into a couple yet-unresolved problems. If you have an references or ideas, I'd appreciate them, but I suppose that's another thread.

On Fri, Jun 18, 2010 at 5:01 PM, Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:

Show 9 quoted lines
> On Fri, Jun 18, 2010 at 20:59, Joshua Shrader <jshrader83@gmail.com> wrote:
>> Thanks.  It took a couple days to get everything straightened out, but
>> this seems to have worked very well.
>
> Mind sharing the details or code for what you did?
>
> I've only proved to myself that this approach will work, I haven't
> actually done it.
>
Previous: Ævar Arnfjörð Bjarmason
Message 6 of 6 in “Fixing branches from a (really messed up) subversion repository”
  1. Joshua ShraderJun 15, 2010
  2. Ævar Arnfjörð BjarmasonJun 15, 2010
  3. Joshua ShraderJun 15, 2010
  4. Ævar Arnfjörð BjarmasonJun 15, 2010
  5. Ævar Arnfjörð BjarmasonJun 18, 2010
  6. Joshua ShraderJun 18, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.