comparison hgext/convert/__init__.py @ 9256:dd89dd090b47

convert: wrap docstrings at 70 characters
author Martin Geisler <mg@lazybytes.net>
date Sun, 26 Jul 2009 01:44:41 +0200
parents 9261667e9b82
children a15813fae0a8
comparison
equal deleted inserted replaced
9255:acfbb88c6ced 9256:dd89dd090b47
33 Accepted destination formats [identifiers]: 33 Accepted destination formats [identifiers]:
34 34
35 - Mercurial [hg] 35 - Mercurial [hg]
36 - Subversion [svn] (history on branches is not preserved) 36 - Subversion [svn] (history on branches is not preserved)
37 37
38 If no revision is given, all revisions will be converted. Otherwise, 38 If no revision is given, all revisions will be converted.
39 convert will only import up to the named revision (given in a format 39 Otherwise, convert will only import up to the named revision
40 understood by the source). 40 (given in a format understood by the source).
41 41
42 If no destination directory name is specified, it defaults to the basename 42 If no destination directory name is specified, it defaults to the
43 of the source with '-hg' appended. If the destination repository doesn't 43 basename of the source with '-hg' appended. If the destination
44 exist, it will be created. 44 repository doesn't exist, it will be created.
45 45
46 By default, all sources except Mercurial will use --branchsort. Mercurial 46 By default, all sources except Mercurial will use --branchsort.
47 uses --sourcesort to preserve original revision numbers order. Sort modes 47 Mercurial uses --sourcesort to preserve original revision numbers
48 have the following effects: 48 order. Sort modes have the following effects:
49 49
50 --branchsort convert from parent to child revision when possible, which 50 --branchsort convert from parent to child revision when possible,
51 means branches are usually converted one after the other. It 51 which means branches are usually converted one after
52 generates more compact repositories. 52 the other. It generates more compact repositories.
53 53
54 --datesort sort revisions by date. Converted repositories have 54 --datesort sort revisions by date. Converted repositories have
55 good-looking changelogs but are often an order of magnitude 55 good-looking changelogs but are often an order of
56 larger than the same ones generated by --branchsort. 56 magnitude larger than the same ones generated by
57 57 --branchsort.
58 --sourcesort try to preserve source revisions order, only supported by 58
59 Mercurial sources. 59 --sourcesort try to preserve source revisions order, only
60 supported by Mercurial sources.
60 61
61 If <REVMAP> isn't given, it will be put in a default location 62 If <REVMAP> isn't given, it will be put in a default location
62 (<dest>/.hg/shamap by default). The <REVMAP> is a simple text file that 63 (<dest>/.hg/shamap by default). The <REVMAP> is a simple text file
63 maps each source commit ID to the destination ID for that revision, like 64 that maps each source commit ID to the destination ID for that
64 so:: 65 revision, like so::
65 66
66 <source ID> <destination ID> 67 <source ID> <destination ID>
67 68
68 If the file doesn't exist, it's automatically created. It's updated on 69 If the file doesn't exist, it's automatically created. It's
69 each commit copied, so convert-repo can be interrupted and can be run 70 updated on each commit copied, so convert-repo can be interrupted
70 repeatedly to copy new commits. 71 and can be run repeatedly to copy new commits.
71 72
72 The [username mapping] file is a simple text file that maps each source 73 The [username mapping] file is a simple text file that maps each
73 commit author to a destination commit author. It is handy for source SCMs 74 source commit author to a destination commit author. It is handy
74 that use unix logins to identify authors (eg: CVS). One line per author 75 for source SCMs that use unix logins to identify authors (eg:
75 mapping and the line format is: srcauthor=whatever string you want 76 CVS). One line per author mapping and the line format is:
76 77 srcauthor=whatever string you want
77 The filemap is a file that allows filtering and remapping of files and 78
78 directories. Comment lines start with '#'. Each line can contain one of 79 The filemap is a file that allows filtering and remapping of files
79 the following directives:: 80 and directories. Comment lines start with '#'. Each line can
81 contain one of the following directives::
80 82
81 include path/to/file 83 include path/to/file
82 84
83 exclude path/to/file 85 exclude path/to/file
84 86
85 rename from/file to/file 87 rename from/file to/file
86 88
87 The 'include' directive causes a file, or all files under a directory, to 89 The 'include' directive causes a file, or all files under a
88 be included in the destination repository, and the exclusion of all other 90 directory, to be included in the destination repository, and the
89 files and directories not explicitly included. The 'exclude' directive 91 exclusion of all other files and directories not explicitly
90 causes files or directories to be omitted. The 'rename' directive renames 92 included. The 'exclude' directive causes files or directories to
91 a file or directory. To rename from a subdirectory into the root of the 93 be omitted. The 'rename' directive renames a file or directory. To
92 repository, use '.' as the path to rename to. 94 rename from a subdirectory into the root of the repository, use
93 95 '.' as the path to rename to.
94 The splicemap is a file that allows insertion of synthetic history, 96
95 letting you specify the parents of a revision. This is useful if you want 97 The splicemap is a file that allows insertion of synthetic
96 to e.g. give a Subversion merge two parents, or graft two disconnected 98 history, letting you specify the parents of a revision. This is
97 series of history together. Each entry contains a key, followed by a 99 useful if you want to e.g. give a Subversion merge two parents, or
98 space, followed by one or two comma-separated values. The key is the 100 graft two disconnected series of history together. Each entry
99 revision ID in the source revision control system whose parents should be 101 contains a key, followed by a space, followed by one or two
100 modified (same format as a key in .hg/shamap). The values are the revision 102 comma-separated values. The key is the revision ID in the source
101 IDs (in either the source or destination revision control system) that 103 revision control system whose parents should be modified (same
104 format as a key in .hg/shamap). The values are the revision IDs
105 (in either the source or destination revision control system) that
102 should be used as the new parents for that node. 106 should be used as the new parents for that node.
103 107
104 The branchmap is a file that allows you to rename a branch when it is 108 The branchmap is a file that allows you to rename a branch when it is
105 being brought in from whatever external repository. When used in 109 being brought in from whatever external repository. When used in
106 conjunction with a splicemap, it allows for a powerful combination to help 110 conjunction with a splicemap, it allows for a powerful combination
107 fix even the most badly mismanaged repositories and turn them into nicely 111 to help fix even the most badly mismanaged repositories and turn them
108 structured Mercurial repositories. The branchmap contains lines of the 112 into nicely structured Mercurial repositories. The branchmap contains
109 form "original_branch_name new_branch_name". "original_branch_name" is the 113 lines of the form "original_branch_name new_branch_name".
110 name of the branch in the source repository, and "new_branch_name" is the 114 "original_branch_name" is the name of the branch in the source
111 name of the branch is the destination repository. This can be used to (for 115 repository, and "new_branch_name" is the name of the branch is the
112 instance) move code in one repository from "default" to a named branch. 116 destination repository. This can be used to (for instance) move code
117 in one repository from "default" to a named branch.
113 118
114 Mercurial Source 119 Mercurial Source
115 ---------------- 120 ----------------
116 121
117 --config convert.hg.ignoreerrors=False (boolean) 122 --config convert.hg.ignoreerrors=False (boolean)
118 ignore integrity errors when reading. Use it to fix Mercurial 123 ignore integrity errors when reading. Use it to fix Mercurial
119 repositories with missing revlogs, by converting from and to 124 repositories with missing revlogs, by converting from and to
120 Mercurial. 125 Mercurial.
121 --config convert.hg.saverev=False (boolean) 126 --config convert.hg.saverev=False (boolean)
122 store original revision ID in changeset (forces target IDs to change) 127 store original revision ID in changeset (forces target IDs to
128 change)
123 --config convert.hg.startrev=0 (hg revision identifier) 129 --config convert.hg.startrev=0 (hg revision identifier)
124 convert start revision and its descendants 130 convert start revision and its descendants
125 131
126 CVS Source 132 CVS Source
127 ---------- 133 ----------
128 134
129 CVS source will use a sandbox (i.e. a checked-out copy) from CVS to 135 CVS source will use a sandbox (i.e. a checked-out copy) from CVS
130 indicate the starting point of what will be converted. Direct access to 136 to indicate the starting point of what will be converted. Direct
131 the repository files is not needed, unless of course the repository is 137 access to the repository files is not needed, unless of course the
132 :local:. The conversion uses the top level directory in the sandbox to 138 repository is :local:. The conversion uses the top level directory
133 find the CVS repository, and then uses CVS rlog commands to find files to 139 in the sandbox to find the CVS repository, and then uses CVS rlog
134 convert. This means that unless a filemap is given, all files under the 140 commands to find files to convert. This means that unless a
135 starting directory will be converted, and that any directory 141 filemap is given, all files under the starting directory will be
136 reorganization in the CVS sandbox is ignored. 142 converted, and that any directory reorganization in the CVS
143 sandbox is ignored.
137 144
138 Because CVS does not have changesets, it is necessary to collect 145 Because CVS does not have changesets, it is necessary to collect
139 individual commits to CVS and merge them into changesets. CVS source uses 146 individual commits to CVS and merge them into changesets. CVS
140 its internal changeset merging code by default but can be configured to 147 source uses its internal changeset merging code by default but can
141 call the external 'cvsps' program by setting:: 148 be configured to call the external 'cvsps' program by setting::
142 149
143 --config convert.cvsps='cvsps -A -u --cvs-direct -q' 150 --config convert.cvsps='cvsps -A -u --cvs-direct -q'
144 151
145 This option is deprecated and will be removed in Mercurial 1.4. 152 This option is deprecated and will be removed in Mercurial 1.4.
146 153
151 --config convert.cvsps=builtin 158 --config convert.cvsps=builtin
152 159
153 and has a few more configurable options: 160 and has a few more configurable options:
154 161
155 --config convert.cvsps.cache=True (boolean) 162 --config convert.cvsps.cache=True (boolean)
156 Set to False to disable remote log caching, for testing and debugging 163 Set to False to disable remote log caching, for testing and
157 purposes. 164 debugging purposes.
158 --config convert.cvsps.fuzz=60 (integer) 165 --config convert.cvsps.fuzz=60 (integer)
159 Specify the maximum time (in seconds) that is allowed between commits 166 Specify the maximum time (in seconds) that is allowed between
160 with identical user and log message in a single changeset. When very 167 commits with identical user and log message in a single
161 large files were checked in as part of a changeset then the default 168 changeset. When very large files were checked in as part of a
162 may not be long enough. 169 changeset then the default may not be long enough.
163 --config convert.cvsps.mergeto='{{mergetobranch ([-\\w]+)}}' 170 --config convert.cvsps.mergeto='{{mergetobranch ([-\\w]+)}}'
164 Specify a regular expression to which commit log messages are matched. 171 Specify a regular expression to which commit log messages are
165 If a match occurs, then the conversion process will insert a dummy 172 matched. If a match occurs, then the conversion process will
166 revision merging the branch on which this log message occurs to the 173 insert a dummy revision merging the branch on which this log
167 branch indicated in the regex. 174 message occurs to the branch indicated in the regex.
168 --config convert.cvsps.mergefrom='{{mergefrombranch ([-\\w]+)}}' 175 --config convert.cvsps.mergefrom='{{mergefrombranch ([-\\w]+)}}'
169 Specify a regular expression to which commit log messages are matched. 176 Specify a regular expression to which commit log messages are
170 If a match occurs, then the conversion process will add the most 177 matched. If a match occurs, then the conversion process will
171 recent revision on the branch indicated in the regex as the second 178 add the most recent revision on the branch indicated in the
172 parent of the changeset. 179 regex as the second parent of the changeset.
173 180
174 The hgext/convert/cvsps wrapper script allows the builtin changeset 181 The hgext/convert/cvsps wrapper script allows the builtin
175 merging code to be run without doing a conversion. Its parameters and 182 changeset merging code to be run without doing a conversion. Its
176 output are similar to that of cvsps 2.1. 183 parameters and output are similar to that of cvsps 2.1.
177 184
178 Subversion Source 185 Subversion Source
179 ----------------- 186 -----------------
180 187
181 Subversion source detects classical trunk/branches/tags layouts. By 188 Subversion source detects classical trunk/branches/tags layouts.
182 default, the supplied "svn://repo/path/" source URL is converted as a 189 By default, the supplied "svn://repo/path/" source URL is
183 single branch. If "svn://repo/path/trunk" exists it replaces the default 190 converted as a single branch. If "svn://repo/path/trunk" exists it
184 branch. If "svn://repo/path/branches" exists, its subdirectories are 191 replaces the default branch. If "svn://repo/path/branches" exists,
185 listed as possible branches. If "svn://repo/path/tags" exists, it is 192 its subdirectories are listed as possible branches. If
186 looked for tags referencing converted branches. Default "trunk", 193 "svn://repo/path/tags" exists, it is looked for tags referencing
187 "branches" and "tags" values can be overridden with following options. Set 194 converted branches. Default "trunk", "branches" and "tags" values
188 them to paths relative to the source URL, or leave them blank to disable 195 can be overridden with following options. Set them to paths
189 auto detection. 196 relative to the source URL, or leave them blank to disable auto
197 detection.
190 198
191 --config convert.svn.branches=branches (directory name) 199 --config convert.svn.branches=branches (directory name)
192 specify the directory containing branches 200 specify the directory containing branches
193 --config convert.svn.tags=tags (directory name) 201 --config convert.svn.tags=tags (directory name)
194 specify the directory containing tags 202 specify the directory containing tags
195 --config convert.svn.trunk=trunk (directory name) 203 --config convert.svn.trunk=trunk (directory name)
196 specify the name of the trunk branch 204 specify the name of the trunk branch
197 205
198 Source history can be retrieved starting at a specific revision, instead 206 Source history can be retrieved starting at a specific revision,
199 of being integrally converted. Only single branch conversions are 207 instead of being integrally converted. Only single branch
200 supported. 208 conversions are supported.
201 209
202 --config convert.svn.startrev=0 (svn revision number) 210 --config convert.svn.startrev=0 (svn revision number)
203 specify start Subversion revision. 211 specify start Subversion revision.
204 212
205 Perforce Source 213 Perforce Source
206 --------------- 214 ---------------
207 215
208 The Perforce (P4) importer can be given a p4 depot path or a client 216 The Perforce (P4) importer can be given a p4 depot path or a
209 specification as source. It will convert all files in the source to a flat 217 client specification as source. It will convert all files in the
210 Mercurial repository, ignoring labels, branches and integrations. Note 218 source to a flat Mercurial repository, ignoring labels, branches
211 that when a depot path is given you then usually should specify a target 219 and integrations. Note that when a depot path is given you then
212 directory, because otherwise the target may be named ...-hg. 220 usually should specify a target directory, because otherwise the
213 221 target may be named ...-hg.
214 It is possible to limit the amount of source history to be converted by 222
215 specifying an initial Perforce revision. 223 It is possible to limit the amount of source history to be
224 converted by specifying an initial Perforce revision.
216 225
217 --config convert.p4.startrev=0 (perforce changelist number) 226 --config convert.p4.startrev=0 (perforce changelist number)
218 specify initial Perforce revision. 227 specify initial Perforce revision.
219 228
220 Mercurial Destination 229 Mercurial Destination
234 return subversion.debugsvnlog(ui, **opts) 243 return subversion.debugsvnlog(ui, **opts)
235 244
236 def debugcvsps(ui, *args, **opts): 245 def debugcvsps(ui, *args, **opts):
237 '''create changeset information from CVS 246 '''create changeset information from CVS
238 247
239 This command is intended as a debugging tool for the CVS to Mercurial 248 This command is intended as a debugging tool for the CVS to
240 converter, and can be used as a direct replacement for cvsps. 249 Mercurial converter, and can be used as a direct replacement for
241 250 cvsps.
242 Hg debugcvsps reads the CVS rlog for current directory (or any named 251
243 directory) in the CVS repository, and converts the log to a series of 252 Hg debugcvsps reads the CVS rlog for current directory (or any
244 changesets based on matching commit log entries and dates. 253 named directory) in the CVS repository, and converts the log to a
245 ''' 254 series of changesets based on matching commit log entries and
255 dates.'''
246 return cvsps.debugcvsps(ui, *args, **opts) 256 return cvsps.debugcvsps(ui, *args, **opts)
247 257
248 commands.norepo += " convert debugsvnlog debugcvsps" 258 commands.norepo += " convert debugsvnlog debugcvsps"
249 259
250 cmdtable = { 260 cmdtable = {