]> Tony Duckles's Git Repositories (git.nynim.org) - svn2svn.git/blob - README.mkd
README updates
[svn2svn.git] / README.mkd
1 svn2svn
2 =======
3 Replicate (replay) changesets from one Subversion repository to another.
4
5 Features
6 --------
7 - **Meant for replaying history into an "empty target location**. This could be
8 an empty target repo or simply an empty folder/branch in the target repo.
9 - **Maintains logical history (when possible)**, e.g. uses "svn copy" for renames.
10 - **Maintains original commit messages**.
11 - **Optionally maintain source commit authors (`svn:author`) and commit timestamps
12 (`svn:date`)**. Requires a "pre-revprop-change" hook script in the target
13 repo, to be able to change the "`svn:author`" and "`svn:date`" revprops after
14 target commits have been made.
15 - **Optionally maintain identical revision #'s between source vs. target repo**.
16 Effectively requires that you're replaying into an empty target repo,
17 or rather that the first source repo revision to be replayed is less than
18 the last target repo revision. Create blank "padding" revisions in the target
19 repo as needed.
20 - **Optionally run an external shell script before each replayed commit**,
21 to give the ability to dynamically exclude or modify files as part
22 of the replay.
23
24 Overview
25 --------
26 This is a utility for replicating the revision history from a source path in
27 a source SVN repository to a target path in a target SVN repository. In other
28 words, it "replays the history" of a given source SVN repository/branch/path
29 into a target SVN repository/branch/path.
30
31 This can be useful to create filtered version of a source SVN repository. For
32 example, say that you have a huge SVN repository with a _lot_ of old branch
33 history which is taking up a lot of disk-space and not serving a lot of purpose
34 going forward. You can this utility to replay/filter just the "/trunk" SVN
35 history into a new repository, so that things like "svn log" and "svn blame"
36 will still show the correct (logical) history/ancestry, even though we end-up
37 generating new commits which will have newer commit-dates and revision #'s.
38
39 While this replay will obviously run faster if you're running between both
40 a local source and target repositories, none of this *requires* direct
41 access to the repo server. You could access both the source and target repo's
42 over standard `http://`, `ssh://`, etc. methods.
43
44 Usage
45 -----
46 See `svn2svn.py --help`:
47
48 $ ./svn2svn.py --help
49 svn2svn, version 1.4.0
50 <http://nynim.org/projects/svn2svn> <https://github.com/tonyduckles/svn2svn>
51
52 Usage: svn2svn.py [OPTIONS] source_url target_url
53
54 Replicate (replay) history from one SVN repository to another. Maintain
55 logical ancestry wherever possible, so that 'svn log' on the replayed repo
56 will correctly follow file/folder renames.
57
58 Examples:
59 Create a copy of only /trunk from source repo, starting at r5000
60 $ svnadmin create /svn/target
61 $ svn mkdir -m 'Add trunk' file:///svn/target/trunk
62 $ svn2svn -av -r 5000 http://server/source/trunk file:///svn/target/trunk
63 1. The target_url will be checked-out to ./_wc_target
64 2. The first commit to http://server/source/trunk at/after r5000 will be
65 exported & added into _wc_target
66 3. All revisions affecting http://server/source/trunk (starting at r5000)
67 will be replayed to _wc_target. Any add/copy/move/replaces that are
68 copy-from'd some path outside of /trunk (e.g. files renamed on a
69 /branch and branch was merged into /trunk) will correctly maintain
70 logical ancestry where possible.
71
72 Use continue-mode (-c) to pick-up where the last run left-off
73 $ svn2svn -avc http://server/source/trunk file:///svn/target/trunk
74 1. The target_url will be checked-out to ./_wc_target, if not already
75 checked-out
76 2. All new revisions affecting http://server/source/trunk starting from
77 the last replayed revision to file:///svn/target/trunk (based on the
78 svn2svn:* revprops) will be replayed to _wc_target, maintaining all
79 logical ancestry where possible.
80
81 Options:
82 --version show program's version number and exit
83 -h, --help show this help message and exit
84 -v, --verbose enable additional output (use -vv or -vvv for more)
85 -a, --archive archive/mirror mode; same as -UDP (see REQUIRE's below)
86 maintain same commit author, same commit time, and
87 file/dir properties
88 -U, --keep-author maintain same commit authors (svn:author) as source
89 (REQUIRES 'pre-revprop-change' hook script to allow
90 'svn:author' changes)
91 -D, --keep-date maintain same commit time (svn:date) as source
92 (REQUIRES 'pre-revprop-change' hook script to allow
93 'svn:date' changes)
94 -P, --keep-prop maintain same file/dir SVN properties as source
95 -R, --keep-revnum maintain same rev #'s as source. creates placeholder
96 target revisions (by modifying a 'svn2svn:keep-revnum'
97 property at the root of the target repo)
98 -c, --continue continue from last source commit to target (based on
99 svn2svn:* revprops)
100 -f, --force allow replaying into a non-empty target folder
101 -r, --revision=ARG revision range to replay from source_url
102 A revision argument can be one of:
103 START start rev # (end will be 'HEAD')
104 START:END start and ending rev #'s
105 Any revision # formats which SVN understands are
106 supported, e.g. 'HEAD', '{2010-01-31}', etc.
107 -u, --log-author append source commit author to replayed commit mesages
108 -d, --log-date append source commit time to replayed commit messages
109 -l, --limit=NUM maximum number of source revisions to process
110 -n, --dry-run process next source revision but don't commit changes to
111 target working-copy (forces --limit=1)
112 -x, --verify verify ancestry and content for changed paths in commit
113 after every target commit or last target commit
114 -X, --verify-all verify ancestry and content for entire target_url tree
115 after every target commit or last target commit
116 --debug enable debugging output (same as -vvv)
117
118 Side Effects
119 ------------
120 - The source repo is treated as strictly read-only. We do log/info/export/etc.
121 actions from the source repo, to get the history to replay and to get the
122 file contents at each step along teh way.
123 - You must have commit access to the target repo. Additionally, for some of
124 the optional command-line args, you'll need access to the target repo to
125 setup hook scripts, e.g. "pre-revprop-change".
126 - This script will create some folders off of your current working directory:
127 - "`_wc_target`": This is the checkout of the target\_url, where we replay
128 actions into and where we commit to the target repo. You can safely
129 remove this directory after a run, and the script will do a fresh
130 "svn checkout" (if needed) when starting the next time.
131 - "`_wc_target_tmp`": This is a temporary folder, which will only be created
132 if using `--keep-revnum` mode and it should only exist for brief periods
133 of time. This is where we commit dummy/padding revisions to the target repo,
134 checking out the root folder of the target repo and modifying a
135 "`svn2svn:keep-revnum`" property, i.e. a small change to trigger a commit
136 and in a location that will likely go un-noticed in the final target repo.
137
138 Examples
139 --------
140 **Create a copy of only /trunk from source repo, starting at r5000**
141
142 $ svnadmin create /svn/target
143 $ svn mkdir -m 'Add trunk' file:///svn/target/trunk
144 $ svn2svn -av -r 5000 http://server/source/trunk file:///svn/target/trunk
145
146 1. The `target_url` will be checked-out to `./_wc_target`.
147 2. The first commit to `http://server/source/trunk` at/after r5000 will be
148 exported & added into `_wc_target`.
149 3. All revisions affecting `http://server/source/trunk` (starting at r5000)
150 will be replayed to `_wc_target`. Any add/copy/move/replaces that are
151 copy-from'd some path outside of /trunk (e.g. files renamed on a
152 /branch and branch was merged into /trunk) will correctly maintain
153 logical ancestry where possible.
154
155 **Use continue-mode (-c) to pick-up where the last run left-off**
156
157 $ svn2svn -avc http://server/source/trunk file:///svn/target/trunk
158
159 1. The `target_url` will be checked-out to `./_wc_target`, if not already
160 checked-out
161 2. All new revisions affecting `http://server/source/trunk` starting from
162 the last replayed revision to `file:///svn/target/trunk` (based on the
163 "`svn2svn:*`" revprops) will be replayed to `_wc_target`, maintaining all
164 logical ancestry where possible.
165
166 Credits
167 -------
168 This project borrows a lot of code from the "hgsvn" project. Many thanks to
169 the folks who have contributed to the hgsvn project, for writing code that is
170 easily re-usable:
171
172 * [http://pypi.python.org/pypi/hgsvn](http://pypi.python.org/pypi/hgsvn)
173 * [https://bitbucket.org/andialbrecht/hgsvn/overview](https://bitbucket.org/andialbrecht/hgsvn/overview)
174
175 This project was originally inspired by this "svn2svn" project:
176 [http://code.google.com/p/svn2svn/](http://code.google.com/p/svn2svn/)
177 That project didn't fully meet my needs, so I forked and ended-up rewriting
178 the majority of the code.
179
180 Links
181 -----
182 * Introduction: "**[svn2svn: Replaying SVN History](http://nynim.org/blog/2012/02/01/svn2svn-replaying-svn-history/)**"
183 * Project page: [http://nynim.org/projects/svn2svn](http://nynim.org/projects/svn2svn)
184 * Source code @ Github: [https://github.com/tonyduckles/svn2svn](https://github.com/tonyduckles/svn2svn)
185 * Source code @ git.nynim.org [http://git.nynim.org/svn2svn.git](http://git.nynim.org/svn2svn.git)