Show More
@@ -1,41 +1,41 b'' | |||
|
1 | 1 | # Mercurial extension to provide the 'hg children' command |
|
2 | 2 | # |
|
3 | 3 | # Copyright 2007 by Intevation GmbH <intevation@intevation.de> |
|
4 | 4 | # Author(s): |
|
5 | 5 | # Thomas Arendsen Hein <thomas@intevation.de> |
|
6 | 6 | # |
|
7 | 7 | # This software may be used and distributed according to the terms |
|
8 | 8 | # of the GNU General Public License, incorporated herein by reference. |
|
9 | 9 | |
|
10 | 10 | from mercurial import cmdutil |
|
11 | 11 | from mercurial.commands import templateopts |
|
12 | 12 | from mercurial.i18n import _ |
|
13 | 13 | |
|
14 | 14 | |
|
15 | 15 | def children(ui, repo, file_=None, **opts): |
|
16 | """show the children of the given or working dir revision | |
|
16 | """show the children of the given or working directory revision | |
|
17 | 17 | |
|
18 | 18 | Print the children of the working directory's revisions. If a |
|
19 | 19 | revision is given via --rev, the children of that revision will be |
|
20 | 20 | printed. If a file argument is given, revision in which the file |
|
21 | 21 | was last changed (after the working directory revision or the |
|
22 | 22 | argument to --rev if given) is printed. |
|
23 | 23 | """ |
|
24 | 24 | rev = opts.get('rev') |
|
25 | 25 | if file_: |
|
26 | 26 | ctx = repo.filectx(file_, changeid=rev) |
|
27 | 27 | else: |
|
28 | 28 | ctx = repo[rev] |
|
29 | 29 | |
|
30 | 30 | displayer = cmdutil.show_changeset(ui, repo, opts) |
|
31 | 31 | for cctx in ctx.children(): |
|
32 | 32 | displayer.show(cctx) |
|
33 | 33 | |
|
34 | 34 | |
|
35 | 35 | cmdtable = { |
|
36 | 36 | "children": |
|
37 | 37 | (children, |
|
38 | 38 | [('r', 'rev', '', _('show children of the specified rev')), |
|
39 | 39 | ] + templateopts, |
|
40 | 40 | _('hg children [-r REV] [FILE]')), |
|
41 | 41 | } |
@@ -1,258 +1,258 b'' | |||
|
1 | 1 | # convert.py Foreign SCM converter |
|
2 | 2 | # |
|
3 | 3 | # Copyright 2005-2007 Matt Mackall <mpm@selenic.com> |
|
4 | 4 | # |
|
5 | 5 | # This software may be used and distributed according to the terms |
|
6 | 6 | # of the GNU General Public License, incorporated herein by reference. |
|
7 | 7 | '''converting foreign VCS repositories to Mercurial''' |
|
8 | 8 | |
|
9 | 9 | import convcmd |
|
10 | 10 | import cvsps |
|
11 | 11 | import subversion |
|
12 | 12 | from mercurial import commands |
|
13 | 13 | from mercurial.i18n import _ |
|
14 | 14 | |
|
15 | 15 | # Commands definition was moved elsewhere to ease demandload job. |
|
16 | 16 | |
|
17 | 17 | def convert(ui, src, dest=None, revmapfile=None, **opts): |
|
18 | 18 | """convert a foreign SCM repository to a Mercurial one. |
|
19 | 19 | |
|
20 | 20 | Accepted source formats [identifiers]: |
|
21 | 21 | - Mercurial [hg] |
|
22 | 22 | - CVS [cvs] |
|
23 | 23 | - Darcs [darcs] |
|
24 | 24 | - git [git] |
|
25 | 25 | - Subversion [svn] |
|
26 | 26 | - Monotone [mtn] |
|
27 | 27 | - GNU Arch [gnuarch] |
|
28 | 28 | - Bazaar [bzr] |
|
29 | 29 | - Perforce [p4] |
|
30 | 30 | |
|
31 | 31 | Accepted destination formats [identifiers]: |
|
32 | 32 | - Mercurial [hg] |
|
33 | 33 | - Subversion [svn] (history on branches is not preserved) |
|
34 | 34 | |
|
35 | 35 | If no revision is given, all revisions will be converted. |
|
36 | 36 | Otherwise, convert will only import up to the named revision |
|
37 | 37 | (given in a format understood by the source). |
|
38 | 38 | |
|
39 | 39 | If no destination directory name is specified, it defaults to the |
|
40 | 40 | basename of the source with '-hg' appended. If the destination |
|
41 | 41 | repository doesn't exist, it will be created. |
|
42 | 42 | |
|
43 | 43 | If <REVMAP> isn't given, it will be put in a default location |
|
44 | 44 | (<dest>/.hg/shamap by default). The <REVMAP> is a simple text file |
|
45 | 45 | that maps each source commit ID to the destination ID for that |
|
46 | 46 | revision, like so: |
|
47 | 47 | <source ID> <destination ID> |
|
48 | 48 | |
|
49 | 49 | If the file doesn't exist, it's automatically created. It's |
|
50 | 50 | updated on each commit copied, so convert-repo can be interrupted |
|
51 | 51 | and can be run repeatedly to copy new commits. |
|
52 | 52 | |
|
53 | 53 | The [username mapping] file is a simple text file that maps each |
|
54 | 54 | source commit author to a destination commit author. It is handy |
|
55 | 55 | for source SCMs that use unix logins to identify authors (eg: |
|
56 | 56 | CVS). One line per author mapping and the line format is: |
|
57 | 57 | srcauthor=whatever string you want |
|
58 | 58 | |
|
59 | 59 | The filemap is a file that allows filtering and remapping of files |
|
60 | 60 | and directories. Comment lines start with '#'. Each line can |
|
61 | 61 | contain one of the following directives: |
|
62 | 62 | |
|
63 | 63 | include path/to/file |
|
64 | 64 | |
|
65 | 65 | exclude path/to/file |
|
66 | 66 | |
|
67 | 67 | rename from/file to/file |
|
68 | 68 | |
|
69 | 69 | The 'include' directive causes a file, or all files under a |
|
70 | 70 | directory, to be included in the destination repository, and the |
|
71 | exclusion of all other files and dirs not explicitely included. | |
|
71 | exclusion of all other files and directories not explicitely included. | |
|
72 | 72 | The 'exclude' directive causes files or directories to be omitted. |
|
73 | 73 | The 'rename' directive renames a file or directory. To rename from |
|
74 | 74 | a subdirectory into the root of the repository, use '.' as the |
|
75 | 75 | path to rename to. |
|
76 | 76 | |
|
77 | 77 | The splicemap is a file that allows insertion of synthetic |
|
78 | 78 | history, letting you specify the parents of a revision. This is |
|
79 | 79 | useful if you want to e.g. give a Subversion merge two parents, or |
|
80 | 80 | graft two disconnected series of history together. Each entry |
|
81 | 81 | contains a key, followed by a space, followed by one or two |
|
82 | 82 | comma-separated values. The key is the revision ID in the source |
|
83 | 83 | revision control system whose parents should be modified (same |
|
84 | 84 | format as a key in .hg/shamap). The values are the revision IDs |
|
85 | 85 | (in either the source or destination revision control system) that |
|
86 | 86 | should be used as the new parents for that node. |
|
87 | 87 | |
|
88 | 88 | Mercurial Source |
|
89 | 89 | ----------------- |
|
90 | 90 | |
|
91 | 91 | --config convert.hg.ignoreerrors=False (boolean) |
|
92 | 92 | ignore integrity errors when reading. Use it to fix Mercurial |
|
93 | 93 | repositories with missing revlogs, by converting from and to |
|
94 | 94 | Mercurial. |
|
95 | 95 | --config convert.hg.saverev=False (boolean) |
|
96 | 96 | store original revision ID in changeset (forces target IDs to |
|
97 | 97 | change) |
|
98 | 98 | --config convert.hg.startrev=0 (hg revision identifier) |
|
99 | 99 | convert start revision and its descendants |
|
100 | 100 | |
|
101 | 101 | CVS Source |
|
102 | 102 | ---------- |
|
103 | 103 | |
|
104 | 104 | CVS source will use a sandbox (i.e. a checked-out copy) from CVS |
|
105 | 105 | to indicate the starting point of what will be converted. Direct |
|
106 | 106 | access to the repository files is not needed, unless of course the |
|
107 | 107 | repository is :local:. The conversion uses the top level directory |
|
108 | 108 | in the sandbox to find the CVS repository, and then uses CVS rlog |
|
109 | 109 | commands to find files to convert. This means that unless a |
|
110 | 110 | filemap is given, all files under the starting directory will be |
|
111 | 111 | converted, and that any directory reorganisation in the CVS |
|
112 | 112 | sandbox is ignored. |
|
113 | 113 | |
|
114 | 114 | Because CVS does not have changesets, it is necessary to collect |
|
115 | 115 | individual commits to CVS and merge them into changesets. CVS |
|
116 | 116 | source uses its internal changeset merging code by default but can |
|
117 | 117 | be configured to call the external 'cvsps' program by setting: |
|
118 | 118 | --config convert.cvsps='cvsps -A -u --cvs-direct -q' |
|
119 | 119 | This is a legacy option and may be removed in future. |
|
120 | 120 | |
|
121 | 121 | The options shown are the defaults. |
|
122 | 122 | |
|
123 | 123 | Internal cvsps is selected by setting |
|
124 | 124 | --config convert.cvsps=builtin |
|
125 | 125 | and has a few more configurable options: |
|
126 | 126 | --config convert.cvsps.fuzz=60 (integer) |
|
127 | 127 | Specify the maximum time (in seconds) that is allowed |
|
128 | 128 | between commits with identical user and log message in a |
|
129 | 129 | single changeset. When very large files were checked in as |
|
130 | 130 | part of a changeset then the default may not be long |
|
131 | 131 | enough. |
|
132 | 132 | --config convert.cvsps.mergeto='{{mergetobranch ([-\w]+)}}' |
|
133 | 133 | Specify a regular expression to which commit log messages |
|
134 | 134 | are matched. If a match occurs, then the conversion |
|
135 | 135 | process will insert a dummy revision merging the branch on |
|
136 | 136 | which this log message occurs to the branch indicated in |
|
137 | 137 | the regex. |
|
138 | 138 | --config convert.cvsps.mergefrom='{{mergefrombranch ([-\w]+)}}' |
|
139 | 139 | Specify a regular expression to which commit log messages |
|
140 | 140 | are matched. If a match occurs, then the conversion |
|
141 | 141 | process will add the most recent revision on the branch |
|
142 | 142 | indicated in the regex as the second parent of the |
|
143 | 143 | changeset. |
|
144 | 144 | |
|
145 | 145 | The hgext/convert/cvsps wrapper script allows the builtin |
|
146 | 146 | changeset merging code to be run without doing a conversion. Its |
|
147 | 147 | parameters and output are similar to that of cvsps 2.1. |
|
148 | 148 | |
|
149 | 149 | Subversion Source |
|
150 | 150 | ----------------- |
|
151 | 151 | |
|
152 | 152 | Subversion source detects classical trunk/branches/tags layouts. |
|
153 | 153 | By default, the supplied "svn://repo/path/" source URL is |
|
154 | 154 | converted as a single branch. If "svn://repo/path/trunk" exists it |
|
155 | 155 | replaces the default branch. If "svn://repo/path/branches" exists, |
|
156 | 156 | its subdirectories are listed as possible branches. If |
|
157 | 157 | "svn://repo/path/tags" exists, it is looked for tags referencing |
|
158 | 158 | converted branches. Default "trunk", "branches" and "tags" values |
|
159 | 159 | can be overriden with following options. Set them to paths |
|
160 | 160 | relative to the source URL, or leave them blank to disable |
|
161 | 161 | autodetection. |
|
162 | 162 | |
|
163 | 163 | --config convert.svn.branches=branches (directory name) |
|
164 | 164 | specify the directory containing branches |
|
165 | 165 | --config convert.svn.tags=tags (directory name) |
|
166 | 166 | specify the directory containing tags |
|
167 | 167 | --config convert.svn.trunk=trunk (directory name) |
|
168 | 168 | specify the name of the trunk branch |
|
169 | 169 | |
|
170 | 170 | Source history can be retrieved starting at a specific revision, |
|
171 | 171 | instead of being integrally converted. Only single branch |
|
172 | 172 | conversions are supported. |
|
173 | 173 | |
|
174 | 174 | --config convert.svn.startrev=0 (svn revision number) |
|
175 | 175 | specify start Subversion revision. |
|
176 | 176 | |
|
177 | 177 | Perforce Source |
|
178 | 178 | --------------- |
|
179 | 179 | |
|
180 | 180 | The Perforce (P4) importer can be given a p4 depot path or a |
|
181 | 181 | client specification as source. It will convert all files in the |
|
182 | 182 | source to a flat Mercurial repository, ignoring labels, branches |
|
183 | 183 | and integrations. Note that when a depot path is given you then |
|
184 | 184 | usually should specify a target directory, because otherwise the |
|
185 | 185 | target may be named ...-hg. |
|
186 | 186 | |
|
187 | 187 | It is possible to limit the amount of source history to be |
|
188 | 188 | converted by specifying an initial Perforce revision. |
|
189 | 189 | |
|
190 | 190 | --config convert.p4.startrev=0 (perforce changelist number) |
|
191 | 191 | specify initial Perforce revision. |
|
192 | 192 | |
|
193 | 193 | |
|
194 | 194 | Mercurial Destination |
|
195 | 195 | --------------------- |
|
196 | 196 | |
|
197 | 197 | --config convert.hg.clonebranches=False (boolean) |
|
198 | 198 | dispatch source branches in separate clones. |
|
199 | 199 | --config convert.hg.tagsbranch=default (branch name) |
|
200 | 200 | tag revisions branch name |
|
201 | 201 | --config convert.hg.usebranchnames=True (boolean) |
|
202 | 202 | preserve branch names |
|
203 | 203 | |
|
204 | 204 | """ |
|
205 | 205 | return convcmd.convert(ui, src, dest, revmapfile, **opts) |
|
206 | 206 | |
|
207 | 207 | def debugsvnlog(ui, **opts): |
|
208 | 208 | return subversion.debugsvnlog(ui, **opts) |
|
209 | 209 | |
|
210 | 210 | def debugcvsps(ui, *args, **opts): |
|
211 | 211 | '''create changeset information from CVS |
|
212 | 212 | |
|
213 | 213 | This command is intended as a debugging tool for the CVS to |
|
214 | 214 | Mercurial converter, and can be used as a direct replacement for |
|
215 | 215 | cvsps. |
|
216 | 216 | |
|
217 | 217 | Hg debugcvsps reads the CVS rlog for current directory (or any |
|
218 | 218 | named directory) in the CVS repository, and converts the log to a |
|
219 | 219 | series of changesets based on matching commit log entries and |
|
220 | 220 | dates.''' |
|
221 | 221 | return cvsps.debugcvsps(ui, *args, **opts) |
|
222 | 222 | |
|
223 | 223 | commands.norepo += " convert debugsvnlog debugcvsps" |
|
224 | 224 | |
|
225 | 225 | cmdtable = { |
|
226 | 226 | "convert": |
|
227 | 227 | (convert, |
|
228 | 228 | [('A', 'authors', '', _('username mapping filename')), |
|
229 | 229 | ('d', 'dest-type', '', _('destination repository type')), |
|
230 | 230 | ('', 'filemap', '', _('remap file names using contents of file')), |
|
231 | 231 | ('r', 'rev', '', _('import up to target revision REV')), |
|
232 | 232 | ('s', 'source-type', '', _('source repository type')), |
|
233 | 233 | ('', 'splicemap', '', _('splice synthesized history into place')), |
|
234 | 234 | ('', 'datesort', None, _('try to sort changesets by date'))], |
|
235 | 235 | _('hg convert [OPTION]... SOURCE [DEST [REVMAP]]')), |
|
236 | 236 | "debugsvnlog": |
|
237 | 237 | (debugsvnlog, |
|
238 | 238 | [], |
|
239 | 239 | 'hg debugsvnlog'), |
|
240 | 240 | "debugcvsps": |
|
241 | 241 | (debugcvsps, |
|
242 | 242 | [ |
|
243 | 243 | # Main options shared with cvsps-2.1 |
|
244 | 244 | ('b', 'branches', [], _('only return changes on specified branches')), |
|
245 | 245 | ('p', 'prefix', '', _('prefix to remove from file names')), |
|
246 | 246 | ('r', 'revisions', [], _('only return changes after or between specified tags')), |
|
247 | 247 | ('u', 'update-cache', None, _("update cvs log cache")), |
|
248 | 248 | ('x', 'new-cache', None, _("create new cvs log cache")), |
|
249 | 249 | ('z', 'fuzz', 60, _('set commit time fuzz in seconds')), |
|
250 | 250 | ('', 'root', '', _('specify cvsroot')), |
|
251 | 251 | # Options specific to builtin cvsps |
|
252 | 252 | ('', 'parents', '', _('show parent changesets')), |
|
253 | 253 | ('', 'ancestors', '', _('show current changeset in ancestor branches')), |
|
254 | 254 | # Options that are ignored for compatibility with cvsps-2.1 |
|
255 | 255 | ('A', 'cvs-direct', None, _('ignored for compatibility')), |
|
256 | 256 | ], |
|
257 | 257 | _('hg debugcvsps [OPTION]... [PATH]...')), |
|
258 | 258 | } |
@@ -1,200 +1,202 b'' | |||
|
1 | 1 | # monotone support for the convert extension |
|
2 | 2 | |
|
3 | 3 | import os, re |
|
4 | 4 | from mercurial import util |
|
5 | 5 | from common import NoRepo, commit, converter_source, checktool |
|
6 | 6 | from common import commandline |
|
7 | 7 | from mercurial.i18n import _ |
|
8 | 8 | |
|
9 | 9 | class monotone_source(converter_source, commandline): |
|
10 | 10 | def __init__(self, ui, path=None, rev=None): |
|
11 | 11 | converter_source.__init__(self, ui, path, rev) |
|
12 | 12 | commandline.__init__(self, ui, 'mtn') |
|
13 | 13 | |
|
14 | 14 | self.ui = ui |
|
15 | 15 | self.path = path |
|
16 | 16 | |
|
17 | 17 | norepo = NoRepo (_("%s does not look like a monotone repo") % path) |
|
18 | 18 | if not os.path.exists(os.path.join(path, '_MTN')): |
|
19 | 19 | raise norepo |
|
20 | 20 | |
|
21 | 21 | # regular expressions for parsing monotone output |
|
22 | 22 | space = r'\s*' |
|
23 | 23 | name = r'\s+"((?:\\"|[^"])*)"\s*' |
|
24 | 24 | value = name |
|
25 | 25 | revision = r'\s+\[(\w+)\]\s*' |
|
26 | 26 | lines = r'(?:.|\n)+' |
|
27 | 27 | |
|
28 | 28 | self.dir_re = re.compile(space + "dir" + name) |
|
29 | 29 | self.file_re = re.compile(space + "file" + name + "content" + revision) |
|
30 | 30 | self.add_file_re = re.compile(space + "add_file" + name + "content" + revision) |
|
31 | 31 | self.patch_re = re.compile(space + "patch" + name + "from" + revision + "to" + revision) |
|
32 | 32 | self.rename_re = re.compile(space + "rename" + name + "to" + name) |
|
33 | 33 | self.delete_re = re.compile(space + "delete" + name) |
|
34 | 34 | self.tag_re = re.compile(space + "tag" + name + "revision" + revision) |
|
35 | 35 | self.cert_re = re.compile(lines + space + "name" + name + "value" + value) |
|
36 | 36 | |
|
37 | 37 | attr = space + "file" + lines + space + "attr" + space |
|
38 | 38 | self.attr_execute_re = re.compile(attr + '"mtn:execute"' + space + '"true"') |
|
39 | 39 | |
|
40 | 40 | # cached data |
|
41 | 41 | self.manifest_rev = None |
|
42 | 42 | self.manifest = None |
|
43 | 43 | self.files = None |
|
44 | 44 | self.dirs = None |
|
45 | 45 | |
|
46 | 46 | checktool('mtn', abort=False) |
|
47 | 47 | |
|
48 | 48 | # test if there are any revisions |
|
49 | 49 | self.rev = None |
|
50 | 50 | try: |
|
51 | 51 | self.getheads() |
|
52 | 52 | except: |
|
53 | 53 | raise norepo |
|
54 | 54 | self.rev = rev |
|
55 | 55 | |
|
56 | 56 | def mtnrun(self, *args, **kwargs): |
|
57 | 57 | kwargs['d'] = self.path |
|
58 | 58 | return self.run0('automate', *args, **kwargs) |
|
59 | 59 | |
|
60 | 60 | def mtnloadmanifest(self, rev): |
|
61 | 61 | if self.manifest_rev == rev: |
|
62 | 62 | return |
|
63 | 63 | self.manifest = self.mtnrun("get_manifest_of", rev).split("\n\n") |
|
64 | 64 | self.manifest_rev = rev |
|
65 | 65 | self.files = {} |
|
66 | 66 | self.dirs = {} |
|
67 | 67 | |
|
68 | 68 | for e in self.manifest: |
|
69 | 69 | m = self.file_re.match(e) |
|
70 | 70 | if m: |
|
71 | 71 | attr = "" |
|
72 | 72 | name = m.group(1) |
|
73 | 73 | node = m.group(2) |
|
74 | 74 | if self.attr_execute_re.match(e): |
|
75 | 75 | attr += "x" |
|
76 | 76 | self.files[name] = (node, attr) |
|
77 | 77 | m = self.dir_re.match(e) |
|
78 | 78 | if m: |
|
79 | 79 | self.dirs[m.group(1)] = True |
|
80 | 80 | |
|
81 | 81 | def mtnisfile(self, name, rev): |
|
82 | 82 | # a non-file could be a directory or a deleted or renamed file |
|
83 | 83 | self.mtnloadmanifest(rev) |
|
84 | 84 | try: |
|
85 | 85 | self.files[name] |
|
86 | 86 | return True |
|
87 | 87 | except KeyError: |
|
88 | 88 | return False |
|
89 | 89 | |
|
90 | 90 | def mtnisdir(self, name, rev): |
|
91 | 91 | self.mtnloadmanifest(rev) |
|
92 | 92 | try: |
|
93 | 93 | self.dirs[name] |
|
94 | 94 | return True |
|
95 | 95 | except KeyError: |
|
96 | 96 | return False |
|
97 | 97 | |
|
98 | 98 | def mtngetcerts(self, rev): |
|
99 | 99 | certs = {"author":"<missing>", "date":"<missing>", |
|
100 | 100 | "changelog":"<missing>", "branch":"<missing>"} |
|
101 | 101 | cert_list = self.mtnrun("certs", rev).split('\n\n key "') |
|
102 | 102 | for e in cert_list: |
|
103 | 103 | m = self.cert_re.match(e) |
|
104 | 104 | if m: |
|
105 | 105 | name, value = m.groups() |
|
106 | 106 | value = value.replace(r'\"', '"') |
|
107 | 107 | value = value.replace(r'\\', '\\') |
|
108 | 108 | certs[name] = value |
|
109 | 109 | return certs |
|
110 | 110 | |
|
111 | 111 | def mtnrenamefiles(self, files, fromdir, todir): |
|
112 | 112 | renamed = {} |
|
113 | 113 | for tofile in files: |
|
114 | 114 | if tofile.startswith(todir): |
|
115 | 115 | renamed[tofile] = fromdir + tofile[len(todir):] |
|
116 | 116 | return renamed |
|
117 | 117 | |
|
118 | 118 | |
|
119 | 119 | # implement the converter_source interface: |
|
120 | 120 | |
|
121 | 121 | def getheads(self): |
|
122 | 122 | if not self.rev: |
|
123 | 123 | return self.mtnrun("leaves").splitlines() |
|
124 | 124 | else: |
|
125 | 125 | return [self.rev] |
|
126 | 126 | |
|
127 | 127 | def getchanges(self, rev): |
|
128 | 128 | #revision = self.mtncmd("get_revision %s" % rev).split("\n\n") |
|
129 | 129 | revision = self.mtnrun("get_revision", rev).split("\n\n") |
|
130 | 130 | files = {} |
|
131 | 131 | copies = {} |
|
132 | 132 | for e in revision: |
|
133 | 133 | m = self.add_file_re.match(e) |
|
134 | 134 | if m: |
|
135 | 135 | files[m.group(1)] = rev |
|
136 | 136 | m = self.patch_re.match(e) |
|
137 | 137 | if m: |
|
138 | 138 | files[m.group(1)] = rev |
|
139 | 139 | |
|
140 | 140 | # Delete/rename is handled later when the convert engine |
|
141 | 141 | # discovers an IOError exception from getfile, |
|
142 | 142 | # but only if we add the "from" file to the list of changes. |
|
143 | 143 | m = self.delete_re.match(e) |
|
144 | 144 | if m: |
|
145 | 145 | files[m.group(1)] = rev |
|
146 | 146 | m = self.rename_re.match(e) |
|
147 | 147 | if m: |
|
148 | 148 | toname = m.group(2) |
|
149 | 149 | fromname = m.group(1) |
|
150 | 150 | if self.mtnisfile(toname, rev): |
|
151 | 151 | copies[toname] = fromname |
|
152 | 152 | files[toname] = rev |
|
153 | 153 | files[fromname] = rev |
|
154 | 154 | if self.mtnisdir(toname, rev): |
|
155 | 155 | renamed = self.mtnrenamefiles(self.files, fromname, toname) |
|
156 | 156 | for tofile, fromfile in renamed.items(): |
|
157 |
self.ui.debug (_("copying file in renamed dir |
|
|
157 | self.ui.debug (_("copying file in renamed directory " | |
|
158 | "from '%s' to '%s'") | |
|
159 | % (fromfile, tofile), '\n') | |
|
158 | 160 | files[tofile] = rev |
|
159 | 161 | for fromfile in renamed.values(): |
|
160 | 162 | files[fromfile] = rev |
|
161 | 163 | return (files.items(), copies) |
|
162 | 164 | |
|
163 | 165 | def getmode(self, name, rev): |
|
164 | 166 | self.mtnloadmanifest(rev) |
|
165 | 167 | try: |
|
166 | 168 | node, attr = self.files[name] |
|
167 | 169 | return attr |
|
168 | 170 | except KeyError: |
|
169 | 171 | return "" |
|
170 | 172 | |
|
171 | 173 | def getfile(self, name, rev): |
|
172 | 174 | if not self.mtnisfile(name, rev): |
|
173 | 175 | raise IOError() # file was deleted or renamed |
|
174 | 176 | try: |
|
175 | 177 | return self.mtnrun("get_file_of", name, r=rev) |
|
176 | 178 | except: |
|
177 | 179 | raise IOError() # file was deleted or renamed |
|
178 | 180 | |
|
179 | 181 | def getcommit(self, rev): |
|
180 | 182 | certs = self.mtngetcerts(rev) |
|
181 | 183 | return commit( |
|
182 | 184 | author=certs["author"], |
|
183 | 185 | date=util.datestr(util.strdate(certs["date"], "%Y-%m-%dT%H:%M:%S")), |
|
184 | 186 | desc=certs["changelog"], |
|
185 | 187 | rev=rev, |
|
186 | 188 | parents=self.mtnrun("parents", rev).splitlines(), |
|
187 | 189 | branch=certs["branch"]) |
|
188 | 190 | |
|
189 | 191 | def gettags(self): |
|
190 | 192 | tags = {} |
|
191 | 193 | for e in self.mtnrun("tags").split("\n\n"): |
|
192 | 194 | m = self.tag_re.match(e) |
|
193 | 195 | if m: |
|
194 | 196 | tags[m.group(1)] = m.group(2) |
|
195 | 197 | return tags |
|
196 | 198 | |
|
197 | 199 | def getchangedfiles(self, rev, i): |
|
198 | 200 | # This function is only needed to support --filemap |
|
199 | 201 | # ... and we don't support that |
|
200 | 202 | raise NotImplementedError() |
@@ -1,260 +1,260 b'' | |||
|
1 | 1 | # extdiff.py - external diff program support for mercurial |
|
2 | 2 | # |
|
3 | 3 | # Copyright 2006 Vadim Gelfer <vadim.gelfer@gmail.com> |
|
4 | 4 | # |
|
5 | 5 | # This software may be used and distributed according to the terms |
|
6 | 6 | # of the GNU General Public License, incorporated herein by reference. |
|
7 | 7 | |
|
8 | 8 | ''' |
|
9 | 9 | The `extdiff' Mercurial extension allows you to use external programs |
|
10 | to compare revisions, or revision with working dir. The external diff | |
|
10 | to compare revisions, or revision with working directory. The external diff | |
|
11 | 11 | programs are called with a configurable set of options and two |
|
12 | 12 | non-option arguments: paths to directories containing snapshots of |
|
13 | 13 | files to compare. |
|
14 | 14 | |
|
15 | 15 | To enable this extension: |
|
16 | 16 | |
|
17 | 17 | [extensions] |
|
18 | 18 | hgext.extdiff = |
|
19 | 19 | |
|
20 | 20 | The `extdiff' extension also allows to configure new diff commands, so |
|
21 | 21 | you do not need to type "hg extdiff -p kdiff3" always. |
|
22 | 22 | |
|
23 | 23 | [extdiff] |
|
24 | 24 | # add new command that runs GNU diff(1) in 'context diff' mode |
|
25 | 25 | cdiff = gdiff -Nprc5 |
|
26 | 26 | ## or the old way: |
|
27 | 27 | #cmd.cdiff = gdiff |
|
28 | 28 | #opts.cdiff = -Nprc5 |
|
29 | 29 | |
|
30 | 30 | # add new command called vdiff, runs kdiff3 |
|
31 | 31 | vdiff = kdiff3 |
|
32 | 32 | |
|
33 | 33 | # add new command called meld, runs meld (no need to name twice) |
|
34 | 34 | meld = |
|
35 | 35 | |
|
36 | 36 | # add new command called vimdiff, runs gvimdiff with DirDiff plugin |
|
37 | 37 | # (see http://www.vim.org/scripts/script.php?script_id=102) |
|
38 | 38 | # Non english user, be sure to put "let g:DirDiffDynamicDiffText = 1" in |
|
39 | 39 | # your .vimrc |
|
40 | 40 | vimdiff = gvim -f '+next' '+execute "DirDiff" argv(0) argv(1)' |
|
41 | 41 | |
|
42 | 42 | You can use -I/-X and list of file or directory names like normal "hg |
|
43 | 43 | diff" command. The `extdiff' extension makes snapshots of only needed |
|
44 | 44 | files, so running the external diff program will actually be pretty |
|
45 | 45 | fast (at least faster than having to compare the entire tree). |
|
46 | 46 | ''' |
|
47 | 47 | |
|
48 | 48 | from mercurial.i18n import _ |
|
49 | 49 | from mercurial.node import short |
|
50 | 50 | from mercurial import cmdutil, util, commands |
|
51 | 51 | import os, shlex, shutil, tempfile |
|
52 | 52 | |
|
53 | 53 | def snapshot_node(ui, repo, files, node, tmproot): |
|
54 | 54 | '''snapshot files as of some revision''' |
|
55 | 55 | dirname = os.path.basename(repo.root) |
|
56 | 56 | if dirname == "": |
|
57 | 57 | dirname = "root" |
|
58 | 58 | dirname = '%s.%s' % (dirname, short(node)) |
|
59 | 59 | base = os.path.join(tmproot, dirname) |
|
60 | 60 | os.mkdir(base) |
|
61 | 61 | ui.note(_('making snapshot of %d files from rev %s\n') % |
|
62 | 62 | (len(files), short(node))) |
|
63 | 63 | ctx = repo[node] |
|
64 | 64 | for fn in files: |
|
65 | 65 | wfn = util.pconvert(fn) |
|
66 | 66 | if not wfn in ctx: |
|
67 | 67 | # skipping new file after a merge ? |
|
68 | 68 | continue |
|
69 | 69 | ui.note(' %s\n' % wfn) |
|
70 | 70 | dest = os.path.join(base, wfn) |
|
71 | 71 | destdir = os.path.dirname(dest) |
|
72 | 72 | if not os.path.isdir(destdir): |
|
73 | 73 | os.makedirs(destdir) |
|
74 | 74 | data = repo.wwritedata(wfn, ctx[wfn].data()) |
|
75 | 75 | open(dest, 'wb').write(data) |
|
76 | 76 | return dirname |
|
77 | 77 | |
|
78 | 78 | |
|
79 | 79 | def snapshot_wdir(ui, repo, files, tmproot): |
|
80 | 80 | '''snapshot files from working directory. |
|
81 | 81 | if not using snapshot, -I/-X does not work and recursive diff |
|
82 | 82 | in tools like kdiff3 and meld displays too many files.''' |
|
83 | 83 | dirname = os.path.basename(repo.root) |
|
84 | 84 | if dirname == "": |
|
85 | 85 | dirname = "root" |
|
86 | 86 | base = os.path.join(tmproot, dirname) |
|
87 | 87 | os.mkdir(base) |
|
88 | ui.note(_('making snapshot of %d files from working dir\n') % | |
|
88 | ui.note(_('making snapshot of %d files from working directory\n') % | |
|
89 | 89 | (len(files))) |
|
90 | 90 | |
|
91 | 91 | fns_and_mtime = [] |
|
92 | 92 | |
|
93 | 93 | for fn in files: |
|
94 | 94 | wfn = util.pconvert(fn) |
|
95 | 95 | ui.note(' %s\n' % wfn) |
|
96 | 96 | dest = os.path.join(base, wfn) |
|
97 | 97 | destdir = os.path.dirname(dest) |
|
98 | 98 | if not os.path.isdir(destdir): |
|
99 | 99 | os.makedirs(destdir) |
|
100 | 100 | |
|
101 | 101 | fp = open(dest, 'wb') |
|
102 | 102 | for chunk in util.filechunkiter(repo.wopener(wfn)): |
|
103 | 103 | fp.write(chunk) |
|
104 | 104 | fp.close() |
|
105 | 105 | |
|
106 | 106 | fns_and_mtime.append((dest, repo.wjoin(fn), os.path.getmtime(dest))) |
|
107 | 107 | |
|
108 | 108 | |
|
109 | 109 | return dirname, fns_and_mtime |
|
110 | 110 | |
|
111 | 111 | |
|
112 | 112 | def dodiff(ui, repo, diffcmd, diffopts, pats, opts): |
|
113 | 113 | '''Do the actuall diff: |
|
114 | 114 | |
|
115 | 115 | - copy to a temp structure if diffing 2 internal revisions |
|
116 | 116 | - copy to a temp structure if diffing working revision with |
|
117 | 117 | another one and more than 1 file is changed |
|
118 | 118 | - just invoke the diff for a single file in the working dir |
|
119 | 119 | ''' |
|
120 | 120 | |
|
121 | 121 | revs = opts.get('rev') |
|
122 | 122 | change = opts.get('change') |
|
123 | 123 | |
|
124 | 124 | if revs and change: |
|
125 | 125 | msg = _('cannot specify --rev and --change at the same time') |
|
126 | 126 | raise util.Abort(msg) |
|
127 | 127 | elif change: |
|
128 | 128 | node2 = repo.lookup(change) |
|
129 | 129 | node1 = repo[node2].parents()[0].node() |
|
130 | 130 | else: |
|
131 | 131 | node1, node2 = cmdutil.revpair(repo, revs) |
|
132 | 132 | |
|
133 | 133 | matcher = cmdutil.match(repo, pats, opts) |
|
134 | 134 | modified, added, removed = repo.status(node1, node2, matcher)[:3] |
|
135 | 135 | if not (modified or added or removed): |
|
136 | 136 | return 0 |
|
137 | 137 | |
|
138 | 138 | tmproot = tempfile.mkdtemp(prefix='extdiff.') |
|
139 | 139 | dir2root = '' |
|
140 | 140 | try: |
|
141 | 141 | # Always make a copy of node1 |
|
142 | 142 | dir1 = snapshot_node(ui, repo, modified + removed, node1, tmproot) |
|
143 | 143 | changes = len(modified) + len(removed) + len(added) |
|
144 | 144 | |
|
145 | 145 | fns_and_mtime = [] |
|
146 | 146 | |
|
147 | 147 | # If node2 in not the wc or there is >1 change, copy it |
|
148 | 148 | if node2: |
|
149 | 149 | dir2 = snapshot_node(ui, repo, modified + added, node2, tmproot) |
|
150 | 150 | elif changes > 1: |
|
151 | 151 | #we only actually need to get the files to copy back to the working |
|
152 | 152 | #dir in this case (because the other cases are: diffing 2 revisions |
|
153 | 153 | #or single file -- in which case the file is already directly passed |
|
154 | 154 | #to the diff tool). |
|
155 | 155 | dir2, fns_and_mtime = snapshot_wdir(ui, repo, modified + added, tmproot) |
|
156 | 156 | else: |
|
157 | 157 | # This lets the diff tool open the changed file directly |
|
158 | 158 | dir2 = '' |
|
159 | 159 | dir2root = repo.root |
|
160 | 160 | |
|
161 | 161 | # If only one change, diff the files instead of the directories |
|
162 | 162 | if changes == 1 : |
|
163 | 163 | if len(modified): |
|
164 | 164 | dir1 = os.path.join(dir1, util.localpath(modified[0])) |
|
165 | 165 | dir2 = os.path.join(dir2root, dir2, util.localpath(modified[0])) |
|
166 | 166 | elif len(removed) : |
|
167 | 167 | dir1 = os.path.join(dir1, util.localpath(removed[0])) |
|
168 | 168 | dir2 = os.devnull |
|
169 | 169 | else: |
|
170 | 170 | dir1 = os.devnull |
|
171 | 171 | dir2 = os.path.join(dir2root, dir2, util.localpath(added[0])) |
|
172 | 172 | |
|
173 | 173 | cmdline = ('%s %s %s %s' % |
|
174 | 174 | (util.shellquote(diffcmd), ' '.join(diffopts), |
|
175 | 175 | util.shellquote(dir1), util.shellquote(dir2))) |
|
176 | 176 | ui.debug(_('running %r in %s\n') % (cmdline, tmproot)) |
|
177 | 177 | util.system(cmdline, cwd=tmproot) |
|
178 | 178 | |
|
179 | 179 | for copy_fn, working_fn, mtime in fns_and_mtime: |
|
180 | 180 | if os.path.getmtime(copy_fn) != mtime: |
|
181 | 181 | ui.debug(_('file changed while diffing. ' |
|
182 | 182 | 'Overwriting: %s (src: %s)\n') % (working_fn, copy_fn)) |
|
183 | 183 | util.copyfile(copy_fn, working_fn) |
|
184 | 184 | |
|
185 | 185 | return 1 |
|
186 | 186 | finally: |
|
187 | 187 | ui.note(_('cleaning up temp directory\n')) |
|
188 | 188 | shutil.rmtree(tmproot) |
|
189 | 189 | |
|
190 | 190 | def extdiff(ui, repo, *pats, **opts): |
|
191 | 191 | '''use external program to diff repository (or selected files) |
|
192 | 192 | |
|
193 | 193 | Show differences between revisions for the specified files, using |
|
194 | 194 | an external program. The default program used is diff, with |
|
195 | 195 | default options "-Npru". |
|
196 | 196 | |
|
197 | 197 | To select a different program, use the -p option. The program will |
|
198 | 198 | be passed the names of two directories to compare. To pass |
|
199 | 199 | additional options to the program, use the -o option. These will |
|
200 | 200 | be passed before the names of the directories to compare. |
|
201 | 201 | |
|
202 | 202 | When two revision arguments are given, then changes are shown |
|
203 | 203 | between those revisions. If only one revision is specified then |
|
204 | 204 | that revision is compared to the working directory, and, when no |
|
205 | 205 | revisions are specified, the working directory files are compared |
|
206 | 206 | to its parent.''' |
|
207 | 207 | program = opts['program'] or 'diff' |
|
208 | 208 | if opts['program']: |
|
209 | 209 | option = opts['option'] |
|
210 | 210 | else: |
|
211 | 211 | option = opts['option'] or ['-Npru'] |
|
212 | 212 | return dodiff(ui, repo, program, option, pats, opts) |
|
213 | 213 | |
|
214 | 214 | cmdtable = { |
|
215 | 215 | "extdiff": |
|
216 | 216 | (extdiff, |
|
217 | 217 | [('p', 'program', '', _('comparison program to run')), |
|
218 | 218 | ('o', 'option', [], _('pass option to comparison program')), |
|
219 | 219 | ('r', 'rev', [], _('revision')), |
|
220 | 220 | ('c', 'change', '', _('change made by revision')), |
|
221 | 221 | ] + commands.walkopts, |
|
222 | 222 | _('hg extdiff [OPT]... [FILE]...')), |
|
223 | 223 | } |
|
224 | 224 | |
|
225 | 225 | def uisetup(ui): |
|
226 | 226 | for cmd, path in ui.configitems('extdiff'): |
|
227 | 227 | if cmd.startswith('cmd.'): |
|
228 | 228 | cmd = cmd[4:] |
|
229 | 229 | if not path: path = cmd |
|
230 | 230 | diffopts = ui.config('extdiff', 'opts.' + cmd, '') |
|
231 | 231 | diffopts = diffopts and [diffopts] or [] |
|
232 | 232 | elif cmd.startswith('opts.'): |
|
233 | 233 | continue |
|
234 | 234 | else: |
|
235 | 235 | # command = path opts |
|
236 | 236 | if path: |
|
237 | 237 | diffopts = shlex.split(path) |
|
238 | 238 | path = diffopts.pop(0) |
|
239 | 239 | else: |
|
240 | 240 | path, diffopts = cmd, [] |
|
241 | 241 | def save(cmd, path, diffopts): |
|
242 | 242 | '''use closure to save diff command to use''' |
|
243 | 243 | def mydiff(ui, repo, *pats, **opts): |
|
244 | 244 | return dodiff(ui, repo, path, diffopts, pats, opts) |
|
245 | 245 | mydiff.__doc__ = '''use %(path)s to diff repository (or selected files) |
|
246 | 246 | |
|
247 | 247 | Show differences between revisions for the specified |
|
248 | 248 | files, using the %(path)s program. |
|
249 | 249 | |
|
250 | 250 | When two revision arguments are given, then changes are |
|
251 | 251 | shown between those revisions. If only one revision is |
|
252 | 252 | specified then that revision is compared to the working |
|
253 | 253 | directory, and, when no revisions are specified, the |
|
254 | 254 | working directory files are compared to its parent.''' % { |
|
255 | 255 | 'path': util.uirepr(path), |
|
256 | 256 | } |
|
257 | 257 | return mydiff |
|
258 | 258 | cmdtable[cmd] = (save(cmd, path, diffopts), |
|
259 | 259 | cmdtable['extdiff'][1][1:], |
|
260 | 260 | _('hg %s [OPTION]... [FILE]...') % cmd) |
@@ -1,2603 +1,2603 b'' | |||
|
1 | 1 | # mq.py - patch queues for mercurial |
|
2 | 2 | # |
|
3 | 3 | # Copyright 2005, 2006 Chris Mason <mason@suse.com> |
|
4 | 4 | # |
|
5 | 5 | # This software may be used and distributed according to the terms |
|
6 | 6 | # of the GNU General Public License, incorporated herein by reference. |
|
7 | 7 | |
|
8 | 8 | '''patch management and development |
|
9 | 9 | |
|
10 | 10 | This extension lets you work with a stack of patches in a Mercurial |
|
11 | 11 | repository. It manages two stacks of patches - all known patches, and |
|
12 | 12 | applied patches (subset of known patches). |
|
13 | 13 | |
|
14 | 14 | Known patches are represented as patch files in the .hg/patches |
|
15 | 15 | directory. Applied patches are both patch files and changesets. |
|
16 | 16 | |
|
17 | 17 | Common tasks (use "hg help command" for more details): |
|
18 | 18 | |
|
19 | 19 | prepare repository to work with patches qinit |
|
20 | 20 | create new patch qnew |
|
21 | 21 | import existing patch qimport |
|
22 | 22 | |
|
23 | 23 | print patch series qseries |
|
24 | 24 | print applied patches qapplied |
|
25 | 25 | print name of top applied patch qtop |
|
26 | 26 | |
|
27 | 27 | add known patch to applied stack qpush |
|
28 | 28 | remove patch from applied stack qpop |
|
29 | 29 | refresh contents of top applied patch qrefresh |
|
30 | 30 | ''' |
|
31 | 31 | |
|
32 | 32 | from mercurial.i18n import _ |
|
33 | 33 | from mercurial.node import bin, hex, short, nullid, nullrev |
|
34 | 34 | from mercurial import commands, cmdutil, hg, patch, util |
|
35 | 35 | from mercurial import repair, extensions, url, error |
|
36 | 36 | import os, sys, re, errno |
|
37 | 37 | |
|
38 | 38 | commands.norepo += " qclone" |
|
39 | 39 | |
|
40 | 40 | # Patch names looks like unix-file names. |
|
41 | 41 | # They must be joinable with queue directory and result in the patch path. |
|
42 | 42 | normname = util.normpath |
|
43 | 43 | |
|
44 | 44 | class statusentry: |
|
45 | 45 | def __init__(self, rev, name=None): |
|
46 | 46 | if not name: |
|
47 | 47 | fields = rev.split(':', 1) |
|
48 | 48 | if len(fields) == 2: |
|
49 | 49 | self.rev, self.name = fields |
|
50 | 50 | else: |
|
51 | 51 | self.rev, self.name = None, None |
|
52 | 52 | else: |
|
53 | 53 | self.rev, self.name = rev, name |
|
54 | 54 | |
|
55 | 55 | def __str__(self): |
|
56 | 56 | return self.rev + ':' + self.name |
|
57 | 57 | |
|
58 | 58 | class patchheader(object): |
|
59 | 59 | def __init__(self, message, comments, user, date, haspatch): |
|
60 | 60 | self.message = message |
|
61 | 61 | self.comments = comments |
|
62 | 62 | self.user = user |
|
63 | 63 | self.date = date |
|
64 | 64 | self.haspatch = haspatch |
|
65 | 65 | |
|
66 | 66 | def setuser(self, user): |
|
67 | 67 | if not self.setheader(['From: ', '# User '], user): |
|
68 | 68 | try: |
|
69 | 69 | patchheaderat = self.comments.index('# HG changeset patch') |
|
70 | 70 | self.comments.insert(patchheaderat + 1,'# User ' + user) |
|
71 | 71 | except ValueError: |
|
72 | 72 | self.comments = ['From: ' + user, ''] + self.comments |
|
73 | 73 | self.user = user |
|
74 | 74 | |
|
75 | 75 | def setdate(self, date): |
|
76 | 76 | if self.setheader(['# Date '], date): |
|
77 | 77 | self.date = date |
|
78 | 78 | |
|
79 | 79 | def setmessage(self, message): |
|
80 | 80 | if self.comments: |
|
81 | 81 | self._delmsg() |
|
82 | 82 | self.message = [message] |
|
83 | 83 | self.comments += self.message |
|
84 | 84 | |
|
85 | 85 | def setheader(self, prefixes, new): |
|
86 | 86 | '''Update all references to a field in the patch header. |
|
87 | 87 | If none found, add it email style.''' |
|
88 | 88 | res = False |
|
89 | 89 | for prefix in prefixes: |
|
90 | 90 | for i in xrange(len(self.comments)): |
|
91 | 91 | if self.comments[i].startswith(prefix): |
|
92 | 92 | self.comments[i] = prefix + new |
|
93 | 93 | res = True |
|
94 | 94 | break |
|
95 | 95 | return res |
|
96 | 96 | |
|
97 | 97 | def __str__(self): |
|
98 | 98 | if not self.comments: |
|
99 | 99 | return '' |
|
100 | 100 | return '\n'.join(self.comments) + '\n\n' |
|
101 | 101 | |
|
102 | 102 | def _delmsg(self): |
|
103 | 103 | '''Remove existing message, keeping the rest of the comments fields. |
|
104 | 104 | If comments contains 'subject: ', message will prepend |
|
105 | 105 | the field and a blank line.''' |
|
106 | 106 | if self.message: |
|
107 | 107 | subj = 'subject: ' + self.message[0].lower() |
|
108 | 108 | for i in xrange(len(self.comments)): |
|
109 | 109 | if subj == self.comments[i].lower(): |
|
110 | 110 | del self.comments[i] |
|
111 | 111 | self.message = self.message[2:] |
|
112 | 112 | break |
|
113 | 113 | ci = 0 |
|
114 | 114 | for mi in xrange(len(self.message)): |
|
115 | 115 | while self.message[mi] != self.comments[ci]: |
|
116 | 116 | ci += 1 |
|
117 | 117 | del self.comments[ci] |
|
118 | 118 | |
|
119 | 119 | class queue: |
|
120 | 120 | def __init__(self, ui, path, patchdir=None): |
|
121 | 121 | self.basepath = path |
|
122 | 122 | self.path = patchdir or os.path.join(path, "patches") |
|
123 | 123 | self.opener = util.opener(self.path) |
|
124 | 124 | self.ui = ui |
|
125 | 125 | self.applied = [] |
|
126 | 126 | self.full_series = [] |
|
127 | 127 | self.applied_dirty = 0 |
|
128 | 128 | self.series_dirty = 0 |
|
129 | 129 | self.series_path = "series" |
|
130 | 130 | self.status_path = "status" |
|
131 | 131 | self.guards_path = "guards" |
|
132 | 132 | self.active_guards = None |
|
133 | 133 | self.guards_dirty = False |
|
134 | 134 | self._diffopts = None |
|
135 | 135 | |
|
136 | 136 | if os.path.exists(self.join(self.series_path)): |
|
137 | 137 | self.full_series = self.opener(self.series_path).read().splitlines() |
|
138 | 138 | self.parse_series() |
|
139 | 139 | |
|
140 | 140 | if os.path.exists(self.join(self.status_path)): |
|
141 | 141 | lines = self.opener(self.status_path).read().splitlines() |
|
142 | 142 | self.applied = [statusentry(l) for l in lines] |
|
143 | 143 | |
|
144 | 144 | def diffopts(self): |
|
145 | 145 | if self._diffopts is None: |
|
146 | 146 | self._diffopts = patch.diffopts(self.ui) |
|
147 | 147 | return self._diffopts |
|
148 | 148 | |
|
149 | 149 | def join(self, *p): |
|
150 | 150 | return os.path.join(self.path, *p) |
|
151 | 151 | |
|
152 | 152 | def find_series(self, patch): |
|
153 | 153 | pre = re.compile("(\s*)([^#]+)") |
|
154 | 154 | index = 0 |
|
155 | 155 | for l in self.full_series: |
|
156 | 156 | m = pre.match(l) |
|
157 | 157 | if m: |
|
158 | 158 | s = m.group(2) |
|
159 | 159 | s = s.rstrip() |
|
160 | 160 | if s == patch: |
|
161 | 161 | return index |
|
162 | 162 | index += 1 |
|
163 | 163 | return None |
|
164 | 164 | |
|
165 | 165 | guard_re = re.compile(r'\s?#([-+][^-+# \t\r\n\f][^# \t\r\n\f]*)') |
|
166 | 166 | |
|
167 | 167 | def parse_series(self): |
|
168 | 168 | self.series = [] |
|
169 | 169 | self.series_guards = [] |
|
170 | 170 | for l in self.full_series: |
|
171 | 171 | h = l.find('#') |
|
172 | 172 | if h == -1: |
|
173 | 173 | patch = l |
|
174 | 174 | comment = '' |
|
175 | 175 | elif h == 0: |
|
176 | 176 | continue |
|
177 | 177 | else: |
|
178 | 178 | patch = l[:h] |
|
179 | 179 | comment = l[h:] |
|
180 | 180 | patch = patch.strip() |
|
181 | 181 | if patch: |
|
182 | 182 | if patch in self.series: |
|
183 | 183 | raise util.Abort(_('%s appears more than once in %s') % |
|
184 | 184 | (patch, self.join(self.series_path))) |
|
185 | 185 | self.series.append(patch) |
|
186 | 186 | self.series_guards.append(self.guard_re.findall(comment)) |
|
187 | 187 | |
|
188 | 188 | def check_guard(self, guard): |
|
189 | 189 | if not guard: |
|
190 | 190 | return _('guard cannot be an empty string') |
|
191 | 191 | bad_chars = '# \t\r\n\f' |
|
192 | 192 | first = guard[0] |
|
193 | 193 | for c in '-+': |
|
194 | 194 | if first == c: |
|
195 | 195 | return (_('guard %r starts with invalid character: %r') % |
|
196 | 196 | (guard, c)) |
|
197 | 197 | for c in bad_chars: |
|
198 | 198 | if c in guard: |
|
199 | 199 | return _('invalid character in guard %r: %r') % (guard, c) |
|
200 | 200 | |
|
201 | 201 | def set_active(self, guards): |
|
202 | 202 | for guard in guards: |
|
203 | 203 | bad = self.check_guard(guard) |
|
204 | 204 | if bad: |
|
205 | 205 | raise util.Abort(bad) |
|
206 | 206 | guards = util.sort(util.unique(guards)) |
|
207 | 207 | self.ui.debug(_('active guards: %s\n') % ' '.join(guards)) |
|
208 | 208 | self.active_guards = guards |
|
209 | 209 | self.guards_dirty = True |
|
210 | 210 | |
|
211 | 211 | def active(self): |
|
212 | 212 | if self.active_guards is None: |
|
213 | 213 | self.active_guards = [] |
|
214 | 214 | try: |
|
215 | 215 | guards = self.opener(self.guards_path).read().split() |
|
216 | 216 | except IOError, err: |
|
217 | 217 | if err.errno != errno.ENOENT: raise |
|
218 | 218 | guards = [] |
|
219 | 219 | for i, guard in enumerate(guards): |
|
220 | 220 | bad = self.check_guard(guard) |
|
221 | 221 | if bad: |
|
222 | 222 | self.ui.warn('%s:%d: %s\n' % |
|
223 | 223 | (self.join(self.guards_path), i + 1, bad)) |
|
224 | 224 | else: |
|
225 | 225 | self.active_guards.append(guard) |
|
226 | 226 | return self.active_guards |
|
227 | 227 | |
|
228 | 228 | def set_guards(self, idx, guards): |
|
229 | 229 | for g in guards: |
|
230 | 230 | if len(g) < 2: |
|
231 | 231 | raise util.Abort(_('guard %r too short') % g) |
|
232 | 232 | if g[0] not in '-+': |
|
233 | 233 | raise util.Abort(_('guard %r starts with invalid char') % g) |
|
234 | 234 | bad = self.check_guard(g[1:]) |
|
235 | 235 | if bad: |
|
236 | 236 | raise util.Abort(bad) |
|
237 | 237 | drop = self.guard_re.sub('', self.full_series[idx]) |
|
238 | 238 | self.full_series[idx] = drop + ''.join([' #' + g for g in guards]) |
|
239 | 239 | self.parse_series() |
|
240 | 240 | self.series_dirty = True |
|
241 | 241 | |
|
242 | 242 | def pushable(self, idx): |
|
243 | 243 | if isinstance(idx, str): |
|
244 | 244 | idx = self.series.index(idx) |
|
245 | 245 | patchguards = self.series_guards[idx] |
|
246 | 246 | if not patchguards: |
|
247 | 247 | return True, None |
|
248 | 248 | guards = self.active() |
|
249 | 249 | exactneg = [g for g in patchguards if g[0] == '-' and g[1:] in guards] |
|
250 | 250 | if exactneg: |
|
251 | 251 | return False, exactneg[0] |
|
252 | 252 | pos = [g for g in patchguards if g[0] == '+'] |
|
253 | 253 | exactpos = [g for g in pos if g[1:] in guards] |
|
254 | 254 | if pos: |
|
255 | 255 | if exactpos: |
|
256 | 256 | return True, exactpos[0] |
|
257 | 257 | return False, pos |
|
258 | 258 | return True, '' |
|
259 | 259 | |
|
260 | 260 | def explain_pushable(self, idx, all_patches=False): |
|
261 | 261 | write = all_patches and self.ui.write or self.ui.warn |
|
262 | 262 | if all_patches or self.ui.verbose: |
|
263 | 263 | if isinstance(idx, str): |
|
264 | 264 | idx = self.series.index(idx) |
|
265 | 265 | pushable, why = self.pushable(idx) |
|
266 | 266 | if all_patches and pushable: |
|
267 | 267 | if why is None: |
|
268 | 268 | write(_('allowing %s - no guards in effect\n') % |
|
269 | 269 | self.series[idx]) |
|
270 | 270 | else: |
|
271 | 271 | if not why: |
|
272 | 272 | write(_('allowing %s - no matching negative guards\n') % |
|
273 | 273 | self.series[idx]) |
|
274 | 274 | else: |
|
275 | 275 | write(_('allowing %s - guarded by %r\n') % |
|
276 | 276 | (self.series[idx], why)) |
|
277 | 277 | if not pushable: |
|
278 | 278 | if why: |
|
279 | 279 | write(_('skipping %s - guarded by %r\n') % |
|
280 | 280 | (self.series[idx], why)) |
|
281 | 281 | else: |
|
282 | 282 | write(_('skipping %s - no matching guards\n') % |
|
283 | 283 | self.series[idx]) |
|
284 | 284 | |
|
285 | 285 | def save_dirty(self): |
|
286 | 286 | def write_list(items, path): |
|
287 | 287 | fp = self.opener(path, 'w') |
|
288 | 288 | for i in items: |
|
289 | 289 | fp.write("%s\n" % i) |
|
290 | 290 | fp.close() |
|
291 | 291 | if self.applied_dirty: write_list(map(str, self.applied), self.status_path) |
|
292 | 292 | if self.series_dirty: write_list(self.full_series, self.series_path) |
|
293 | 293 | if self.guards_dirty: write_list(self.active_guards, self.guards_path) |
|
294 | 294 | |
|
295 | 295 | def readheaders(self, patch): |
|
296 | 296 | def eatdiff(lines): |
|
297 | 297 | while lines: |
|
298 | 298 | l = lines[-1] |
|
299 | 299 | if (l.startswith("diff -") or |
|
300 | 300 | l.startswith("Index:") or |
|
301 | 301 | l.startswith("===========")): |
|
302 | 302 | del lines[-1] |
|
303 | 303 | else: |
|
304 | 304 | break |
|
305 | 305 | def eatempty(lines): |
|
306 | 306 | while lines: |
|
307 | 307 | l = lines[-1] |
|
308 | 308 | if re.match('\s*$', l): |
|
309 | 309 | del lines[-1] |
|
310 | 310 | else: |
|
311 | 311 | break |
|
312 | 312 | |
|
313 | 313 | pf = self.join(patch) |
|
314 | 314 | message = [] |
|
315 | 315 | comments = [] |
|
316 | 316 | user = None |
|
317 | 317 | date = None |
|
318 | 318 | format = None |
|
319 | 319 | subject = None |
|
320 | 320 | diffstart = 0 |
|
321 | 321 | |
|
322 | 322 | for line in file(pf): |
|
323 | 323 | line = line.rstrip() |
|
324 | 324 | if line.startswith('diff --git'): |
|
325 | 325 | diffstart = 2 |
|
326 | 326 | break |
|
327 | 327 | if diffstart: |
|
328 | 328 | if line.startswith('+++ '): |
|
329 | 329 | diffstart = 2 |
|
330 | 330 | break |
|
331 | 331 | if line.startswith("--- "): |
|
332 | 332 | diffstart = 1 |
|
333 | 333 | continue |
|
334 | 334 | elif format == "hgpatch": |
|
335 | 335 | # parse values when importing the result of an hg export |
|
336 | 336 | if line.startswith("# User "): |
|
337 | 337 | user = line[7:] |
|
338 | 338 | elif line.startswith("# Date "): |
|
339 | 339 | date = line[7:] |
|
340 | 340 | elif not line.startswith("# ") and line: |
|
341 | 341 | message.append(line) |
|
342 | 342 | format = None |
|
343 | 343 | elif line == '# HG changeset patch': |
|
344 | 344 | format = "hgpatch" |
|
345 | 345 | elif (format != "tagdone" and (line.startswith("Subject: ") or |
|
346 | 346 | line.startswith("subject: "))): |
|
347 | 347 | subject = line[9:] |
|
348 | 348 | format = "tag" |
|
349 | 349 | elif (format != "tagdone" and (line.startswith("From: ") or |
|
350 | 350 | line.startswith("from: "))): |
|
351 | 351 | user = line[6:] |
|
352 | 352 | format = "tag" |
|
353 | 353 | elif format == "tag" and line == "": |
|
354 | 354 | # when looking for tags (subject: from: etc) they |
|
355 | 355 | # end once you find a blank line in the source |
|
356 | 356 | format = "tagdone" |
|
357 | 357 | elif message or line: |
|
358 | 358 | message.append(line) |
|
359 | 359 | comments.append(line) |
|
360 | 360 | |
|
361 | 361 | eatdiff(message) |
|
362 | 362 | eatdiff(comments) |
|
363 | 363 | eatempty(message) |
|
364 | 364 | eatempty(comments) |
|
365 | 365 | |
|
366 | 366 | # make sure message isn't empty |
|
367 | 367 | if format and format.startswith("tag") and subject: |
|
368 | 368 | message.insert(0, "") |
|
369 | 369 | message.insert(0, subject) |
|
370 | 370 | return patchheader(message, comments, user, date, diffstart > 1) |
|
371 | 371 | |
|
372 | 372 | def removeundo(self, repo): |
|
373 | 373 | undo = repo.sjoin('undo') |
|
374 | 374 | if not os.path.exists(undo): |
|
375 | 375 | return |
|
376 | 376 | try: |
|
377 | 377 | os.unlink(undo) |
|
378 | 378 | except OSError, inst: |
|
379 | 379 | self.ui.warn(_('error removing undo: %s\n') % str(inst)) |
|
380 | 380 | |
|
381 | 381 | def printdiff(self, repo, node1, node2=None, files=None, |
|
382 | 382 | fp=None, changes=None, opts={}): |
|
383 | 383 | m = cmdutil.match(repo, files, opts) |
|
384 | 384 | chunks = patch.diff(repo, node1, node2, m, changes, self.diffopts()) |
|
385 | 385 | write = fp is None and repo.ui.write or fp.write |
|
386 | 386 | for chunk in chunks: |
|
387 | 387 | write(chunk) |
|
388 | 388 | |
|
389 | 389 | def mergeone(self, repo, mergeq, head, patch, rev): |
|
390 | 390 | # first try just applying the patch |
|
391 | 391 | (err, n) = self.apply(repo, [ patch ], update_status=False, |
|
392 | 392 | strict=True, merge=rev) |
|
393 | 393 | |
|
394 | 394 | if err == 0: |
|
395 | 395 | return (err, n) |
|
396 | 396 | |
|
397 | 397 | if n is None: |
|
398 | 398 | raise util.Abort(_("apply failed for patch %s") % patch) |
|
399 | 399 | |
|
400 | 400 | self.ui.warn(_("patch didn't work out, merging %s\n") % patch) |
|
401 | 401 | |
|
402 | 402 | # apply failed, strip away that rev and merge. |
|
403 | 403 | hg.clean(repo, head) |
|
404 | 404 | self.strip(repo, n, update=False, backup='strip') |
|
405 | 405 | |
|
406 | 406 | ctx = repo[rev] |
|
407 | 407 | ret = hg.merge(repo, rev) |
|
408 | 408 | if ret: |
|
409 | 409 | raise util.Abort(_("update returned %d") % ret) |
|
410 | 410 | n = repo.commit(None, ctx.description(), ctx.user(), force=1) |
|
411 | 411 | if n == None: |
|
412 | 412 | raise util.Abort(_("repo commit failed")) |
|
413 | 413 | try: |
|
414 | 414 | ph = mergeq.readheaders(patch) |
|
415 | 415 | except: |
|
416 | 416 | raise util.Abort(_("unable to read %s") % patch) |
|
417 | 417 | |
|
418 | 418 | patchf = self.opener(patch, "w") |
|
419 | 419 | comments = str(ph) |
|
420 | 420 | if comments: |
|
421 | 421 | patchf.write(comments) |
|
422 | 422 | self.printdiff(repo, head, n, fp=patchf) |
|
423 | 423 | patchf.close() |
|
424 | 424 | self.removeundo(repo) |
|
425 | 425 | return (0, n) |
|
426 | 426 | |
|
427 | 427 | def qparents(self, repo, rev=None): |
|
428 | 428 | if rev is None: |
|
429 | 429 | (p1, p2) = repo.dirstate.parents() |
|
430 | 430 | if p2 == nullid: |
|
431 | 431 | return p1 |
|
432 | 432 | if len(self.applied) == 0: |
|
433 | 433 | return None |
|
434 | 434 | return bin(self.applied[-1].rev) |
|
435 | 435 | pp = repo.changelog.parents(rev) |
|
436 | 436 | if pp[1] != nullid: |
|
437 | 437 | arevs = [ x.rev for x in self.applied ] |
|
438 | 438 | p0 = hex(pp[0]) |
|
439 | 439 | p1 = hex(pp[1]) |
|
440 | 440 | if p0 in arevs: |
|
441 | 441 | return pp[0] |
|
442 | 442 | if p1 in arevs: |
|
443 | 443 | return pp[1] |
|
444 | 444 | return pp[0] |
|
445 | 445 | |
|
446 | 446 | def mergepatch(self, repo, mergeq, series): |
|
447 | 447 | if len(self.applied) == 0: |
|
448 | 448 | # each of the patches merged in will have two parents. This |
|
449 | 449 | # can confuse the qrefresh, qdiff, and strip code because it |
|
450 | 450 | # needs to know which parent is actually in the patch queue. |
|
451 | 451 | # so, we insert a merge marker with only one parent. This way |
|
452 | 452 | # the first patch in the queue is never a merge patch |
|
453 | 453 | # |
|
454 | 454 | pname = ".hg.patches.merge.marker" |
|
455 | 455 | n = repo.commit(None, '[mq]: merge marker', user=None, force=1) |
|
456 | 456 | self.removeundo(repo) |
|
457 | 457 | self.applied.append(statusentry(hex(n), pname)) |
|
458 | 458 | self.applied_dirty = 1 |
|
459 | 459 | |
|
460 | 460 | head = self.qparents(repo) |
|
461 | 461 | |
|
462 | 462 | for patch in series: |
|
463 | 463 | patch = mergeq.lookup(patch, strict=True) |
|
464 | 464 | if not patch: |
|
465 | 465 | self.ui.warn(_("patch %s does not exist\n") % patch) |
|
466 | 466 | return (1, None) |
|
467 | 467 | pushable, reason = self.pushable(patch) |
|
468 | 468 | if not pushable: |
|
469 | 469 | self.explain_pushable(patch, all_patches=True) |
|
470 | 470 | continue |
|
471 | 471 | info = mergeq.isapplied(patch) |
|
472 | 472 | if not info: |
|
473 | 473 | self.ui.warn(_("patch %s is not applied\n") % patch) |
|
474 | 474 | return (1, None) |
|
475 | 475 | rev = bin(info[1]) |
|
476 | 476 | (err, head) = self.mergeone(repo, mergeq, head, patch, rev) |
|
477 | 477 | if head: |
|
478 | 478 | self.applied.append(statusentry(hex(head), patch)) |
|
479 | 479 | self.applied_dirty = 1 |
|
480 | 480 | if err: |
|
481 | 481 | return (err, head) |
|
482 | 482 | self.save_dirty() |
|
483 | 483 | return (0, head) |
|
484 | 484 | |
|
485 | 485 | def patch(self, repo, patchfile): |
|
486 | 486 | '''Apply patchfile to the working directory. |
|
487 | 487 | patchfile: file name of patch''' |
|
488 | 488 | files = {} |
|
489 | 489 | try: |
|
490 | 490 | fuzz = patch.patch(patchfile, self.ui, strip=1, cwd=repo.root, |
|
491 | 491 | files=files) |
|
492 | 492 | except Exception, inst: |
|
493 | 493 | self.ui.note(str(inst) + '\n') |
|
494 | 494 | if not self.ui.verbose: |
|
495 | 495 | self.ui.warn(_("patch failed, unable to continue (try -v)\n")) |
|
496 | 496 | return (False, files, False) |
|
497 | 497 | |
|
498 | 498 | return (True, files, fuzz) |
|
499 | 499 | |
|
500 | 500 | def apply(self, repo, series, list=False, update_status=True, |
|
501 | 501 | strict=False, patchdir=None, merge=None, all_files={}): |
|
502 | 502 | wlock = lock = tr = None |
|
503 | 503 | try: |
|
504 | 504 | wlock = repo.wlock() |
|
505 | 505 | lock = repo.lock() |
|
506 | 506 | tr = repo.transaction() |
|
507 | 507 | try: |
|
508 | 508 | ret = self._apply(repo, series, list, update_status, |
|
509 | 509 | strict, patchdir, merge, all_files=all_files) |
|
510 | 510 | tr.close() |
|
511 | 511 | self.save_dirty() |
|
512 | 512 | return ret |
|
513 | 513 | except: |
|
514 | 514 | try: |
|
515 | 515 | tr.abort() |
|
516 | 516 | finally: |
|
517 | 517 | repo.invalidate() |
|
518 | 518 | repo.dirstate.invalidate() |
|
519 | 519 | raise |
|
520 | 520 | finally: |
|
521 | 521 | del tr, lock, wlock |
|
522 | 522 | self.removeundo(repo) |
|
523 | 523 | |
|
524 | 524 | def _apply(self, repo, series, list=False, update_status=True, |
|
525 | 525 | strict=False, patchdir=None, merge=None, all_files={}): |
|
526 | 526 | # TODO unify with commands.py |
|
527 | 527 | if not patchdir: |
|
528 | 528 | patchdir = self.path |
|
529 | 529 | err = 0 |
|
530 | 530 | n = None |
|
531 | 531 | for patchname in series: |
|
532 | 532 | pushable, reason = self.pushable(patchname) |
|
533 | 533 | if not pushable: |
|
534 | 534 | self.explain_pushable(patchname, all_patches=True) |
|
535 | 535 | continue |
|
536 | 536 | self.ui.warn(_("applying %s\n") % patchname) |
|
537 | 537 | pf = os.path.join(patchdir, patchname) |
|
538 | 538 | |
|
539 | 539 | try: |
|
540 | 540 | ph = self.readheaders(patchname) |
|
541 | 541 | except: |
|
542 | 542 | self.ui.warn(_("Unable to read %s\n") % patchname) |
|
543 | 543 | err = 1 |
|
544 | 544 | break |
|
545 | 545 | |
|
546 | 546 | message = ph.message |
|
547 | 547 | if not message: |
|
548 | 548 | message = _("imported patch %s\n") % patchname |
|
549 | 549 | else: |
|
550 | 550 | if list: |
|
551 | 551 | message.append(_("\nimported patch %s") % patchname) |
|
552 | 552 | message = '\n'.join(message) |
|
553 | 553 | |
|
554 | 554 | if ph.haspatch: |
|
555 | 555 | (patcherr, files, fuzz) = self.patch(repo, pf) |
|
556 | 556 | all_files.update(files) |
|
557 | 557 | patcherr = not patcherr |
|
558 | 558 | else: |
|
559 | 559 | self.ui.warn(_("patch %s is empty\n") % patchname) |
|
560 | 560 | patcherr, files, fuzz = 0, [], 0 |
|
561 | 561 | |
|
562 | 562 | if merge and files: |
|
563 | 563 | # Mark as removed/merged and update dirstate parent info |
|
564 | 564 | removed = [] |
|
565 | 565 | merged = [] |
|
566 | 566 | for f in files: |
|
567 | 567 | if os.path.exists(repo.wjoin(f)): |
|
568 | 568 | merged.append(f) |
|
569 | 569 | else: |
|
570 | 570 | removed.append(f) |
|
571 | 571 | for f in removed: |
|
572 | 572 | repo.dirstate.remove(f) |
|
573 | 573 | for f in merged: |
|
574 | 574 | repo.dirstate.merge(f) |
|
575 | 575 | p1, p2 = repo.dirstate.parents() |
|
576 | 576 | repo.dirstate.setparents(p1, merge) |
|
577 | 577 | |
|
578 | 578 | files = patch.updatedir(self.ui, repo, files) |
|
579 | 579 | match = cmdutil.matchfiles(repo, files or []) |
|
580 | 580 | n = repo.commit(files, message, ph.user, ph.date, match=match, |
|
581 | 581 | force=True) |
|
582 | 582 | |
|
583 | 583 | if n == None: |
|
584 | 584 | raise util.Abort(_("repo commit failed")) |
|
585 | 585 | |
|
586 | 586 | if update_status: |
|
587 | 587 | self.applied.append(statusentry(hex(n), patchname)) |
|
588 | 588 | |
|
589 | 589 | if patcherr: |
|
590 | 590 | self.ui.warn(_("patch failed, rejects left in working dir\n")) |
|
591 | 591 | err = 1 |
|
592 | 592 | break |
|
593 | 593 | |
|
594 | 594 | if fuzz and strict: |
|
595 | 595 | self.ui.warn(_("fuzz found when applying patch, stopping\n")) |
|
596 | 596 | err = 1 |
|
597 | 597 | break |
|
598 | 598 | return (err, n) |
|
599 | 599 | |
|
600 | 600 | def _clean_series(self, patches): |
|
601 | 601 | indices = util.sort([self.find_series(p) for p in patches]) |
|
602 | 602 | for i in indices[-1::-1]: |
|
603 | 603 | del self.full_series[i] |
|
604 | 604 | self.parse_series() |
|
605 | 605 | self.series_dirty = 1 |
|
606 | 606 | |
|
607 | 607 | def finish(self, repo, revs): |
|
608 | 608 | revs.sort() |
|
609 | 609 | firstrev = repo[self.applied[0].rev].rev() |
|
610 | 610 | appliedbase = 0 |
|
611 | 611 | patches = [] |
|
612 | 612 | for rev in util.sort(revs): |
|
613 | 613 | if rev < firstrev: |
|
614 | 614 | raise util.Abort(_('revision %d is not managed') % rev) |
|
615 | 615 | base = bin(self.applied[appliedbase].rev) |
|
616 | 616 | node = repo.changelog.node(rev) |
|
617 | 617 | if node != base: |
|
618 | 618 | raise util.Abort(_('cannot delete revision %d above ' |
|
619 | 619 | 'applied patches') % rev) |
|
620 | 620 | patches.append(self.applied[appliedbase].name) |
|
621 | 621 | appliedbase += 1 |
|
622 | 622 | |
|
623 | 623 | r = self.qrepo() |
|
624 | 624 | if r: |
|
625 | 625 | r.remove(patches, True) |
|
626 | 626 | else: |
|
627 | 627 | for p in patches: |
|
628 | 628 | os.unlink(self.join(p)) |
|
629 | 629 | |
|
630 | 630 | del self.applied[:appliedbase] |
|
631 | 631 | self.applied_dirty = 1 |
|
632 | 632 | self._clean_series(patches) |
|
633 | 633 | |
|
634 | 634 | def delete(self, repo, patches, opts): |
|
635 | 635 | if not patches and not opts.get('rev'): |
|
636 | 636 | raise util.Abort(_('qdelete requires at least one revision or ' |
|
637 | 637 | 'patch name')) |
|
638 | 638 | |
|
639 | 639 | realpatches = [] |
|
640 | 640 | for patch in patches: |
|
641 | 641 | patch = self.lookup(patch, strict=True) |
|
642 | 642 | info = self.isapplied(patch) |
|
643 | 643 | if info: |
|
644 | 644 | raise util.Abort(_("cannot delete applied patch %s") % patch) |
|
645 | 645 | if patch not in self.series: |
|
646 | 646 | raise util.Abort(_("patch %s not in series file") % patch) |
|
647 | 647 | realpatches.append(patch) |
|
648 | 648 | |
|
649 | 649 | appliedbase = 0 |
|
650 | 650 | if opts.get('rev'): |
|
651 | 651 | if not self.applied: |
|
652 | 652 | raise util.Abort(_('no patches applied')) |
|
653 | 653 | revs = cmdutil.revrange(repo, opts['rev']) |
|
654 | 654 | if len(revs) > 1 and revs[0] > revs[1]: |
|
655 | 655 | revs.reverse() |
|
656 | 656 | for rev in revs: |
|
657 | 657 | if appliedbase >= len(self.applied): |
|
658 | 658 | raise util.Abort(_("revision %d is not managed") % rev) |
|
659 | 659 | |
|
660 | 660 | base = bin(self.applied[appliedbase].rev) |
|
661 | 661 | node = repo.changelog.node(rev) |
|
662 | 662 | if node != base: |
|
663 | 663 | raise util.Abort(_("cannot delete revision %d above " |
|
664 | 664 | "applied patches") % rev) |
|
665 | 665 | realpatches.append(self.applied[appliedbase].name) |
|
666 | 666 | appliedbase += 1 |
|
667 | 667 | |
|
668 | 668 | if not opts.get('keep'): |
|
669 | 669 | r = self.qrepo() |
|
670 | 670 | if r: |
|
671 | 671 | r.remove(realpatches, True) |
|
672 | 672 | else: |
|
673 | 673 | for p in realpatches: |
|
674 | 674 | os.unlink(self.join(p)) |
|
675 | 675 | |
|
676 | 676 | if appliedbase: |
|
677 | 677 | del self.applied[:appliedbase] |
|
678 | 678 | self.applied_dirty = 1 |
|
679 | 679 | self._clean_series(realpatches) |
|
680 | 680 | |
|
681 | 681 | def check_toppatch(self, repo): |
|
682 | 682 | if len(self.applied) > 0: |
|
683 | 683 | top = bin(self.applied[-1].rev) |
|
684 | 684 | pp = repo.dirstate.parents() |
|
685 | 685 | if top not in pp: |
|
686 | 686 | raise util.Abort(_("working directory revision is not qtip")) |
|
687 | 687 | return top |
|
688 | 688 | return None |
|
689 | 689 | def check_localchanges(self, repo, force=False, refresh=True): |
|
690 | 690 | m, a, r, d = repo.status()[:4] |
|
691 | 691 | if m or a or r or d: |
|
692 | 692 | if not force: |
|
693 | 693 | if refresh: |
|
694 | 694 | raise util.Abort(_("local changes found, refresh first")) |
|
695 | 695 | else: |
|
696 | 696 | raise util.Abort(_("local changes found")) |
|
697 | 697 | return m, a, r, d |
|
698 | 698 | |
|
699 | 699 | _reserved = ('series', 'status', 'guards') |
|
700 | 700 | def check_reserved_name(self, name): |
|
701 | 701 | if (name in self._reserved or name.startswith('.hg') |
|
702 | 702 | or name.startswith('.mq')): |
|
703 | 703 | raise util.Abort(_('"%s" cannot be used as the name of a patch') |
|
704 | 704 | % name) |
|
705 | 705 | |
|
706 | 706 | def new(self, repo, patchfn, *pats, **opts): |
|
707 | 707 | """options: |
|
708 | 708 | msg: a string or a no-argument function returning a string |
|
709 | 709 | """ |
|
710 | 710 | msg = opts.get('msg') |
|
711 | 711 | force = opts.get('force') |
|
712 | 712 | user = opts.get('user') |
|
713 | 713 | date = opts.get('date') |
|
714 | 714 | if date: |
|
715 | 715 | date = util.parsedate(date) |
|
716 | 716 | self.check_reserved_name(patchfn) |
|
717 | 717 | if os.path.exists(self.join(patchfn)): |
|
718 | 718 | raise util.Abort(_('patch "%s" already exists') % patchfn) |
|
719 | 719 | if opts.get('include') or opts.get('exclude') or pats: |
|
720 | 720 | match = cmdutil.match(repo, pats, opts) |
|
721 | 721 | # detect missing files in pats |
|
722 | 722 | def badfn(f, msg): |
|
723 | 723 | raise util.Abort('%s: %s' % (f, msg)) |
|
724 | 724 | match.bad = badfn |
|
725 | 725 | m, a, r, d = repo.status(match=match)[:4] |
|
726 | 726 | else: |
|
727 | 727 | m, a, r, d = self.check_localchanges(repo, force) |
|
728 | 728 | match = cmdutil.matchfiles(repo, m + a + r) |
|
729 | 729 | commitfiles = m + a + r |
|
730 | 730 | self.check_toppatch(repo) |
|
731 | 731 | insert = self.full_series_end() |
|
732 | 732 | wlock = repo.wlock() |
|
733 | 733 | try: |
|
734 | 734 | # if patch file write fails, abort early |
|
735 | 735 | p = self.opener(patchfn, "w") |
|
736 | 736 | try: |
|
737 | 737 | if date: |
|
738 | 738 | p.write("# HG changeset patch\n") |
|
739 | 739 | if user: |
|
740 | 740 | p.write("# User " + user + "\n") |
|
741 | 741 | p.write("# Date %d %d\n\n" % date) |
|
742 | 742 | elif user: |
|
743 | 743 | p.write("From: " + user + "\n\n") |
|
744 | 744 | |
|
745 | 745 | if callable(msg): |
|
746 | 746 | msg = msg() |
|
747 | 747 | commitmsg = msg and msg or ("[mq]: %s" % patchfn) |
|
748 | 748 | n = repo.commit(commitfiles, commitmsg, user, date, match=match, force=True) |
|
749 | 749 | if n == None: |
|
750 | 750 | raise util.Abort(_("repo commit failed")) |
|
751 | 751 | try: |
|
752 | 752 | self.full_series[insert:insert] = [patchfn] |
|
753 | 753 | self.applied.append(statusentry(hex(n), patchfn)) |
|
754 | 754 | self.parse_series() |
|
755 | 755 | self.series_dirty = 1 |
|
756 | 756 | self.applied_dirty = 1 |
|
757 | 757 | if msg: |
|
758 | 758 | msg = msg + "\n\n" |
|
759 | 759 | p.write(msg) |
|
760 | 760 | if commitfiles: |
|
761 | 761 | diffopts = self.diffopts() |
|
762 | 762 | if opts.get('git'): diffopts.git = True |
|
763 | 763 | parent = self.qparents(repo, n) |
|
764 | 764 | chunks = patch.diff(repo, node1=parent, node2=n, |
|
765 | 765 | match=match, opts=diffopts) |
|
766 | 766 | for chunk in chunks: |
|
767 | 767 | p.write(chunk) |
|
768 | 768 | p.close() |
|
769 | 769 | wlock = None |
|
770 | 770 | r = self.qrepo() |
|
771 | 771 | if r: r.add([patchfn]) |
|
772 | 772 | except: |
|
773 | 773 | repo.rollback() |
|
774 | 774 | raise |
|
775 | 775 | except Exception: |
|
776 | 776 | patchpath = self.join(patchfn) |
|
777 | 777 | try: |
|
778 | 778 | os.unlink(patchpath) |
|
779 | 779 | except: |
|
780 | 780 | self.ui.warn(_('error unlinking %s\n') % patchpath) |
|
781 | 781 | raise |
|
782 | 782 | self.removeundo(repo) |
|
783 | 783 | finally: |
|
784 | 784 | del wlock |
|
785 | 785 | |
|
786 | 786 | def strip(self, repo, rev, update=True, backup="all", force=None): |
|
787 | 787 | wlock = lock = None |
|
788 | 788 | try: |
|
789 | 789 | wlock = repo.wlock() |
|
790 | 790 | lock = repo.lock() |
|
791 | 791 | |
|
792 | 792 | if update: |
|
793 | 793 | self.check_localchanges(repo, force=force, refresh=False) |
|
794 | 794 | urev = self.qparents(repo, rev) |
|
795 | 795 | hg.clean(repo, urev) |
|
796 | 796 | repo.dirstate.write() |
|
797 | 797 | |
|
798 | 798 | self.removeundo(repo) |
|
799 | 799 | repair.strip(self.ui, repo, rev, backup) |
|
800 | 800 | # strip may have unbundled a set of backed up revisions after |
|
801 | 801 | # the actual strip |
|
802 | 802 | self.removeundo(repo) |
|
803 | 803 | finally: |
|
804 | 804 | del lock, wlock |
|
805 | 805 | |
|
806 | 806 | def isapplied(self, patch): |
|
807 | 807 | """returns (index, rev, patch)""" |
|
808 | 808 | for i in xrange(len(self.applied)): |
|
809 | 809 | a = self.applied[i] |
|
810 | 810 | if a.name == patch: |
|
811 | 811 | return (i, a.rev, a.name) |
|
812 | 812 | return None |
|
813 | 813 | |
|
814 | 814 | # if the exact patch name does not exist, we try a few |
|
815 | 815 | # variations. If strict is passed, we try only #1 |
|
816 | 816 | # |
|
817 | 817 | # 1) a number to indicate an offset in the series file |
|
818 | 818 | # 2) a unique substring of the patch name was given |
|
819 | 819 | # 3) patchname[-+]num to indicate an offset in the series file |
|
820 | 820 | def lookup(self, patch, strict=False): |
|
821 | 821 | patch = patch and str(patch) |
|
822 | 822 | |
|
823 | 823 | def partial_name(s): |
|
824 | 824 | if s in self.series: |
|
825 | 825 | return s |
|
826 | 826 | matches = [x for x in self.series if s in x] |
|
827 | 827 | if len(matches) > 1: |
|
828 | 828 | self.ui.warn(_('patch name "%s" is ambiguous:\n') % s) |
|
829 | 829 | for m in matches: |
|
830 | 830 | self.ui.warn(' %s\n' % m) |
|
831 | 831 | return None |
|
832 | 832 | if matches: |
|
833 | 833 | return matches[0] |
|
834 | 834 | if len(self.series) > 0 and len(self.applied) > 0: |
|
835 | 835 | if s == 'qtip': |
|
836 | 836 | return self.series[self.series_end(True)-1] |
|
837 | 837 | if s == 'qbase': |
|
838 | 838 | return self.series[0] |
|
839 | 839 | return None |
|
840 | 840 | |
|
841 | 841 | if patch == None: |
|
842 | 842 | return None |
|
843 | 843 | if patch in self.series: |
|
844 | 844 | return patch |
|
845 | 845 | |
|
846 | 846 | if not os.path.isfile(self.join(patch)): |
|
847 | 847 | try: |
|
848 | 848 | sno = int(patch) |
|
849 | 849 | except(ValueError, OverflowError): |
|
850 | 850 | pass |
|
851 | 851 | else: |
|
852 | 852 | if -len(self.series) <= sno < len(self.series): |
|
853 | 853 | return self.series[sno] |
|
854 | 854 | |
|
855 | 855 | if not strict: |
|
856 | 856 | res = partial_name(patch) |
|
857 | 857 | if res: |
|
858 | 858 | return res |
|
859 | 859 | minus = patch.rfind('-') |
|
860 | 860 | if minus >= 0: |
|
861 | 861 | res = partial_name(patch[:minus]) |
|
862 | 862 | if res: |
|
863 | 863 | i = self.series.index(res) |
|
864 | 864 | try: |
|
865 | 865 | off = int(patch[minus+1:] or 1) |
|
866 | 866 | except(ValueError, OverflowError): |
|
867 | 867 | pass |
|
868 | 868 | else: |
|
869 | 869 | if i - off >= 0: |
|
870 | 870 | return self.series[i - off] |
|
871 | 871 | plus = patch.rfind('+') |
|
872 | 872 | if plus >= 0: |
|
873 | 873 | res = partial_name(patch[:plus]) |
|
874 | 874 | if res: |
|
875 | 875 | i = self.series.index(res) |
|
876 | 876 | try: |
|
877 | 877 | off = int(patch[plus+1:] or 1) |
|
878 | 878 | except(ValueError, OverflowError): |
|
879 | 879 | pass |
|
880 | 880 | else: |
|
881 | 881 | if i + off < len(self.series): |
|
882 | 882 | return self.series[i + off] |
|
883 | 883 | raise util.Abort(_("patch %s not in series") % patch) |
|
884 | 884 | |
|
885 | 885 | def push(self, repo, patch=None, force=False, list=False, |
|
886 | 886 | mergeq=None, all=False): |
|
887 | 887 | wlock = repo.wlock() |
|
888 | 888 | if repo.dirstate.parents()[0] != repo.changelog.tip(): |
|
889 | 889 | self.ui.status(_("(working directory not at tip)\n")) |
|
890 | 890 | |
|
891 | 891 | if not self.series: |
|
892 | 892 | self.ui.warn(_('no patches in series\n')) |
|
893 | 893 | return 0 |
|
894 | 894 | |
|
895 | 895 | try: |
|
896 | 896 | patch = self.lookup(patch) |
|
897 | 897 | # Suppose our series file is: A B C and the current 'top' |
|
898 | 898 | # patch is B. qpush C should be performed (moving forward) |
|
899 | 899 | # qpush B is a NOP (no change) qpush A is an error (can't |
|
900 | 900 | # go backwards with qpush) |
|
901 | 901 | if patch: |
|
902 | 902 | info = self.isapplied(patch) |
|
903 | 903 | if info: |
|
904 | 904 | if info[0] < len(self.applied) - 1: |
|
905 | 905 | raise util.Abort( |
|
906 | 906 | _("cannot push to a previous patch: %s") % patch) |
|
907 | 907 | self.ui.warn( |
|
908 | 908 | _('qpush: %s is already at the top\n') % patch) |
|
909 | 909 | return |
|
910 | 910 | pushable, reason = self.pushable(patch) |
|
911 | 911 | if not pushable: |
|
912 | 912 | if reason: |
|
913 | 913 | reason = _('guarded by %r') % reason |
|
914 | 914 | else: |
|
915 | 915 | reason = _('no matching guards') |
|
916 | 916 | self.ui.warn(_("cannot push '%s' - %s\n") % (patch, reason)) |
|
917 | 917 | return 1 |
|
918 | 918 | elif all: |
|
919 | 919 | patch = self.series[-1] |
|
920 | 920 | if self.isapplied(patch): |
|
921 | 921 | self.ui.warn(_('all patches are currently applied\n')) |
|
922 | 922 | return 0 |
|
923 | 923 | |
|
924 | 924 | # Following the above example, starting at 'top' of B: |
|
925 | 925 | # qpush should be performed (pushes C), but a subsequent |
|
926 | 926 | # qpush without an argument is an error (nothing to |
|
927 | 927 | # apply). This allows a loop of "...while hg qpush..." to |
|
928 | 928 | # work as it detects an error when done |
|
929 | 929 | start = self.series_end() |
|
930 | 930 | if start == len(self.series): |
|
931 | 931 | self.ui.warn(_('patch series already fully applied\n')) |
|
932 | 932 | return 1 |
|
933 | 933 | if not force: |
|
934 | 934 | self.check_localchanges(repo) |
|
935 | 935 | |
|
936 | 936 | self.applied_dirty = 1 |
|
937 | 937 | if start > 0: |
|
938 | 938 | self.check_toppatch(repo) |
|
939 | 939 | if not patch: |
|
940 | 940 | patch = self.series[start] |
|
941 | 941 | end = start + 1 |
|
942 | 942 | else: |
|
943 | 943 | end = self.series.index(patch, start) + 1 |
|
944 | 944 | s = self.series[start:end] |
|
945 | 945 | all_files = {} |
|
946 | 946 | try: |
|
947 | 947 | if mergeq: |
|
948 | 948 | ret = self.mergepatch(repo, mergeq, s) |
|
949 | 949 | else: |
|
950 | 950 | ret = self.apply(repo, s, list, all_files=all_files) |
|
951 | 951 | except: |
|
952 | 952 | self.ui.warn(_('cleaning up working directory...')) |
|
953 | 953 | node = repo.dirstate.parents()[0] |
|
954 | 954 | hg.revert(repo, node, None) |
|
955 | 955 | unknown = repo.status(unknown=True)[4] |
|
956 | 956 | # only remove unknown files that we know we touched or |
|
957 | 957 | # created while patching |
|
958 | 958 | for f in unknown: |
|
959 | 959 | if f in all_files: |
|
960 | 960 | util.unlink(repo.wjoin(f)) |
|
961 | 961 | self.ui.warn(_('done\n')) |
|
962 | 962 | raise |
|
963 | 963 | top = self.applied[-1].name |
|
964 | 964 | if ret[0]: |
|
965 | 965 | self.ui.write(_("errors during apply, please fix and " |
|
966 | 966 | "refresh %s\n") % top) |
|
967 | 967 | else: |
|
968 | 968 | self.ui.write(_("now at: %s\n") % top) |
|
969 | 969 | return ret[0] |
|
970 | 970 | finally: |
|
971 | 971 | del wlock |
|
972 | 972 | |
|
973 | 973 | def pop(self, repo, patch=None, force=False, update=True, all=False): |
|
974 | 974 | def getfile(f, rev, flags): |
|
975 | 975 | t = repo.file(f).read(rev) |
|
976 | 976 | repo.wwrite(f, t, flags) |
|
977 | 977 | |
|
978 | 978 | wlock = repo.wlock() |
|
979 | 979 | try: |
|
980 | 980 | if patch: |
|
981 | 981 | # index, rev, patch |
|
982 | 982 | info = self.isapplied(patch) |
|
983 | 983 | if not info: |
|
984 | 984 | patch = self.lookup(patch) |
|
985 | 985 | info = self.isapplied(patch) |
|
986 | 986 | if not info: |
|
987 | 987 | raise util.Abort(_("patch %s is not applied") % patch) |
|
988 | 988 | |
|
989 | 989 | if len(self.applied) == 0: |
|
990 | 990 | # Allow qpop -a to work repeatedly, |
|
991 | 991 | # but not qpop without an argument |
|
992 | 992 | self.ui.warn(_("no patches applied\n")) |
|
993 | 993 | return not all |
|
994 | 994 | |
|
995 | 995 | if all: |
|
996 | 996 | start = 0 |
|
997 | 997 | elif patch: |
|
998 | 998 | start = info[0] + 1 |
|
999 | 999 | else: |
|
1000 | 1000 | start = len(self.applied) - 1 |
|
1001 | 1001 | |
|
1002 | 1002 | if start >= len(self.applied): |
|
1003 | 1003 | self.ui.warn(_("qpop: %s is already at the top\n") % patch) |
|
1004 | 1004 | return |
|
1005 | 1005 | |
|
1006 | 1006 | if not update: |
|
1007 | 1007 | parents = repo.dirstate.parents() |
|
1008 | 1008 | rr = [ bin(x.rev) for x in self.applied ] |
|
1009 | 1009 | for p in parents: |
|
1010 | 1010 | if p in rr: |
|
1011 | 1011 | self.ui.warn(_("qpop: forcing dirstate update\n")) |
|
1012 | 1012 | update = True |
|
1013 | 1013 | else: |
|
1014 | 1014 | parents = [p.hex() for p in repo[None].parents()] |
|
1015 | 1015 | needupdate = False |
|
1016 | 1016 | for entry in self.applied[start:]: |
|
1017 | 1017 | if entry.rev in parents: |
|
1018 | 1018 | needupdate = True |
|
1019 | 1019 | break |
|
1020 | 1020 | update = needupdate |
|
1021 | 1021 | |
|
1022 | 1022 | if not force and update: |
|
1023 | 1023 | self.check_localchanges(repo) |
|
1024 | 1024 | |
|
1025 | 1025 | self.applied_dirty = 1 |
|
1026 | 1026 | end = len(self.applied) |
|
1027 | 1027 | rev = bin(self.applied[start].rev) |
|
1028 | 1028 | if update: |
|
1029 | 1029 | top = self.check_toppatch(repo) |
|
1030 | 1030 | |
|
1031 | 1031 | try: |
|
1032 | 1032 | heads = repo.changelog.heads(rev) |
|
1033 | 1033 | except error.LookupError: |
|
1034 | 1034 | node = short(rev) |
|
1035 | 1035 | raise util.Abort(_('trying to pop unknown node %s') % node) |
|
1036 | 1036 | |
|
1037 | 1037 | if heads != [bin(self.applied[-1].rev)]: |
|
1038 | 1038 | raise util.Abort(_("popping would remove a revision not " |
|
1039 | 1039 | "managed by this patch queue")) |
|
1040 | 1040 | |
|
1041 | 1041 | # we know there are no local changes, so we can make a simplified |
|
1042 | 1042 | # form of hg.update. |
|
1043 | 1043 | if update: |
|
1044 | 1044 | qp = self.qparents(repo, rev) |
|
1045 | 1045 | changes = repo.changelog.read(qp) |
|
1046 | 1046 | mmap = repo.manifest.read(changes[0]) |
|
1047 | 1047 | m, a, r, d = repo.status(qp, top)[:4] |
|
1048 | 1048 | if d: |
|
1049 | 1049 | raise util.Abort(_("deletions found between repo revs")) |
|
1050 | 1050 | for f in m: |
|
1051 | 1051 | getfile(f, mmap[f], mmap.flags(f)) |
|
1052 | 1052 | for f in r: |
|
1053 | 1053 | getfile(f, mmap[f], mmap.flags(f)) |
|
1054 | 1054 | for f in m + r: |
|
1055 | 1055 | repo.dirstate.normal(f) |
|
1056 | 1056 | for f in a: |
|
1057 | 1057 | try: |
|
1058 | 1058 | os.unlink(repo.wjoin(f)) |
|
1059 | 1059 | except OSError, e: |
|
1060 | 1060 | if e.errno != errno.ENOENT: |
|
1061 | 1061 | raise |
|
1062 | 1062 | try: os.removedirs(os.path.dirname(repo.wjoin(f))) |
|
1063 | 1063 | except: pass |
|
1064 | 1064 | repo.dirstate.forget(f) |
|
1065 | 1065 | repo.dirstate.setparents(qp, nullid) |
|
1066 | 1066 | del self.applied[start:end] |
|
1067 | 1067 | self.strip(repo, rev, update=False, backup='strip') |
|
1068 | 1068 | if len(self.applied): |
|
1069 | 1069 | self.ui.write(_("now at: %s\n") % self.applied[-1].name) |
|
1070 | 1070 | else: |
|
1071 | 1071 | self.ui.write(_("patch queue now empty\n")) |
|
1072 | 1072 | finally: |
|
1073 | 1073 | del wlock |
|
1074 | 1074 | |
|
1075 | 1075 | def diff(self, repo, pats, opts): |
|
1076 | 1076 | top = self.check_toppatch(repo) |
|
1077 | 1077 | if not top: |
|
1078 | 1078 | self.ui.write(_("no patches applied\n")) |
|
1079 | 1079 | return |
|
1080 | 1080 | qp = self.qparents(repo, top) |
|
1081 | 1081 | self._diffopts = patch.diffopts(self.ui, opts) |
|
1082 | 1082 | self.printdiff(repo, qp, files=pats, opts=opts) |
|
1083 | 1083 | |
|
1084 | 1084 | def refresh(self, repo, pats=None, **opts): |
|
1085 | 1085 | if len(self.applied) == 0: |
|
1086 | 1086 | self.ui.write(_("no patches applied\n")) |
|
1087 | 1087 | return 1 |
|
1088 | 1088 | msg = opts.get('msg', '').rstrip() |
|
1089 | 1089 | newuser = opts.get('user') |
|
1090 | 1090 | newdate = opts.get('date') |
|
1091 | 1091 | if newdate: |
|
1092 | 1092 | newdate = '%d %d' % util.parsedate(newdate) |
|
1093 | 1093 | wlock = repo.wlock() |
|
1094 | 1094 | try: |
|
1095 | 1095 | self.check_toppatch(repo) |
|
1096 | 1096 | (top, patchfn) = (self.applied[-1].rev, self.applied[-1].name) |
|
1097 | 1097 | top = bin(top) |
|
1098 | 1098 | if repo.changelog.heads(top) != [top]: |
|
1099 | 1099 | raise util.Abort(_("cannot refresh a revision with children")) |
|
1100 | 1100 | cparents = repo.changelog.parents(top) |
|
1101 | 1101 | patchparent = self.qparents(repo, top) |
|
1102 | 1102 | ph = self.readheaders(patchfn) |
|
1103 | 1103 | |
|
1104 | 1104 | patchf = self.opener(patchfn, 'r') |
|
1105 | 1105 | |
|
1106 | 1106 | # if the patch was a git patch, refresh it as a git patch |
|
1107 | 1107 | for line in patchf: |
|
1108 | 1108 | if line.startswith('diff --git'): |
|
1109 | 1109 | self.diffopts().git = True |
|
1110 | 1110 | break |
|
1111 | 1111 | |
|
1112 | 1112 | if msg: |
|
1113 | 1113 | ph.setmessage(msg) |
|
1114 | 1114 | if newuser: |
|
1115 | 1115 | ph.setuser(newuser) |
|
1116 | 1116 | if newdate: |
|
1117 | 1117 | ph.setdate(newdate) |
|
1118 | 1118 | |
|
1119 | 1119 | # only commit new patch when write is complete |
|
1120 | 1120 | patchf = self.opener(patchfn, 'w', atomictemp=True) |
|
1121 | 1121 | |
|
1122 | 1122 | patchf.seek(0) |
|
1123 | 1123 | patchf.truncate() |
|
1124 | 1124 | |
|
1125 | 1125 | comments = str(ph) |
|
1126 | 1126 | if comments: |
|
1127 | 1127 | patchf.write(comments) |
|
1128 | 1128 | |
|
1129 | 1129 | if opts.get('git'): |
|
1130 | 1130 | self.diffopts().git = True |
|
1131 | 1131 | tip = repo.changelog.tip() |
|
1132 | 1132 | if top == tip: |
|
1133 | 1133 | # if the top of our patch queue is also the tip, there is an |
|
1134 | 1134 | # optimization here. We update the dirstate in place and strip |
|
1135 | 1135 | # off the tip commit. Then just commit the current directory |
|
1136 | 1136 | # tree. We can also send repo.commit the list of files |
|
1137 | 1137 | # changed to speed up the diff |
|
1138 | 1138 | # |
|
1139 | 1139 | # in short mode, we only diff the files included in the |
|
1140 | 1140 | # patch already plus specified files |
|
1141 | 1141 | # |
|
1142 | 1142 | # this should really read: |
|
1143 | 1143 | # mm, dd, aa, aa2 = repo.status(tip, patchparent)[:4] |
|
1144 | 1144 | # but we do it backwards to take advantage of manifest/chlog |
|
1145 | 1145 | # caching against the next repo.status call |
|
1146 | 1146 | # |
|
1147 | 1147 | mm, aa, dd, aa2 = repo.status(patchparent, tip)[:4] |
|
1148 | 1148 | changes = repo.changelog.read(tip) |
|
1149 | 1149 | man = repo.manifest.read(changes[0]) |
|
1150 | 1150 | aaa = aa[:] |
|
1151 | 1151 | matchfn = cmdutil.match(repo, pats, opts) |
|
1152 | 1152 | if opts.get('short'): |
|
1153 | 1153 | # if amending a patch, we start with existing |
|
1154 | 1154 | # files plus specified files - unfiltered |
|
1155 | 1155 | match = cmdutil.matchfiles(repo, mm + aa + dd + matchfn.files()) |
|
1156 | 1156 | # filter with inc/exl options |
|
1157 | 1157 | matchfn = cmdutil.match(repo, opts=opts) |
|
1158 | 1158 | else: |
|
1159 | 1159 | match = cmdutil.matchall(repo) |
|
1160 | 1160 | m, a, r, d = repo.status(match=match)[:4] |
|
1161 | 1161 | |
|
1162 | 1162 | # we might end up with files that were added between |
|
1163 | 1163 | # tip and the dirstate parent, but then changed in the |
|
1164 | 1164 | # local dirstate. in this case, we want them to only |
|
1165 | 1165 | # show up in the added section |
|
1166 | 1166 | for x in m: |
|
1167 | 1167 | if x not in aa: |
|
1168 | 1168 | mm.append(x) |
|
1169 | 1169 | # we might end up with files added by the local dirstate that |
|
1170 | 1170 | # were deleted by the patch. In this case, they should only |
|
1171 | 1171 | # show up in the changed section. |
|
1172 | 1172 | for x in a: |
|
1173 | 1173 | if x in dd: |
|
1174 | 1174 | del dd[dd.index(x)] |
|
1175 | 1175 | mm.append(x) |
|
1176 | 1176 | else: |
|
1177 | 1177 | aa.append(x) |
|
1178 | 1178 | # make sure any files deleted in the local dirstate |
|
1179 | 1179 | # are not in the add or change column of the patch |
|
1180 | 1180 | forget = [] |
|
1181 | 1181 | for x in d + r: |
|
1182 | 1182 | if x in aa: |
|
1183 | 1183 | del aa[aa.index(x)] |
|
1184 | 1184 | forget.append(x) |
|
1185 | 1185 | continue |
|
1186 | 1186 | elif x in mm: |
|
1187 | 1187 | del mm[mm.index(x)] |
|
1188 | 1188 | dd.append(x) |
|
1189 | 1189 | |
|
1190 | 1190 | m = util.unique(mm) |
|
1191 | 1191 | r = util.unique(dd) |
|
1192 | 1192 | a = util.unique(aa) |
|
1193 | 1193 | c = [filter(matchfn, l) for l in (m, a, r)] |
|
1194 | 1194 | match = cmdutil.matchfiles(repo, util.unique(c[0] + c[1] + c[2])) |
|
1195 | 1195 | chunks = patch.diff(repo, patchparent, match=match, |
|
1196 | 1196 | changes=c, opts=self.diffopts()) |
|
1197 | 1197 | for chunk in chunks: |
|
1198 | 1198 | patchf.write(chunk) |
|
1199 | 1199 | |
|
1200 | 1200 | try: |
|
1201 | 1201 | if self.diffopts().git: |
|
1202 | 1202 | copies = {} |
|
1203 | 1203 | for dst in a: |
|
1204 | 1204 | src = repo.dirstate.copied(dst) |
|
1205 | 1205 | # during qfold, the source file for copies may |
|
1206 | 1206 | # be removed. Treat this as a simple add. |
|
1207 | 1207 | if src is not None and src in repo.dirstate: |
|
1208 | 1208 | copies.setdefault(src, []).append(dst) |
|
1209 | 1209 | repo.dirstate.add(dst) |
|
1210 | 1210 | # remember the copies between patchparent and tip |
|
1211 | 1211 | for dst in aaa: |
|
1212 | 1212 | f = repo.file(dst) |
|
1213 | 1213 | src = f.renamed(man[dst]) |
|
1214 | 1214 | if src: |
|
1215 | 1215 | copies.setdefault(src[0], []).extend(copies.get(dst, [])) |
|
1216 | 1216 | if dst in a: |
|
1217 | 1217 | copies[src[0]].append(dst) |
|
1218 | 1218 | # we can't copy a file created by the patch itself |
|
1219 | 1219 | if dst in copies: |
|
1220 | 1220 | del copies[dst] |
|
1221 | 1221 | for src, dsts in copies.iteritems(): |
|
1222 | 1222 | for dst in dsts: |
|
1223 | 1223 | repo.dirstate.copy(src, dst) |
|
1224 | 1224 | else: |
|
1225 | 1225 | for dst in a: |
|
1226 | 1226 | repo.dirstate.add(dst) |
|
1227 | 1227 | # Drop useless copy information |
|
1228 | 1228 | for f in list(repo.dirstate.copies()): |
|
1229 | 1229 | repo.dirstate.copy(None, f) |
|
1230 | 1230 | for f in r: |
|
1231 | 1231 | repo.dirstate.remove(f) |
|
1232 | 1232 | # if the patch excludes a modified file, mark that |
|
1233 | 1233 | # file with mtime=0 so status can see it. |
|
1234 | 1234 | mm = [] |
|
1235 | 1235 | for i in xrange(len(m)-1, -1, -1): |
|
1236 | 1236 | if not matchfn(m[i]): |
|
1237 | 1237 | mm.append(m[i]) |
|
1238 | 1238 | del m[i] |
|
1239 | 1239 | for f in m: |
|
1240 | 1240 | repo.dirstate.normal(f) |
|
1241 | 1241 | for f in mm: |
|
1242 | 1242 | repo.dirstate.normallookup(f) |
|
1243 | 1243 | for f in forget: |
|
1244 | 1244 | repo.dirstate.forget(f) |
|
1245 | 1245 | |
|
1246 | 1246 | if not msg: |
|
1247 | 1247 | if not ph.message: |
|
1248 | 1248 | message = "[mq]: %s\n" % patchfn |
|
1249 | 1249 | else: |
|
1250 | 1250 | message = "\n".join(ph.message) |
|
1251 | 1251 | else: |
|
1252 | 1252 | message = msg |
|
1253 | 1253 | |
|
1254 | 1254 | user = ph.user or changes[1] |
|
1255 | 1255 | |
|
1256 | 1256 | # assumes strip can roll itself back if interrupted |
|
1257 | 1257 | repo.dirstate.setparents(*cparents) |
|
1258 | 1258 | self.applied.pop() |
|
1259 | 1259 | self.applied_dirty = 1 |
|
1260 | 1260 | self.strip(repo, top, update=False, |
|
1261 | 1261 | backup='strip') |
|
1262 | 1262 | except: |
|
1263 | 1263 | repo.dirstate.invalidate() |
|
1264 | 1264 | raise |
|
1265 | 1265 | |
|
1266 | 1266 | try: |
|
1267 | 1267 | # might be nice to attempt to roll back strip after this |
|
1268 | 1268 | patchf.rename() |
|
1269 | 1269 | n = repo.commit(match.files(), message, user, ph.date, |
|
1270 | 1270 | match=match, force=1) |
|
1271 | 1271 | self.applied.append(statusentry(hex(n), patchfn)) |
|
1272 | 1272 | except: |
|
1273 | 1273 | ctx = repo[cparents[0]] |
|
1274 | 1274 | repo.dirstate.rebuild(ctx.node(), ctx.manifest()) |
|
1275 | 1275 | self.save_dirty() |
|
1276 | 1276 | self.ui.warn(_('refresh interrupted while patch was popped! ' |
|
1277 | 1277 | '(revert --all, qpush to recover)\n')) |
|
1278 | 1278 | raise |
|
1279 | 1279 | else: |
|
1280 | 1280 | self.printdiff(repo, patchparent, fp=patchf) |
|
1281 | 1281 | patchf.rename() |
|
1282 | 1282 | added = repo.status()[1] |
|
1283 | 1283 | for a in added: |
|
1284 | 1284 | f = repo.wjoin(a) |
|
1285 | 1285 | try: |
|
1286 | 1286 | os.unlink(f) |
|
1287 | 1287 | except OSError, e: |
|
1288 | 1288 | if e.errno != errno.ENOENT: |
|
1289 | 1289 | raise |
|
1290 | 1290 | try: os.removedirs(os.path.dirname(f)) |
|
1291 | 1291 | except: pass |
|
1292 | 1292 | # forget the file copies in the dirstate |
|
1293 | 1293 | # push should readd the files later on |
|
1294 | 1294 | repo.dirstate.forget(a) |
|
1295 | 1295 | self.pop(repo, force=True) |
|
1296 | 1296 | self.push(repo, force=True) |
|
1297 | 1297 | finally: |
|
1298 | 1298 | del wlock |
|
1299 | 1299 | self.removeundo(repo) |
|
1300 | 1300 | |
|
1301 | 1301 | def init(self, repo, create=False): |
|
1302 | 1302 | if not create and os.path.isdir(self.path): |
|
1303 | 1303 | raise util.Abort(_("patch queue directory already exists")) |
|
1304 | 1304 | try: |
|
1305 | 1305 | os.mkdir(self.path) |
|
1306 | 1306 | except OSError, inst: |
|
1307 | 1307 | if inst.errno != errno.EEXIST or not create: |
|
1308 | 1308 | raise |
|
1309 | 1309 | if create: |
|
1310 | 1310 | return self.qrepo(create=True) |
|
1311 | 1311 | |
|
1312 | 1312 | def unapplied(self, repo, patch=None): |
|
1313 | 1313 | if patch and patch not in self.series: |
|
1314 | 1314 | raise util.Abort(_("patch %s is not in series file") % patch) |
|
1315 | 1315 | if not patch: |
|
1316 | 1316 | start = self.series_end() |
|
1317 | 1317 | else: |
|
1318 | 1318 | start = self.series.index(patch) + 1 |
|
1319 | 1319 | unapplied = [] |
|
1320 | 1320 | for i in xrange(start, len(self.series)): |
|
1321 | 1321 | pushable, reason = self.pushable(i) |
|
1322 | 1322 | if pushable: |
|
1323 | 1323 | unapplied.append((i, self.series[i])) |
|
1324 | 1324 | self.explain_pushable(i) |
|
1325 | 1325 | return unapplied |
|
1326 | 1326 | |
|
1327 | 1327 | def qseries(self, repo, missing=None, start=0, length=None, status=None, |
|
1328 | 1328 | summary=False): |
|
1329 | 1329 | def displayname(patchname): |
|
1330 | 1330 | if summary: |
|
1331 | 1331 | ph = self.readheaders(patchname) |
|
1332 | 1332 | msg = ph.message |
|
1333 | 1333 | msg = msg and ': ' + msg[0] or ': ' |
|
1334 | 1334 | else: |
|
1335 | 1335 | msg = '' |
|
1336 | 1336 | return '%s%s' % (patchname, msg) |
|
1337 | 1337 | |
|
1338 | 1338 | applied = dict.fromkeys([p.name for p in self.applied]) |
|
1339 | 1339 | if length is None: |
|
1340 | 1340 | length = len(self.series) - start |
|
1341 | 1341 | if not missing: |
|
1342 | 1342 | for i in xrange(start, start+length): |
|
1343 | 1343 | patch = self.series[i] |
|
1344 | 1344 | if patch in applied: |
|
1345 | 1345 | stat = 'A' |
|
1346 | 1346 | elif self.pushable(i)[0]: |
|
1347 | 1347 | stat = 'U' |
|
1348 | 1348 | else: |
|
1349 | 1349 | stat = 'G' |
|
1350 | 1350 | pfx = '' |
|
1351 | 1351 | if self.ui.verbose: |
|
1352 | 1352 | pfx = '%d %s ' % (i, stat) |
|
1353 | 1353 | elif status and status != stat: |
|
1354 | 1354 | continue |
|
1355 | 1355 | self.ui.write('%s%s\n' % (pfx, displayname(patch))) |
|
1356 | 1356 | else: |
|
1357 | 1357 | msng_list = [] |
|
1358 | 1358 | for root, dirs, files in os.walk(self.path): |
|
1359 | 1359 | d = root[len(self.path) + 1:] |
|
1360 | 1360 | for f in files: |
|
1361 | 1361 | fl = os.path.join(d, f) |
|
1362 | 1362 | if (fl not in self.series and |
|
1363 | 1363 | fl not in (self.status_path, self.series_path, |
|
1364 | 1364 | self.guards_path) |
|
1365 | 1365 | and not fl.startswith('.')): |
|
1366 | 1366 | msng_list.append(fl) |
|
1367 | 1367 | for x in util.sort(msng_list): |
|
1368 | 1368 | pfx = self.ui.verbose and ('D ') or '' |
|
1369 | 1369 | self.ui.write("%s%s\n" % (pfx, displayname(x))) |
|
1370 | 1370 | |
|
1371 | 1371 | def issaveline(self, l): |
|
1372 | 1372 | if l.name == '.hg.patches.save.line': |
|
1373 | 1373 | return True |
|
1374 | 1374 | |
|
1375 | 1375 | def qrepo(self, create=False): |
|
1376 | 1376 | if create or os.path.isdir(self.join(".hg")): |
|
1377 | 1377 | return hg.repository(self.ui, path=self.path, create=create) |
|
1378 | 1378 | |
|
1379 | 1379 | def restore(self, repo, rev, delete=None, qupdate=None): |
|
1380 | 1380 | c = repo.changelog.read(rev) |
|
1381 | 1381 | desc = c[4].strip() |
|
1382 | 1382 | lines = desc.splitlines() |
|
1383 | 1383 | i = 0 |
|
1384 | 1384 | datastart = None |
|
1385 | 1385 | series = [] |
|
1386 | 1386 | applied = [] |
|
1387 | 1387 | qpp = None |
|
1388 | 1388 | for i in xrange(0, len(lines)): |
|
1389 | 1389 | if lines[i] == 'Patch Data:': |
|
1390 | 1390 | datastart = i + 1 |
|
1391 | 1391 | elif lines[i].startswith('Dirstate:'): |
|
1392 | 1392 | l = lines[i].rstrip() |
|
1393 | 1393 | l = l[10:].split(' ') |
|
1394 | 1394 | qpp = [ bin(x) for x in l ] |
|
1395 | 1395 | elif datastart != None: |
|
1396 | 1396 | l = lines[i].rstrip() |
|
1397 | 1397 | se = statusentry(l) |
|
1398 | 1398 | file_ = se.name |
|
1399 | 1399 | if se.rev: |
|
1400 | 1400 | applied.append(se) |
|
1401 | 1401 | else: |
|
1402 | 1402 | series.append(file_) |
|
1403 | 1403 | if datastart == None: |
|
1404 | 1404 | self.ui.warn(_("No saved patch data found\n")) |
|
1405 | 1405 | return 1 |
|
1406 | 1406 | self.ui.warn(_("restoring status: %s\n") % lines[0]) |
|
1407 | 1407 | self.full_series = series |
|
1408 | 1408 | self.applied = applied |
|
1409 | 1409 | self.parse_series() |
|
1410 | 1410 | self.series_dirty = 1 |
|
1411 | 1411 | self.applied_dirty = 1 |
|
1412 | 1412 | heads = repo.changelog.heads() |
|
1413 | 1413 | if delete: |
|
1414 | 1414 | if rev not in heads: |
|
1415 | 1415 | self.ui.warn(_("save entry has children, leaving it alone\n")) |
|
1416 | 1416 | else: |
|
1417 | 1417 | self.ui.warn(_("removing save entry %s\n") % short(rev)) |
|
1418 | 1418 | pp = repo.dirstate.parents() |
|
1419 | 1419 | if rev in pp: |
|
1420 | 1420 | update = True |
|
1421 | 1421 | else: |
|
1422 | 1422 | update = False |
|
1423 | 1423 | self.strip(repo, rev, update=update, backup='strip') |
|
1424 | 1424 | if qpp: |
|
1425 | 1425 | self.ui.warn(_("saved queue repository parents: %s %s\n") % |
|
1426 | 1426 | (short(qpp[0]), short(qpp[1]))) |
|
1427 | 1427 | if qupdate: |
|
1428 | 1428 | self.ui.status(_("queue directory updating\n")) |
|
1429 | 1429 | r = self.qrepo() |
|
1430 | 1430 | if not r: |
|
1431 | 1431 | self.ui.warn(_("Unable to load queue repository\n")) |
|
1432 | 1432 | return 1 |
|
1433 | 1433 | hg.clean(r, qpp[0]) |
|
1434 | 1434 | |
|
1435 | 1435 | def save(self, repo, msg=None): |
|
1436 | 1436 | if len(self.applied) == 0: |
|
1437 | 1437 | self.ui.warn(_("save: no patches applied, exiting\n")) |
|
1438 | 1438 | return 1 |
|
1439 | 1439 | if self.issaveline(self.applied[-1]): |
|
1440 | 1440 | self.ui.warn(_("status is already saved\n")) |
|
1441 | 1441 | return 1 |
|
1442 | 1442 | |
|
1443 | 1443 | ar = [ ':' + x for x in self.full_series ] |
|
1444 | 1444 | if not msg: |
|
1445 | 1445 | msg = _("hg patches saved state") |
|
1446 | 1446 | else: |
|
1447 | 1447 | msg = "hg patches: " + msg.rstrip('\r\n') |
|
1448 | 1448 | r = self.qrepo() |
|
1449 | 1449 | if r: |
|
1450 | 1450 | pp = r.dirstate.parents() |
|
1451 | 1451 | msg += "\nDirstate: %s %s" % (hex(pp[0]), hex(pp[1])) |
|
1452 | 1452 | msg += "\n\nPatch Data:\n" |
|
1453 | 1453 | text = msg + "\n".join([str(x) for x in self.applied]) + '\n' + (ar and |
|
1454 | 1454 | "\n".join(ar) + '\n' or "") |
|
1455 | 1455 | n = repo.commit(None, text, user=None, force=1) |
|
1456 | 1456 | if not n: |
|
1457 | 1457 | self.ui.warn(_("repo commit failed\n")) |
|
1458 | 1458 | return 1 |
|
1459 | 1459 | self.applied.append(statusentry(hex(n),'.hg.patches.save.line')) |
|
1460 | 1460 | self.applied_dirty = 1 |
|
1461 | 1461 | self.removeundo(repo) |
|
1462 | 1462 | |
|
1463 | 1463 | def full_series_end(self): |
|
1464 | 1464 | if len(self.applied) > 0: |
|
1465 | 1465 | p = self.applied[-1].name |
|
1466 | 1466 | end = self.find_series(p) |
|
1467 | 1467 | if end == None: |
|
1468 | 1468 | return len(self.full_series) |
|
1469 | 1469 | return end + 1 |
|
1470 | 1470 | return 0 |
|
1471 | 1471 | |
|
1472 | 1472 | def series_end(self, all_patches=False): |
|
1473 | 1473 | """If all_patches is False, return the index of the next pushable patch |
|
1474 | 1474 | in the series, or the series length. If all_patches is True, return the |
|
1475 | 1475 | index of the first patch past the last applied one. |
|
1476 | 1476 | """ |
|
1477 | 1477 | end = 0 |
|
1478 | 1478 | def next(start): |
|
1479 | 1479 | if all_patches: |
|
1480 | 1480 | return start |
|
1481 | 1481 | i = start |
|
1482 | 1482 | while i < len(self.series): |
|
1483 | 1483 | p, reason = self.pushable(i) |
|
1484 | 1484 | if p: |
|
1485 | 1485 | break |
|
1486 | 1486 | self.explain_pushable(i) |
|
1487 | 1487 | i += 1 |
|
1488 | 1488 | return i |
|
1489 | 1489 | if len(self.applied) > 0: |
|
1490 | 1490 | p = self.applied[-1].name |
|
1491 | 1491 | try: |
|
1492 | 1492 | end = self.series.index(p) |
|
1493 | 1493 | except ValueError: |
|
1494 | 1494 | return 0 |
|
1495 | 1495 | return next(end + 1) |
|
1496 | 1496 | return next(end) |
|
1497 | 1497 | |
|
1498 | 1498 | def appliedname(self, index): |
|
1499 | 1499 | pname = self.applied[index].name |
|
1500 | 1500 | if not self.ui.verbose: |
|
1501 | 1501 | p = pname |
|
1502 | 1502 | else: |
|
1503 | 1503 | p = str(self.series.index(pname)) + " " + pname |
|
1504 | 1504 | return p |
|
1505 | 1505 | |
|
1506 | 1506 | def qimport(self, repo, files, patchname=None, rev=None, existing=None, |
|
1507 | 1507 | force=None, git=False): |
|
1508 | 1508 | def checkseries(patchname): |
|
1509 | 1509 | if patchname in self.series: |
|
1510 | 1510 | raise util.Abort(_('patch %s is already in the series file') |
|
1511 | 1511 | % patchname) |
|
1512 | 1512 | def checkfile(patchname): |
|
1513 | 1513 | if not force and os.path.exists(self.join(patchname)): |
|
1514 | 1514 | raise util.Abort(_('patch "%s" already exists') |
|
1515 | 1515 | % patchname) |
|
1516 | 1516 | |
|
1517 | 1517 | if rev: |
|
1518 | 1518 | if files: |
|
1519 | 1519 | raise util.Abort(_('option "-r" not valid when importing ' |
|
1520 | 1520 | 'files')) |
|
1521 | 1521 | rev = cmdutil.revrange(repo, rev) |
|
1522 | 1522 | rev.sort(lambda x, y: cmp(y, x)) |
|
1523 | 1523 | if (len(files) > 1 or len(rev) > 1) and patchname: |
|
1524 | 1524 | raise util.Abort(_('option "-n" not valid when importing multiple ' |
|
1525 | 1525 | 'patches')) |
|
1526 | 1526 | i = 0 |
|
1527 | 1527 | added = [] |
|
1528 | 1528 | if rev: |
|
1529 | 1529 | # If mq patches are applied, we can only import revisions |
|
1530 | 1530 | # that form a linear path to qbase. |
|
1531 | 1531 | # Otherwise, they should form a linear path to a head. |
|
1532 | 1532 | heads = repo.changelog.heads(repo.changelog.node(rev[-1])) |
|
1533 | 1533 | if len(heads) > 1: |
|
1534 | 1534 | raise util.Abort(_('revision %d is the root of more than one ' |
|
1535 | 1535 | 'branch') % rev[-1]) |
|
1536 | 1536 | if self.applied: |
|
1537 | 1537 | base = hex(repo.changelog.node(rev[0])) |
|
1538 | 1538 | if base in [n.rev for n in self.applied]: |
|
1539 | 1539 | raise util.Abort(_('revision %d is already managed') |
|
1540 | 1540 | % rev[0]) |
|
1541 | 1541 | if heads != [bin(self.applied[-1].rev)]: |
|
1542 | 1542 | raise util.Abort(_('revision %d is not the parent of ' |
|
1543 | 1543 | 'the queue') % rev[0]) |
|
1544 | 1544 | base = repo.changelog.rev(bin(self.applied[0].rev)) |
|
1545 | 1545 | lastparent = repo.changelog.parentrevs(base)[0] |
|
1546 | 1546 | else: |
|
1547 | 1547 | if heads != [repo.changelog.node(rev[0])]: |
|
1548 | 1548 | raise util.Abort(_('revision %d has unmanaged children') |
|
1549 | 1549 | % rev[0]) |
|
1550 | 1550 | lastparent = None |
|
1551 | 1551 | |
|
1552 | 1552 | if git: |
|
1553 | 1553 | self.diffopts().git = True |
|
1554 | 1554 | |
|
1555 | 1555 | for r in rev: |
|
1556 | 1556 | p1, p2 = repo.changelog.parentrevs(r) |
|
1557 | 1557 | n = repo.changelog.node(r) |
|
1558 | 1558 | if p2 != nullrev: |
|
1559 | 1559 | raise util.Abort(_('cannot import merge revision %d') % r) |
|
1560 | 1560 | if lastparent and lastparent != r: |
|
1561 | 1561 | raise util.Abort(_('revision %d is not the parent of %d') |
|
1562 | 1562 | % (r, lastparent)) |
|
1563 | 1563 | lastparent = p1 |
|
1564 | 1564 | |
|
1565 | 1565 | if not patchname: |
|
1566 | 1566 | patchname = normname('%d.diff' % r) |
|
1567 | 1567 | self.check_reserved_name(patchname) |
|
1568 | 1568 | checkseries(patchname) |
|
1569 | 1569 | checkfile(patchname) |
|
1570 | 1570 | self.full_series.insert(0, patchname) |
|
1571 | 1571 | |
|
1572 | 1572 | patchf = self.opener(patchname, "w") |
|
1573 | 1573 | patch.export(repo, [n], fp=patchf, opts=self.diffopts()) |
|
1574 | 1574 | patchf.close() |
|
1575 | 1575 | |
|
1576 | 1576 | se = statusentry(hex(n), patchname) |
|
1577 | 1577 | self.applied.insert(0, se) |
|
1578 | 1578 | |
|
1579 | 1579 | added.append(patchname) |
|
1580 | 1580 | patchname = None |
|
1581 | 1581 | self.parse_series() |
|
1582 | 1582 | self.applied_dirty = 1 |
|
1583 | 1583 | |
|
1584 | 1584 | for filename in files: |
|
1585 | 1585 | if existing: |
|
1586 | 1586 | if filename == '-': |
|
1587 | 1587 | raise util.Abort(_('-e is incompatible with import from -')) |
|
1588 | 1588 | if not patchname: |
|
1589 | 1589 | patchname = normname(filename) |
|
1590 | 1590 | self.check_reserved_name(patchname) |
|
1591 | 1591 | if not os.path.isfile(self.join(patchname)): |
|
1592 | 1592 | raise util.Abort(_("patch %s does not exist") % patchname) |
|
1593 | 1593 | else: |
|
1594 | 1594 | try: |
|
1595 | 1595 | if filename == '-': |
|
1596 | 1596 | if not patchname: |
|
1597 | 1597 | raise util.Abort(_('need --name to import a patch from -')) |
|
1598 | 1598 | text = sys.stdin.read() |
|
1599 | 1599 | else: |
|
1600 | 1600 | text = url.open(self.ui, filename).read() |
|
1601 | 1601 | except (OSError, IOError): |
|
1602 | 1602 | raise util.Abort(_("unable to read %s") % filename) |
|
1603 | 1603 | if not patchname: |
|
1604 | 1604 | patchname = normname(os.path.basename(filename)) |
|
1605 | 1605 | self.check_reserved_name(patchname) |
|
1606 | 1606 | checkfile(patchname) |
|
1607 | 1607 | patchf = self.opener(patchname, "w") |
|
1608 | 1608 | patchf.write(text) |
|
1609 | 1609 | if not force: |
|
1610 | 1610 | checkseries(patchname) |
|
1611 | 1611 | if patchname not in self.series: |
|
1612 | 1612 | index = self.full_series_end() + i |
|
1613 | 1613 | self.full_series[index:index] = [patchname] |
|
1614 | 1614 | self.parse_series() |
|
1615 | 1615 | self.ui.warn(_("adding %s to series file\n") % patchname) |
|
1616 | 1616 | i += 1 |
|
1617 | 1617 | added.append(patchname) |
|
1618 | 1618 | patchname = None |
|
1619 | 1619 | self.series_dirty = 1 |
|
1620 | 1620 | qrepo = self.qrepo() |
|
1621 | 1621 | if qrepo: |
|
1622 | 1622 | qrepo.add(added) |
|
1623 | 1623 | |
|
1624 | 1624 | def delete(ui, repo, *patches, **opts): |
|
1625 | 1625 | """remove patches from queue |
|
1626 | 1626 | |
|
1627 | 1627 | The patches must not be applied, unless they are arguments to the |
|
1628 | 1628 | --rev parameter. At least one patch or revision is required. |
|
1629 | 1629 | |
|
1630 | 1630 | With --rev, mq will stop managing the named revisions (converting |
|
1631 | 1631 | them to regular mercurial changesets). The qfinish command should |
|
1632 | 1632 | be used as an alternative for qdel -r, as the latter option is |
|
1633 | 1633 | deprecated. |
|
1634 | 1634 | |
|
1635 | 1635 | With --keep, the patch files are preserved in the patch |
|
1636 | 1636 | directory.""" |
|
1637 | 1637 | q = repo.mq |
|
1638 | 1638 | q.delete(repo, patches, opts) |
|
1639 | 1639 | q.save_dirty() |
|
1640 | 1640 | return 0 |
|
1641 | 1641 | |
|
1642 | 1642 | def applied(ui, repo, patch=None, **opts): |
|
1643 | 1643 | """print the patches already applied""" |
|
1644 | 1644 | q = repo.mq |
|
1645 | 1645 | if patch: |
|
1646 | 1646 | if patch not in q.series: |
|
1647 | 1647 | raise util.Abort(_("patch %s is not in series file") % patch) |
|
1648 | 1648 | end = q.series.index(patch) + 1 |
|
1649 | 1649 | else: |
|
1650 | 1650 | end = q.series_end(True) |
|
1651 | 1651 | return q.qseries(repo, length=end, status='A', summary=opts.get('summary')) |
|
1652 | 1652 | |
|
1653 | 1653 | def unapplied(ui, repo, patch=None, **opts): |
|
1654 | 1654 | """print the patches not yet applied""" |
|
1655 | 1655 | q = repo.mq |
|
1656 | 1656 | if patch: |
|
1657 | 1657 | if patch not in q.series: |
|
1658 | 1658 | raise util.Abort(_("patch %s is not in series file") % patch) |
|
1659 | 1659 | start = q.series.index(patch) + 1 |
|
1660 | 1660 | else: |
|
1661 | 1661 | start = q.series_end(True) |
|
1662 | 1662 | q.qseries(repo, start=start, status='U', summary=opts.get('summary')) |
|
1663 | 1663 | |
|
1664 | 1664 | def qimport(ui, repo, *filename, **opts): |
|
1665 | 1665 | """import a patch |
|
1666 | 1666 | |
|
1667 | 1667 | The patch is inserted into the series after the last applied |
|
1668 | 1668 | patch. If no patches have been applied, qimport prepends the patch |
|
1669 | 1669 | to the series. |
|
1670 | 1670 | |
|
1671 | 1671 | The patch will have the same name as its source file unless you |
|
1672 | 1672 | give it a new one with --name. |
|
1673 | 1673 | |
|
1674 | 1674 | You can register an existing patch inside the patch directory with |
|
1675 | 1675 | the --existing flag. |
|
1676 | 1676 | |
|
1677 | 1677 | With --force, an existing patch of the same name will be |
|
1678 | 1678 | overwritten. |
|
1679 | 1679 | |
|
1680 | 1680 | An existing changeset may be placed under mq control with --rev |
|
1681 | 1681 | (e.g. qimport --rev tip -n patch will place tip under mq control). |
|
1682 | 1682 | With --git, patches imported with --rev will use the git diff |
|
1683 | 1683 | format. See the diffs help topic for information on why this is |
|
1684 | 1684 | important for preserving rename/copy information and permission |
|
1685 | 1685 | changes. |
|
1686 | 1686 | """ |
|
1687 | 1687 | q = repo.mq |
|
1688 | 1688 | q.qimport(repo, filename, patchname=opts['name'], |
|
1689 | 1689 | existing=opts['existing'], force=opts['force'], rev=opts['rev'], |
|
1690 | 1690 | git=opts['git']) |
|
1691 | 1691 | q.save_dirty() |
|
1692 | 1692 | return 0 |
|
1693 | 1693 | |
|
1694 | 1694 | def init(ui, repo, **opts): |
|
1695 | 1695 | """init a new queue repository |
|
1696 | 1696 | |
|
1697 | 1697 | The queue repository is unversioned by default. If -c is |
|
1698 | 1698 | specified, qinit will create a separate nested repository for |
|
1699 | 1699 | patches (qinit -c may also be run later to convert an unversioned |
|
1700 | 1700 | patch repository into a versioned one). You can use qcommit to |
|
1701 | 1701 | commit changes to this queue repository.""" |
|
1702 | 1702 | q = repo.mq |
|
1703 | 1703 | r = q.init(repo, create=opts['create_repo']) |
|
1704 | 1704 | q.save_dirty() |
|
1705 | 1705 | if r: |
|
1706 | 1706 | if not os.path.exists(r.wjoin('.hgignore')): |
|
1707 | 1707 | fp = r.wopener('.hgignore', 'w') |
|
1708 | 1708 | fp.write('^\\.hg\n') |
|
1709 | 1709 | fp.write('^\\.mq\n') |
|
1710 | 1710 | fp.write('syntax: glob\n') |
|
1711 | 1711 | fp.write('status\n') |
|
1712 | 1712 | fp.write('guards\n') |
|
1713 | 1713 | fp.close() |
|
1714 | 1714 | if not os.path.exists(r.wjoin('series')): |
|
1715 | 1715 | r.wopener('series', 'w').close() |
|
1716 | 1716 | r.add(['.hgignore', 'series']) |
|
1717 | 1717 | commands.add(ui, r) |
|
1718 | 1718 | return 0 |
|
1719 | 1719 | |
|
1720 | 1720 | def clone(ui, source, dest=None, **opts): |
|
1721 | 1721 | '''clone main and patch repository at same time |
|
1722 | 1722 | |
|
1723 | 1723 | If source is local, destination will have no patches applied. If |
|
1724 | 1724 | source is remote, this command can not check if patches are |
|
1725 | 1725 | applied in source, so cannot guarantee that patches are not |
|
1726 | 1726 | applied in destination. If you clone remote repository, be sure |
|
1727 | 1727 | before that it has no patches applied. |
|
1728 | 1728 | |
|
1729 | 1729 | Source patch repository is looked for in <src>/.hg/patches by |
|
1730 | 1730 | default. Use -p <url> to change. |
|
1731 | 1731 | |
|
1732 | 1732 | The patch directory must be a nested mercurial repository, as |
|
1733 | 1733 | would be created by qinit -c. |
|
1734 | 1734 | ''' |
|
1735 | 1735 | def patchdir(repo): |
|
1736 | 1736 | url = repo.url() |
|
1737 | 1737 | if url.endswith('/'): |
|
1738 | 1738 | url = url[:-1] |
|
1739 | 1739 | return url + '/.hg/patches' |
|
1740 | 1740 | cmdutil.setremoteconfig(ui, opts) |
|
1741 | 1741 | if dest is None: |
|
1742 | 1742 | dest = hg.defaultdest(source) |
|
1743 | 1743 | sr = hg.repository(ui, ui.expandpath(source)) |
|
1744 | 1744 | if opts['patches']: |
|
1745 | 1745 | patchespath = ui.expandpath(opts['patches']) |
|
1746 | 1746 | else: |
|
1747 | 1747 | patchespath = patchdir(sr) |
|
1748 | 1748 | try: |
|
1749 | 1749 | hg.repository(ui, patchespath) |
|
1750 | 1750 | except error.RepoError: |
|
1751 | 1751 | raise util.Abort(_('versioned patch repository not found' |
|
1752 | 1752 | ' (see qinit -c)')) |
|
1753 | 1753 | qbase, destrev = None, None |
|
1754 | 1754 | if sr.local(): |
|
1755 | 1755 | if sr.mq.applied: |
|
1756 | 1756 | qbase = bin(sr.mq.applied[0].rev) |
|
1757 | 1757 | if not hg.islocal(dest): |
|
1758 | 1758 | heads = dict.fromkeys(sr.heads()) |
|
1759 | 1759 | for h in sr.heads(qbase): |
|
1760 | 1760 | del heads[h] |
|
1761 | 1761 | destrev = heads.keys() |
|
1762 | 1762 | destrev.append(sr.changelog.parents(qbase)[0]) |
|
1763 | 1763 | elif sr.capable('lookup'): |
|
1764 | 1764 | try: |
|
1765 | 1765 | qbase = sr.lookup('qbase') |
|
1766 | 1766 | except error.RepoError: |
|
1767 | 1767 | pass |
|
1768 | 1768 | ui.note(_('cloning main repo\n')) |
|
1769 | 1769 | sr, dr = hg.clone(ui, sr.url(), dest, |
|
1770 | 1770 | pull=opts['pull'], |
|
1771 | 1771 | rev=destrev, |
|
1772 | 1772 | update=False, |
|
1773 | 1773 | stream=opts['uncompressed']) |
|
1774 | 1774 | ui.note(_('cloning patch repo\n')) |
|
1775 | 1775 | hg.clone(ui, opts['patches'] or patchdir(sr), patchdir(dr), |
|
1776 | 1776 | pull=opts['pull'], update=not opts['noupdate'], |
|
1777 | 1777 | stream=opts['uncompressed']) |
|
1778 | 1778 | if dr.local(): |
|
1779 | 1779 | if qbase: |
|
1780 | 1780 | ui.note(_('stripping applied patches from destination repo\n')) |
|
1781 | 1781 | dr.mq.strip(dr, qbase, update=False, backup=None) |
|
1782 | 1782 | if not opts['noupdate']: |
|
1783 | 1783 | ui.note(_('updating destination repo\n')) |
|
1784 | 1784 | hg.update(dr, dr.changelog.tip()) |
|
1785 | 1785 | |
|
1786 | 1786 | def commit(ui, repo, *pats, **opts): |
|
1787 | 1787 | """commit changes in the queue repository""" |
|
1788 | 1788 | q = repo.mq |
|
1789 | 1789 | r = q.qrepo() |
|
1790 | 1790 | if not r: raise util.Abort('no queue repository') |
|
1791 | 1791 | commands.commit(r.ui, r, *pats, **opts) |
|
1792 | 1792 | |
|
1793 | 1793 | def series(ui, repo, **opts): |
|
1794 | 1794 | """print the entire series file""" |
|
1795 | 1795 | repo.mq.qseries(repo, missing=opts['missing'], summary=opts['summary']) |
|
1796 | 1796 | return 0 |
|
1797 | 1797 | |
|
1798 | 1798 | def top(ui, repo, **opts): |
|
1799 | 1799 | """print the name of the current patch""" |
|
1800 | 1800 | q = repo.mq |
|
1801 | 1801 | t = q.applied and q.series_end(True) or 0 |
|
1802 | 1802 | if t: |
|
1803 | 1803 | return q.qseries(repo, start=t-1, length=1, status='A', |
|
1804 | 1804 | summary=opts.get('summary')) |
|
1805 | 1805 | else: |
|
1806 | 1806 | ui.write(_("no patches applied\n")) |
|
1807 | 1807 | return 1 |
|
1808 | 1808 | |
|
1809 | 1809 | def next(ui, repo, **opts): |
|
1810 | 1810 | """print the name of the next patch""" |
|
1811 | 1811 | q = repo.mq |
|
1812 | 1812 | end = q.series_end() |
|
1813 | 1813 | if end == len(q.series): |
|
1814 | 1814 | ui.write(_("all patches applied\n")) |
|
1815 | 1815 | return 1 |
|
1816 | 1816 | return q.qseries(repo, start=end, length=1, summary=opts.get('summary')) |
|
1817 | 1817 | |
|
1818 | 1818 | def prev(ui, repo, **opts): |
|
1819 | 1819 | """print the name of the previous patch""" |
|
1820 | 1820 | q = repo.mq |
|
1821 | 1821 | l = len(q.applied) |
|
1822 | 1822 | if l == 1: |
|
1823 | 1823 | ui.write(_("only one patch applied\n")) |
|
1824 | 1824 | return 1 |
|
1825 | 1825 | if not l: |
|
1826 | 1826 | ui.write(_("no patches applied\n")) |
|
1827 | 1827 | return 1 |
|
1828 | 1828 | return q.qseries(repo, start=l-2, length=1, status='A', |
|
1829 | 1829 | summary=opts.get('summary')) |
|
1830 | 1830 | |
|
1831 | 1831 | def setupheaderopts(ui, opts): |
|
1832 | 1832 | def do(opt,val): |
|
1833 | 1833 | if not opts[opt] and opts['current' + opt]: |
|
1834 | 1834 | opts[opt] = val |
|
1835 | 1835 | do('user', ui.username()) |
|
1836 | 1836 | do('date', "%d %d" % util.makedate()) |
|
1837 | 1837 | |
|
1838 | 1838 | def new(ui, repo, patch, *args, **opts): |
|
1839 | 1839 | """create a new patch |
|
1840 | 1840 | |
|
1841 | 1841 | qnew creates a new patch on top of the currently-applied patch (if |
|
1842 | 1842 | any). It will refuse to run if there are any outstanding changes |
|
1843 | 1843 | unless -f is specified, in which case the patch will be |
|
1844 | 1844 | initialized with them. You may also use -I, -X, and/or a list of |
|
1845 | 1845 | files after the patch name to add only changes to matching files |
|
1846 | 1846 | to the new patch, leaving the rest as uncommitted modifications. |
|
1847 | 1847 | |
|
1848 | 1848 | -u and -d can be used to set the (given) user and date, respectively. |
|
1849 | 1849 | -U and -D set user to current user and date to current date. |
|
1850 | 1850 | |
|
1851 | 1851 | -e, -m or -l set the patch header as well as the commit message. |
|
1852 | 1852 | If none is specified, the header is empty and the commit message |
|
1853 | 1853 | is '[mq]: PATCH'. |
|
1854 | 1854 | |
|
1855 | 1855 | Use the --git option to keep the patch in the git extended diff |
|
1856 | 1856 | format. Read the diffs help topic for more information on why this |
|
1857 | 1857 | is important for preserving permission changes and copy/rename |
|
1858 | 1858 | information. |
|
1859 | 1859 | """ |
|
1860 | 1860 | msg = cmdutil.logmessage(opts) |
|
1861 | 1861 | def getmsg(): return ui.edit(msg, ui.username()) |
|
1862 | 1862 | q = repo.mq |
|
1863 | 1863 | opts['msg'] = msg |
|
1864 | 1864 | if opts.get('edit'): |
|
1865 | 1865 | opts['msg'] = getmsg |
|
1866 | 1866 | else: |
|
1867 | 1867 | opts['msg'] = msg |
|
1868 | 1868 | setupheaderopts(ui, opts) |
|
1869 | 1869 | q.new(repo, patch, *args, **opts) |
|
1870 | 1870 | q.save_dirty() |
|
1871 | 1871 | return 0 |
|
1872 | 1872 | |
|
1873 | 1873 | def refresh(ui, repo, *pats, **opts): |
|
1874 | 1874 | """update the current patch |
|
1875 | 1875 | |
|
1876 | 1876 | If any file patterns are provided, the refreshed patch will |
|
1877 | 1877 | contain only the modifications that match those patterns; the |
|
1878 | 1878 | remaining modifications will remain in the working directory. |
|
1879 | 1879 | |
|
1880 | 1880 | If --short is specified, files currently included in the patch |
|
1881 | 1881 | will be refreshed just like matched files and remain in the patch. |
|
1882 | 1882 | |
|
1883 | 1883 | hg add/remove/copy/rename work as usual, though you might want to |
|
1884 | 1884 | use git-style patches (--git or [diff] git=1) to track copies and |
|
1885 | 1885 | renames. See the diffs help topic for more information on the git |
|
1886 | 1886 | diff format. |
|
1887 | 1887 | """ |
|
1888 | 1888 | q = repo.mq |
|
1889 | 1889 | message = cmdutil.logmessage(opts) |
|
1890 | 1890 | if opts['edit']: |
|
1891 | 1891 | if not q.applied: |
|
1892 | 1892 | ui.write(_("no patches applied\n")) |
|
1893 | 1893 | return 1 |
|
1894 | 1894 | if message: |
|
1895 | 1895 | raise util.Abort(_('option "-e" incompatible with "-m" or "-l"')) |
|
1896 | 1896 | patch = q.applied[-1].name |
|
1897 | 1897 | ph = q.readheaders(patch) |
|
1898 | 1898 | message = ui.edit('\n'.join(ph.message), ph.user or ui.username()) |
|
1899 | 1899 | setupheaderopts(ui, opts) |
|
1900 | 1900 | ret = q.refresh(repo, pats, msg=message, **opts) |
|
1901 | 1901 | q.save_dirty() |
|
1902 | 1902 | return ret |
|
1903 | 1903 | |
|
1904 | 1904 | def diff(ui, repo, *pats, **opts): |
|
1905 | 1905 | """diff of the current patch and subsequent modifications |
|
1906 | 1906 | |
|
1907 | 1907 | Shows a diff which includes the current patch as well as any |
|
1908 | 1908 | changes which have been made in the working directory since the |
|
1909 | 1909 | last refresh (thus showing what the current patch would become |
|
1910 | 1910 | after a qrefresh). |
|
1911 | 1911 | |
|
1912 | 1912 | Use 'hg diff' if you only want to see the changes made since the |
|
1913 | 1913 | last qrefresh, or 'hg export qtip' if you want to see changes made |
|
1914 | 1914 | by the current patch without including changes made since the |
|
1915 | 1915 | qrefresh. |
|
1916 | 1916 | """ |
|
1917 | 1917 | repo.mq.diff(repo, pats, opts) |
|
1918 | 1918 | return 0 |
|
1919 | 1919 | |
|
1920 | 1920 | def fold(ui, repo, *files, **opts): |
|
1921 | 1921 | """fold the named patches into the current patch |
|
1922 | 1922 | |
|
1923 | 1923 | Patches must not yet be applied. Each patch will be successively |
|
1924 | 1924 | applied to the current patch in the order given. If all the |
|
1925 | 1925 | patches apply successfully, the current patch will be refreshed |
|
1926 | 1926 | with the new cumulative patch, and the folded patches will be |
|
1927 | 1927 | deleted. With -k/--keep, the folded patch files will not be |
|
1928 | 1928 | removed afterwards. |
|
1929 | 1929 | |
|
1930 | 1930 | The header for each folded patch will be concatenated with the |
|
1931 | 1931 | current patch header, separated by a line of '* * *'.""" |
|
1932 | 1932 | |
|
1933 | 1933 | q = repo.mq |
|
1934 | 1934 | |
|
1935 | 1935 | if not files: |
|
1936 | 1936 | raise util.Abort(_('qfold requires at least one patch name')) |
|
1937 | 1937 | if not q.check_toppatch(repo): |
|
1938 | 1938 | raise util.Abort(_('No patches applied')) |
|
1939 | 1939 | |
|
1940 | 1940 | message = cmdutil.logmessage(opts) |
|
1941 | 1941 | if opts['edit']: |
|
1942 | 1942 | if message: |
|
1943 | 1943 | raise util.Abort(_('option "-e" incompatible with "-m" or "-l"')) |
|
1944 | 1944 | |
|
1945 | 1945 | parent = q.lookup('qtip') |
|
1946 | 1946 | patches = [] |
|
1947 | 1947 | messages = [] |
|
1948 | 1948 | for f in files: |
|
1949 | 1949 | p = q.lookup(f) |
|
1950 | 1950 | if p in patches or p == parent: |
|
1951 | 1951 | ui.warn(_('Skipping already folded patch %s') % p) |
|
1952 | 1952 | if q.isapplied(p): |
|
1953 | 1953 | raise util.Abort(_('qfold cannot fold already applied patch %s') % p) |
|
1954 | 1954 | patches.append(p) |
|
1955 | 1955 | |
|
1956 | 1956 | for p in patches: |
|
1957 | 1957 | if not message: |
|
1958 | 1958 | ph = q.readheaders(p) |
|
1959 | 1959 | if ph.message: |
|
1960 | 1960 | messages.append(ph.message) |
|
1961 | 1961 | pf = q.join(p) |
|
1962 | 1962 | (patchsuccess, files, fuzz) = q.patch(repo, pf) |
|
1963 | 1963 | if not patchsuccess: |
|
1964 | 1964 | raise util.Abort(_('Error folding patch %s') % p) |
|
1965 | 1965 | patch.updatedir(ui, repo, files) |
|
1966 | 1966 | |
|
1967 | 1967 | if not message: |
|
1968 | 1968 | ph = q.readheaders(parent) |
|
1969 | 1969 | message, user = ph.message, ph.user |
|
1970 | 1970 | for msg in messages: |
|
1971 | 1971 | message.append('* * *') |
|
1972 | 1972 | message.extend(msg) |
|
1973 | 1973 | message = '\n'.join(message) |
|
1974 | 1974 | |
|
1975 | 1975 | if opts['edit']: |
|
1976 | 1976 | message = ui.edit(message, user or ui.username()) |
|
1977 | 1977 | |
|
1978 | 1978 | q.refresh(repo, msg=message) |
|
1979 | 1979 | q.delete(repo, patches, opts) |
|
1980 | 1980 | q.save_dirty() |
|
1981 | 1981 | |
|
1982 | 1982 | def goto(ui, repo, patch, **opts): |
|
1983 | 1983 | '''push or pop patches until named patch is at top of stack''' |
|
1984 | 1984 | q = repo.mq |
|
1985 | 1985 | patch = q.lookup(patch) |
|
1986 | 1986 | if q.isapplied(patch): |
|
1987 | 1987 | ret = q.pop(repo, patch, force=opts['force']) |
|
1988 | 1988 | else: |
|
1989 | 1989 | ret = q.push(repo, patch, force=opts['force']) |
|
1990 | 1990 | q.save_dirty() |
|
1991 | 1991 | return ret |
|
1992 | 1992 | |
|
1993 | 1993 | def guard(ui, repo, *args, **opts): |
|
1994 | 1994 | '''set or print guards for a patch |
|
1995 | 1995 | |
|
1996 | 1996 | Guards control whether a patch can be pushed. A patch with no |
|
1997 | 1997 | guards is always pushed. A patch with a positive guard ("+foo") is |
|
1998 | 1998 | pushed only if the qselect command has activated it. A patch with |
|
1999 | 1999 | a negative guard ("-foo") is never pushed if the qselect command |
|
2000 | 2000 | has activated it. |
|
2001 | 2001 | |
|
2002 | 2002 | With no arguments, print the currently active guards. |
|
2003 | 2003 | With arguments, set guards for the named patch. |
|
2004 | 2004 | NOTE: Specifying negative guards now requires '--'. |
|
2005 | 2005 | |
|
2006 | 2006 | To set guards on another patch: |
|
2007 | 2007 | hg qguard -- other.patch +2.6.17 -stable |
|
2008 | 2008 | ''' |
|
2009 | 2009 | def status(idx): |
|
2010 | 2010 | guards = q.series_guards[idx] or ['unguarded'] |
|
2011 | 2011 | ui.write('%s: %s\n' % (q.series[idx], ' '.join(guards))) |
|
2012 | 2012 | q = repo.mq |
|
2013 | 2013 | patch = None |
|
2014 | 2014 | args = list(args) |
|
2015 | 2015 | if opts['list']: |
|
2016 | 2016 | if args or opts['none']: |
|
2017 | 2017 | raise util.Abort(_('cannot mix -l/--list with options or arguments')) |
|
2018 | 2018 | for i in xrange(len(q.series)): |
|
2019 | 2019 | status(i) |
|
2020 | 2020 | return |
|
2021 | 2021 | if not args or args[0][0:1] in '-+': |
|
2022 | 2022 | if not q.applied: |
|
2023 | 2023 | raise util.Abort(_('no patches applied')) |
|
2024 | 2024 | patch = q.applied[-1].name |
|
2025 | 2025 | if patch is None and args[0][0:1] not in '-+': |
|
2026 | 2026 | patch = args.pop(0) |
|
2027 | 2027 | if patch is None: |
|
2028 | 2028 | raise util.Abort(_('no patch to work with')) |
|
2029 | 2029 | if args or opts['none']: |
|
2030 | 2030 | idx = q.find_series(patch) |
|
2031 | 2031 | if idx is None: |
|
2032 | 2032 | raise util.Abort(_('no patch named %s') % patch) |
|
2033 | 2033 | q.set_guards(idx, args) |
|
2034 | 2034 | q.save_dirty() |
|
2035 | 2035 | else: |
|
2036 | 2036 | status(q.series.index(q.lookup(patch))) |
|
2037 | 2037 | |
|
2038 | 2038 | def header(ui, repo, patch=None): |
|
2039 | 2039 | """print the header of the topmost or specified patch""" |
|
2040 | 2040 | q = repo.mq |
|
2041 | 2041 | |
|
2042 | 2042 | if patch: |
|
2043 | 2043 | patch = q.lookup(patch) |
|
2044 | 2044 | else: |
|
2045 | 2045 | if not q.applied: |
|
2046 | 2046 | ui.write('no patches applied\n') |
|
2047 | 2047 | return 1 |
|
2048 | 2048 | patch = q.lookup('qtip') |
|
2049 | 2049 | ph = repo.mq.readheaders(patch) |
|
2050 | 2050 | |
|
2051 | 2051 | ui.write('\n'.join(ph.message) + '\n') |
|
2052 | 2052 | |
|
2053 | 2053 | def lastsavename(path): |
|
2054 | 2054 | (directory, base) = os.path.split(path) |
|
2055 | 2055 | names = os.listdir(directory) |
|
2056 | 2056 | namere = re.compile("%s.([0-9]+)" % base) |
|
2057 | 2057 | maxindex = None |
|
2058 | 2058 | maxname = None |
|
2059 | 2059 | for f in names: |
|
2060 | 2060 | m = namere.match(f) |
|
2061 | 2061 | if m: |
|
2062 | 2062 | index = int(m.group(1)) |
|
2063 | 2063 | if maxindex == None or index > maxindex: |
|
2064 | 2064 | maxindex = index |
|
2065 | 2065 | maxname = f |
|
2066 | 2066 | if maxname: |
|
2067 | 2067 | return (os.path.join(directory, maxname), maxindex) |
|
2068 | 2068 | return (None, None) |
|
2069 | 2069 | |
|
2070 | 2070 | def savename(path): |
|
2071 | 2071 | (last, index) = lastsavename(path) |
|
2072 | 2072 | if last is None: |
|
2073 | 2073 | index = 0 |
|
2074 | 2074 | newpath = path + ".%d" % (index + 1) |
|
2075 | 2075 | return newpath |
|
2076 | 2076 | |
|
2077 | 2077 | def push(ui, repo, patch=None, **opts): |
|
2078 | 2078 | """push the next patch onto the stack |
|
2079 | 2079 | |
|
2080 | 2080 | When --force is applied, all local changes in patched files will |
|
2081 | 2081 | be lost. |
|
2082 | 2082 | """ |
|
2083 | 2083 | q = repo.mq |
|
2084 | 2084 | mergeq = None |
|
2085 | 2085 | |
|
2086 | 2086 | if opts['merge']: |
|
2087 | 2087 | if opts['name']: |
|
2088 | 2088 | newpath = repo.join(opts['name']) |
|
2089 | 2089 | else: |
|
2090 | 2090 | newpath, i = lastsavename(q.path) |
|
2091 | 2091 | if not newpath: |
|
2092 | 2092 | ui.warn(_("no saved queues found, please use -n\n")) |
|
2093 | 2093 | return 1 |
|
2094 | 2094 | mergeq = queue(ui, repo.join(""), newpath) |
|
2095 | 2095 | ui.warn(_("merging with queue at: %s\n") % mergeq.path) |
|
2096 | 2096 | ret = q.push(repo, patch, force=opts['force'], list=opts['list'], |
|
2097 | 2097 | mergeq=mergeq, all=opts.get('all')) |
|
2098 | 2098 | return ret |
|
2099 | 2099 | |
|
2100 | 2100 | def pop(ui, repo, patch=None, **opts): |
|
2101 | 2101 | """pop the current patch off the stack |
|
2102 | 2102 | |
|
2103 | 2103 | By default, pops off the top of the patch stack. If given a patch |
|
2104 | 2104 | name, keeps popping off patches until the named patch is at the |
|
2105 | 2105 | top of the stack. |
|
2106 | 2106 | """ |
|
2107 | 2107 | localupdate = True |
|
2108 | 2108 | if opts['name']: |
|
2109 | 2109 | q = queue(ui, repo.join(""), repo.join(opts['name'])) |
|
2110 | 2110 | ui.warn(_('using patch queue: %s\n') % q.path) |
|
2111 | 2111 | localupdate = False |
|
2112 | 2112 | else: |
|
2113 | 2113 | q = repo.mq |
|
2114 | 2114 | ret = q.pop(repo, patch, force=opts['force'], update=localupdate, |
|
2115 | 2115 | all=opts['all']) |
|
2116 | 2116 | q.save_dirty() |
|
2117 | 2117 | return ret |
|
2118 | 2118 | |
|
2119 | 2119 | def rename(ui, repo, patch, name=None, **opts): |
|
2120 | 2120 | """rename a patch |
|
2121 | 2121 | |
|
2122 | 2122 | With one argument, renames the current patch to PATCH1. |
|
2123 | 2123 | With two arguments, renames PATCH1 to PATCH2.""" |
|
2124 | 2124 | |
|
2125 | 2125 | q = repo.mq |
|
2126 | 2126 | |
|
2127 | 2127 | if not name: |
|
2128 | 2128 | name = patch |
|
2129 | 2129 | patch = None |
|
2130 | 2130 | |
|
2131 | 2131 | if patch: |
|
2132 | 2132 | patch = q.lookup(patch) |
|
2133 | 2133 | else: |
|
2134 | 2134 | if not q.applied: |
|
2135 | 2135 | ui.write(_('no patches applied\n')) |
|
2136 | 2136 | return |
|
2137 | 2137 | patch = q.lookup('qtip') |
|
2138 | 2138 | absdest = q.join(name) |
|
2139 | 2139 | if os.path.isdir(absdest): |
|
2140 | 2140 | name = normname(os.path.join(name, os.path.basename(patch))) |
|
2141 | 2141 | absdest = q.join(name) |
|
2142 | 2142 | if os.path.exists(absdest): |
|
2143 | 2143 | raise util.Abort(_('%s already exists') % absdest) |
|
2144 | 2144 | |
|
2145 | 2145 | if name in q.series: |
|
2146 | 2146 | raise util.Abort(_('A patch named %s already exists in the series file') % name) |
|
2147 | 2147 | |
|
2148 | 2148 | if ui.verbose: |
|
2149 | 2149 | ui.write('renaming %s to %s\n' % (patch, name)) |
|
2150 | 2150 | i = q.find_series(patch) |
|
2151 | 2151 | guards = q.guard_re.findall(q.full_series[i]) |
|
2152 | 2152 | q.full_series[i] = name + ''.join([' #' + g for g in guards]) |
|
2153 | 2153 | q.parse_series() |
|
2154 | 2154 | q.series_dirty = 1 |
|
2155 | 2155 | |
|
2156 | 2156 | info = q.isapplied(patch) |
|
2157 | 2157 | if info: |
|
2158 | 2158 | q.applied[info[0]] = statusentry(info[1], name) |
|
2159 | 2159 | q.applied_dirty = 1 |
|
2160 | 2160 | |
|
2161 | 2161 | util.rename(q.join(patch), absdest) |
|
2162 | 2162 | r = q.qrepo() |
|
2163 | 2163 | if r: |
|
2164 | 2164 | wlock = r.wlock() |
|
2165 | 2165 | try: |
|
2166 | 2166 | if r.dirstate[patch] == 'a': |
|
2167 | 2167 | r.dirstate.forget(patch) |
|
2168 | 2168 | r.dirstate.add(name) |
|
2169 | 2169 | else: |
|
2170 | 2170 | if r.dirstate[name] == 'r': |
|
2171 | 2171 | r.undelete([name]) |
|
2172 | 2172 | r.copy(patch, name) |
|
2173 | 2173 | r.remove([patch], False) |
|
2174 | 2174 | finally: |
|
2175 | 2175 | del wlock |
|
2176 | 2176 | |
|
2177 | 2177 | q.save_dirty() |
|
2178 | 2178 | |
|
2179 | 2179 | def restore(ui, repo, rev, **opts): |
|
2180 | 2180 | """restore the queue state saved by a rev""" |
|
2181 | 2181 | rev = repo.lookup(rev) |
|
2182 | 2182 | q = repo.mq |
|
2183 | 2183 | q.restore(repo, rev, delete=opts['delete'], |
|
2184 | 2184 | qupdate=opts['update']) |
|
2185 | 2185 | q.save_dirty() |
|
2186 | 2186 | return 0 |
|
2187 | 2187 | |
|
2188 | 2188 | def save(ui, repo, **opts): |
|
2189 | 2189 | """save current queue state""" |
|
2190 | 2190 | q = repo.mq |
|
2191 | 2191 | message = cmdutil.logmessage(opts) |
|
2192 | 2192 | ret = q.save(repo, msg=message) |
|
2193 | 2193 | if ret: |
|
2194 | 2194 | return ret |
|
2195 | 2195 | q.save_dirty() |
|
2196 | 2196 | if opts['copy']: |
|
2197 | 2197 | path = q.path |
|
2198 | 2198 | if opts['name']: |
|
2199 | 2199 | newpath = os.path.join(q.basepath, opts['name']) |
|
2200 | 2200 | if os.path.exists(newpath): |
|
2201 | 2201 | if not os.path.isdir(newpath): |
|
2202 | 2202 | raise util.Abort(_('destination %s exists and is not ' |
|
2203 | 2203 | 'a directory') % newpath) |
|
2204 | 2204 | if not opts['force']: |
|
2205 | 2205 | raise util.Abort(_('destination %s exists, ' |
|
2206 | 2206 | 'use -f to force') % newpath) |
|
2207 | 2207 | else: |
|
2208 | 2208 | newpath = savename(path) |
|
2209 | 2209 | ui.warn(_("copy %s to %s\n") % (path, newpath)) |
|
2210 | 2210 | util.copyfiles(path, newpath) |
|
2211 | 2211 | if opts['empty']: |
|
2212 | 2212 | try: |
|
2213 | 2213 | os.unlink(q.join(q.status_path)) |
|
2214 | 2214 | except: |
|
2215 | 2215 | pass |
|
2216 | 2216 | return 0 |
|
2217 | 2217 | |
|
2218 | 2218 | def strip(ui, repo, rev, **opts): |
|
2219 | 2219 | """strip a revision and all its descendants from the repository |
|
2220 | 2220 | |
|
2221 | If one of the working dir's parent revisions is stripped, the | |
|
2221 | If one of the working directory's parent revisions is stripped, the | |
|
2222 | 2222 | working directory will be updated to the parent of the stripped |
|
2223 | 2223 | revision. |
|
2224 | 2224 | """ |
|
2225 | 2225 | backup = 'all' |
|
2226 | 2226 | if opts['backup']: |
|
2227 | 2227 | backup = 'strip' |
|
2228 | 2228 | elif opts['nobackup']: |
|
2229 | 2229 | backup = 'none' |
|
2230 | 2230 | |
|
2231 | 2231 | rev = repo.lookup(rev) |
|
2232 | 2232 | p = repo.dirstate.parents() |
|
2233 | 2233 | cl = repo.changelog |
|
2234 | 2234 | update = True |
|
2235 | 2235 | if p[0] == nullid: |
|
2236 | 2236 | update = False |
|
2237 | 2237 | elif p[1] == nullid and rev != cl.ancestor(p[0], rev): |
|
2238 | 2238 | update = False |
|
2239 | 2239 | elif rev not in (cl.ancestor(p[0], rev), cl.ancestor(p[1], rev)): |
|
2240 | 2240 | update = False |
|
2241 | 2241 | |
|
2242 | 2242 | repo.mq.strip(repo, rev, backup=backup, update=update, force=opts['force']) |
|
2243 | 2243 | return 0 |
|
2244 | 2244 | |
|
2245 | 2245 | def select(ui, repo, *args, **opts): |
|
2246 | 2246 | '''set or print guarded patches to push |
|
2247 | 2247 | |
|
2248 | 2248 | Use the qguard command to set or print guards on patch, then use |
|
2249 | 2249 | qselect to tell mq which guards to use. A patch will be pushed if |
|
2250 | 2250 | it has no guards or any positive guards match the currently |
|
2251 | 2251 | selected guard, but will not be pushed if any negative guards |
|
2252 | 2252 | match the current guard. For example: |
|
2253 | 2253 | |
|
2254 | 2254 | qguard foo.patch -stable (negative guard) |
|
2255 | 2255 | qguard bar.patch +stable (positive guard) |
|
2256 | 2256 | qselect stable |
|
2257 | 2257 | |
|
2258 | 2258 | This activates the "stable" guard. mq will skip foo.patch (because |
|
2259 | 2259 | it has a negative match) but push bar.patch (because it has a |
|
2260 | 2260 | positive match). |
|
2261 | 2261 | |
|
2262 | 2262 | With no arguments, prints the currently active guards. |
|
2263 | 2263 | With one argument, sets the active guard. |
|
2264 | 2264 | |
|
2265 | 2265 | Use -n/--none to deactivate guards (no other arguments needed). |
|
2266 | 2266 | When no guards are active, patches with positive guards are |
|
2267 | 2267 | skipped and patches with negative guards are pushed. |
|
2268 | 2268 | |
|
2269 | 2269 | qselect can change the guards on applied patches. It does not pop |
|
2270 | 2270 | guarded patches by default. Use --pop to pop back to the last |
|
2271 | 2271 | applied patch that is not guarded. Use --reapply (which implies |
|
2272 | 2272 | --pop) to push back to the current patch afterwards, but skip |
|
2273 | 2273 | guarded patches. |
|
2274 | 2274 | |
|
2275 | 2275 | Use -s/--series to print a list of all guards in the series file |
|
2276 | 2276 | (no other arguments needed). Use -v for more information.''' |
|
2277 | 2277 | |
|
2278 | 2278 | q = repo.mq |
|
2279 | 2279 | guards = q.active() |
|
2280 | 2280 | if args or opts['none']: |
|
2281 | 2281 | old_unapplied = q.unapplied(repo) |
|
2282 | 2282 | old_guarded = [i for i in xrange(len(q.applied)) if |
|
2283 | 2283 | not q.pushable(i)[0]] |
|
2284 | 2284 | q.set_active(args) |
|
2285 | 2285 | q.save_dirty() |
|
2286 | 2286 | if not args: |
|
2287 | 2287 | ui.status(_('guards deactivated\n')) |
|
2288 | 2288 | if not opts['pop'] and not opts['reapply']: |
|
2289 | 2289 | unapplied = q.unapplied(repo) |
|
2290 | 2290 | guarded = [i for i in xrange(len(q.applied)) |
|
2291 | 2291 | if not q.pushable(i)[0]] |
|
2292 | 2292 | if len(unapplied) != len(old_unapplied): |
|
2293 | 2293 | ui.status(_('number of unguarded, unapplied patches has ' |
|
2294 | 2294 | 'changed from %d to %d\n') % |
|
2295 | 2295 | (len(old_unapplied), len(unapplied))) |
|
2296 | 2296 | if len(guarded) != len(old_guarded): |
|
2297 | 2297 | ui.status(_('number of guarded, applied patches has changed ' |
|
2298 | 2298 | 'from %d to %d\n') % |
|
2299 | 2299 | (len(old_guarded), len(guarded))) |
|
2300 | 2300 | elif opts['series']: |
|
2301 | 2301 | guards = {} |
|
2302 | 2302 | noguards = 0 |
|
2303 | 2303 | for gs in q.series_guards: |
|
2304 | 2304 | if not gs: |
|
2305 | 2305 | noguards += 1 |
|
2306 | 2306 | for g in gs: |
|
2307 | 2307 | guards.setdefault(g, 0) |
|
2308 | 2308 | guards[g] += 1 |
|
2309 | 2309 | if ui.verbose: |
|
2310 | 2310 | guards['NONE'] = noguards |
|
2311 | 2311 | guards = guards.items() |
|
2312 | 2312 | guards.sort(lambda a, b: cmp(a[0][1:], b[0][1:])) |
|
2313 | 2313 | if guards: |
|
2314 | 2314 | ui.note(_('guards in series file:\n')) |
|
2315 | 2315 | for guard, count in guards: |
|
2316 | 2316 | ui.note('%2d ' % count) |
|
2317 | 2317 | ui.write(guard, '\n') |
|
2318 | 2318 | else: |
|
2319 | 2319 | ui.note(_('no guards in series file\n')) |
|
2320 | 2320 | else: |
|
2321 | 2321 | if guards: |
|
2322 | 2322 | ui.note(_('active guards:\n')) |
|
2323 | 2323 | for g in guards: |
|
2324 | 2324 | ui.write(g, '\n') |
|
2325 | 2325 | else: |
|
2326 | 2326 | ui.write(_('no active guards\n')) |
|
2327 | 2327 | reapply = opts['reapply'] and q.applied and q.appliedname(-1) |
|
2328 | 2328 | popped = False |
|
2329 | 2329 | if opts['pop'] or opts['reapply']: |
|
2330 | 2330 | for i in xrange(len(q.applied)): |
|
2331 | 2331 | pushable, reason = q.pushable(i) |
|
2332 | 2332 | if not pushable: |
|
2333 | 2333 | ui.status(_('popping guarded patches\n')) |
|
2334 | 2334 | popped = True |
|
2335 | 2335 | if i == 0: |
|
2336 | 2336 | q.pop(repo, all=True) |
|
2337 | 2337 | else: |
|
2338 | 2338 | q.pop(repo, i-1) |
|
2339 | 2339 | break |
|
2340 | 2340 | if popped: |
|
2341 | 2341 | try: |
|
2342 | 2342 | if reapply: |
|
2343 | 2343 | ui.status(_('reapplying unguarded patches\n')) |
|
2344 | 2344 | q.push(repo, reapply) |
|
2345 | 2345 | finally: |
|
2346 | 2346 | q.save_dirty() |
|
2347 | 2347 | |
|
2348 | 2348 | def finish(ui, repo, *revrange, **opts): |
|
2349 | 2349 | """move applied patches into repository history |
|
2350 | 2350 | |
|
2351 | 2351 | Finishes the specified revisions (corresponding to applied |
|
2352 | 2352 | patches) by moving them out of mq control into regular repository |
|
2353 | 2353 | history. |
|
2354 | 2354 | |
|
2355 | 2355 | Accepts a revision range or the --applied option. If --applied is |
|
2356 | 2356 | specified, all applied mq revisions are removed from mq control. |
|
2357 | 2357 | Otherwise, the given revisions must be at the base of the stack of |
|
2358 | 2358 | applied patches. |
|
2359 | 2359 | |
|
2360 | 2360 | This can be especially useful if your changes have been applied to |
|
2361 | 2361 | an upstream repository, or if you are about to push your changes |
|
2362 | 2362 | to upstream. |
|
2363 | 2363 | """ |
|
2364 | 2364 | if not opts['applied'] and not revrange: |
|
2365 | 2365 | raise util.Abort(_('no revisions specified')) |
|
2366 | 2366 | elif opts['applied']: |
|
2367 | 2367 | revrange = ('qbase:qtip',) + revrange |
|
2368 | 2368 | |
|
2369 | 2369 | q = repo.mq |
|
2370 | 2370 | if not q.applied: |
|
2371 | 2371 | ui.status(_('no patches applied\n')) |
|
2372 | 2372 | return 0 |
|
2373 | 2373 | |
|
2374 | 2374 | revs = cmdutil.revrange(repo, revrange) |
|
2375 | 2375 | q.finish(repo, revs) |
|
2376 | 2376 | q.save_dirty() |
|
2377 | 2377 | return 0 |
|
2378 | 2378 | |
|
2379 | 2379 | def reposetup(ui, repo): |
|
2380 | 2380 | class mqrepo(repo.__class__): |
|
2381 | 2381 | def abort_if_wdir_patched(self, errmsg, force=False): |
|
2382 | 2382 | if self.mq.applied and not force: |
|
2383 | 2383 | parent = hex(self.dirstate.parents()[0]) |
|
2384 | 2384 | if parent in [s.rev for s in self.mq.applied]: |
|
2385 | 2385 | raise util.Abort(errmsg) |
|
2386 | 2386 | |
|
2387 | 2387 | def commit(self, *args, **opts): |
|
2388 | 2388 | if len(args) >= 6: |
|
2389 | 2389 | force = args[5] |
|
2390 | 2390 | else: |
|
2391 | 2391 | force = opts.get('force') |
|
2392 | 2392 | self.abort_if_wdir_patched( |
|
2393 | 2393 | _('cannot commit over an applied mq patch'), |
|
2394 | 2394 | force) |
|
2395 | 2395 | |
|
2396 | 2396 | return super(mqrepo, self).commit(*args, **opts) |
|
2397 | 2397 | |
|
2398 | 2398 | def push(self, remote, force=False, revs=None): |
|
2399 | 2399 | if self.mq.applied and not force and not revs: |
|
2400 | 2400 | raise util.Abort(_('source has mq patches applied')) |
|
2401 | 2401 | return super(mqrepo, self).push(remote, force, revs) |
|
2402 | 2402 | |
|
2403 | 2403 | def tags(self): |
|
2404 | 2404 | if self.tagscache: |
|
2405 | 2405 | return self.tagscache |
|
2406 | 2406 | |
|
2407 | 2407 | tagscache = super(mqrepo, self).tags() |
|
2408 | 2408 | |
|
2409 | 2409 | q = self.mq |
|
2410 | 2410 | if not q.applied: |
|
2411 | 2411 | return tagscache |
|
2412 | 2412 | |
|
2413 | 2413 | mqtags = [(bin(patch.rev), patch.name) for patch in q.applied] |
|
2414 | 2414 | |
|
2415 | 2415 | if mqtags[-1][0] not in self.changelog.nodemap: |
|
2416 | 2416 | self.ui.warn(_('mq status file refers to unknown node %s\n') |
|
2417 | 2417 | % short(mqtags[-1][0])) |
|
2418 | 2418 | return tagscache |
|
2419 | 2419 | |
|
2420 | 2420 | mqtags.append((mqtags[-1][0], 'qtip')) |
|
2421 | 2421 | mqtags.append((mqtags[0][0], 'qbase')) |
|
2422 | 2422 | mqtags.append((self.changelog.parents(mqtags[0][0])[0], 'qparent')) |
|
2423 | 2423 | for patch in mqtags: |
|
2424 | 2424 | if patch[1] in tagscache: |
|
2425 | 2425 | self.ui.warn(_('Tag %s overrides mq patch of the same name\n') |
|
2426 | 2426 | % patch[1]) |
|
2427 | 2427 | else: |
|
2428 | 2428 | tagscache[patch[1]] = patch[0] |
|
2429 | 2429 | |
|
2430 | 2430 | return tagscache |
|
2431 | 2431 | |
|
2432 | 2432 | def _branchtags(self, partial, lrev): |
|
2433 | 2433 | q = self.mq |
|
2434 | 2434 | if not q.applied: |
|
2435 | 2435 | return super(mqrepo, self)._branchtags(partial, lrev) |
|
2436 | 2436 | |
|
2437 | 2437 | cl = self.changelog |
|
2438 | 2438 | qbasenode = bin(q.applied[0].rev) |
|
2439 | 2439 | if qbasenode not in cl.nodemap: |
|
2440 | 2440 | self.ui.warn(_('mq status file refers to unknown node %s\n') |
|
2441 | 2441 | % short(qbasenode)) |
|
2442 | 2442 | return super(mqrepo, self)._branchtags(partial, lrev) |
|
2443 | 2443 | |
|
2444 | 2444 | qbase = cl.rev(qbasenode) |
|
2445 | 2445 | start = lrev + 1 |
|
2446 | 2446 | if start < qbase: |
|
2447 | 2447 | # update the cache (excluding the patches) and save it |
|
2448 | 2448 | self._updatebranchcache(partial, lrev+1, qbase) |
|
2449 | 2449 | self._writebranchcache(partial, cl.node(qbase-1), qbase-1) |
|
2450 | 2450 | start = qbase |
|
2451 | 2451 | # if start = qbase, the cache is as updated as it should be. |
|
2452 | 2452 | # if start > qbase, the cache includes (part of) the patches. |
|
2453 | 2453 | # we might as well use it, but we won't save it. |
|
2454 | 2454 | |
|
2455 | 2455 | # update the cache up to the tip |
|
2456 | 2456 | self._updatebranchcache(partial, start, len(cl)) |
|
2457 | 2457 | |
|
2458 | 2458 | return partial |
|
2459 | 2459 | |
|
2460 | 2460 | if repo.local(): |
|
2461 | 2461 | repo.__class__ = mqrepo |
|
2462 | 2462 | repo.mq = queue(ui, repo.join("")) |
|
2463 | 2463 | |
|
2464 | 2464 | def mqimport(orig, ui, repo, *args, **kwargs): |
|
2465 | 2465 | if hasattr(repo, 'abort_if_wdir_patched'): |
|
2466 | 2466 | repo.abort_if_wdir_patched(_('cannot import over an applied patch'), |
|
2467 | 2467 | kwargs.get('force')) |
|
2468 | 2468 | return orig(ui, repo, *args, **kwargs) |
|
2469 | 2469 | |
|
2470 | 2470 | def uisetup(ui): |
|
2471 | 2471 | extensions.wrapcommand(commands.table, 'import', mqimport) |
|
2472 | 2472 | |
|
2473 | 2473 | seriesopts = [('s', 'summary', None, _('print first line of patch header'))] |
|
2474 | 2474 | |
|
2475 | 2475 | cmdtable = { |
|
2476 | 2476 | "qapplied": (applied, [] + seriesopts, _('hg qapplied [-s] [PATCH]')), |
|
2477 | 2477 | "qclone": |
|
2478 | 2478 | (clone, |
|
2479 | 2479 | [('', 'pull', None, _('use pull protocol to copy metadata')), |
|
2480 | 2480 | ('U', 'noupdate', None, _('do not update the new working directories')), |
|
2481 | 2481 | ('', 'uncompressed', None, |
|
2482 | 2482 | _('use uncompressed transfer (fast over LAN)')), |
|
2483 | 2483 | ('p', 'patches', '', _('location of source patch repo')), |
|
2484 | 2484 | ] + commands.remoteopts, |
|
2485 | 2485 | _('hg qclone [OPTION]... SOURCE [DEST]')), |
|
2486 | 2486 | "qcommit|qci": |
|
2487 | 2487 | (commit, |
|
2488 | 2488 | commands.table["^commit|ci"][1], |
|
2489 | 2489 | _('hg qcommit [OPTION]... [FILE]...')), |
|
2490 | 2490 | "^qdiff": |
|
2491 | 2491 | (diff, |
|
2492 | 2492 | commands.diffopts + commands.diffopts2 + commands.walkopts, |
|
2493 | 2493 | _('hg qdiff [OPTION]... [FILE]...')), |
|
2494 | 2494 | "qdelete|qremove|qrm": |
|
2495 | 2495 | (delete, |
|
2496 | 2496 | [('k', 'keep', None, _('keep patch file')), |
|
2497 | 2497 | ('r', 'rev', [], _('stop managing a revision'))], |
|
2498 | 2498 | _('hg qdelete [-k] [-r REV]... [PATCH]...')), |
|
2499 | 2499 | 'qfold': |
|
2500 | 2500 | (fold, |
|
2501 | 2501 | [('e', 'edit', None, _('edit patch header')), |
|
2502 | 2502 | ('k', 'keep', None, _('keep folded patch files')), |
|
2503 | 2503 | ] + commands.commitopts, |
|
2504 | 2504 | _('hg qfold [-e] [-k] [-m TEXT] [-l FILE] PATCH...')), |
|
2505 | 2505 | 'qgoto': |
|
2506 | 2506 | (goto, |
|
2507 | 2507 | [('f', 'force', None, _('overwrite any local changes'))], |
|
2508 | 2508 | _('hg qgoto [OPTION]... PATCH')), |
|
2509 | 2509 | 'qguard': |
|
2510 | 2510 | (guard, |
|
2511 | 2511 | [('l', 'list', None, _('list all patches and guards')), |
|
2512 | 2512 | ('n', 'none', None, _('drop all guards'))], |
|
2513 | 2513 | _('hg qguard [-l] [-n] -- [PATCH] [+GUARD]... [-GUARD]...')), |
|
2514 | 2514 | 'qheader': (header, [], _('hg qheader [PATCH]')), |
|
2515 | 2515 | "^qimport": |
|
2516 | 2516 | (qimport, |
|
2517 | [('e', 'existing', None, _('import file in patch dir')), | |
|
2517 | [('e', 'existing', None, _('import file in patch directory')), | |
|
2518 | 2518 | ('n', 'name', '', _('patch file name')), |
|
2519 | 2519 | ('f', 'force', None, _('overwrite existing files')), |
|
2520 | 2520 | ('r', 'rev', [], _('place existing revisions under mq control')), |
|
2521 | 2521 | ('g', 'git', None, _('use git extended diff format'))], |
|
2522 | 2522 | _('hg qimport [-e] [-n NAME] [-f] [-g] [-r REV]... FILE...')), |
|
2523 | 2523 | "^qinit": |
|
2524 | 2524 | (init, |
|
2525 | 2525 | [('c', 'create-repo', None, _('create queue repository'))], |
|
2526 | 2526 | _('hg qinit [-c]')), |
|
2527 | 2527 | "qnew": |
|
2528 | 2528 | (new, |
|
2529 | 2529 | [('e', 'edit', None, _('edit commit message')), |
|
2530 | 2530 | ('f', 'force', None, _('import uncommitted changes into patch')), |
|
2531 | 2531 | ('g', 'git', None, _('use git extended diff format')), |
|
2532 | 2532 | ('U', 'currentuser', None, _('add "From: <current user>" to patch')), |
|
2533 | 2533 | ('u', 'user', '', _('add "From: <given user>" to patch')), |
|
2534 | 2534 | ('D', 'currentdate', None, _('add "Date: <current date>" to patch')), |
|
2535 | 2535 | ('d', 'date', '', _('add "Date: <given date>" to patch')) |
|
2536 | 2536 | ] + commands.walkopts + commands.commitopts, |
|
2537 | 2537 | _('hg qnew [-e] [-m TEXT] [-l FILE] [-f] PATCH [FILE]...')), |
|
2538 | 2538 | "qnext": (next, [] + seriesopts, _('hg qnext [-s]')), |
|
2539 | 2539 | "qprev": (prev, [] + seriesopts, _('hg qprev [-s]')), |
|
2540 | 2540 | "^qpop": |
|
2541 | 2541 | (pop, |
|
2542 | 2542 | [('a', 'all', None, _('pop all patches')), |
|
2543 | 2543 | ('n', 'name', '', _('queue name to pop')), |
|
2544 | 2544 | ('f', 'force', None, _('forget any local changes'))], |
|
2545 | 2545 | _('hg qpop [-a] [-n NAME] [-f] [PATCH | INDEX]')), |
|
2546 | 2546 | "^qpush": |
|
2547 | 2547 | (push, |
|
2548 | 2548 | [('f', 'force', None, _('apply if the patch has rejects')), |
|
2549 | 2549 | ('l', 'list', None, _('list patch name in commit text')), |
|
2550 | 2550 | ('a', 'all', None, _('apply all patches')), |
|
2551 | 2551 | ('m', 'merge', None, _('merge from another queue')), |
|
2552 | 2552 | ('n', 'name', '', _('merge queue name'))], |
|
2553 | 2553 | _('hg qpush [-f] [-l] [-a] [-m] [-n NAME] [PATCH | INDEX]')), |
|
2554 | 2554 | "^qrefresh": |
|
2555 | 2555 | (refresh, |
|
2556 | 2556 | [('e', 'edit', None, _('edit commit message')), |
|
2557 | 2557 | ('g', 'git', None, _('use git extended diff format')), |
|
2558 | 2558 | ('s', 'short', None, _('refresh only files already in the patch and specified files')), |
|
2559 | 2559 | ('U', 'currentuser', None, _('add/update "From: <current user>" in patch')), |
|
2560 | 2560 | ('u', 'user', '', _('add/update "From: <given user>" in patch')), |
|
2561 | 2561 | ('D', 'currentdate', None, _('update "Date: <current date>" in patch (if present)')), |
|
2562 | 2562 | ('d', 'date', '', _('update "Date: <given date>" in patch (if present)')) |
|
2563 | 2563 | ] + commands.walkopts + commands.commitopts, |
|
2564 | 2564 | _('hg qrefresh [-I] [-X] [-e] [-m TEXT] [-l FILE] [-s] [FILE]...')), |
|
2565 | 2565 | 'qrename|qmv': |
|
2566 | 2566 | (rename, [], _('hg qrename PATCH1 [PATCH2]')), |
|
2567 | 2567 | "qrestore": |
|
2568 | 2568 | (restore, |
|
2569 | 2569 | [('d', 'delete', None, _('delete save entry')), |
|
2570 | ('u', 'update', None, _('update queue working dir'))], | |
|
2570 | ('u', 'update', None, _('update queue working directory'))], | |
|
2571 | 2571 | _('hg qrestore [-d] [-u] REV')), |
|
2572 | 2572 | "qsave": |
|
2573 | 2573 | (save, |
|
2574 | 2574 | [('c', 'copy', None, _('copy patch directory')), |
|
2575 | 2575 | ('n', 'name', '', _('copy directory name')), |
|
2576 | 2576 | ('e', 'empty', None, _('clear queue status file')), |
|
2577 | 2577 | ('f', 'force', None, _('force copy'))] + commands.commitopts, |
|
2578 | 2578 | _('hg qsave [-m TEXT] [-l FILE] [-c] [-n NAME] [-e] [-f]')), |
|
2579 | 2579 | "qselect": |
|
2580 | 2580 | (select, |
|
2581 | 2581 | [('n', 'none', None, _('disable all guards')), |
|
2582 | 2582 | ('s', 'series', None, _('list all guards in series file')), |
|
2583 | 2583 | ('', 'pop', None, _('pop to before first guarded applied patch')), |
|
2584 | 2584 | ('', 'reapply', None, _('pop, then reapply patches'))], |
|
2585 | 2585 | _('hg qselect [OPTION]... [GUARD]...')), |
|
2586 | 2586 | "qseries": |
|
2587 | 2587 | (series, |
|
2588 | 2588 | [('m', 'missing', None, _('print patches not in series')), |
|
2589 | 2589 | ] + seriesopts, |
|
2590 | 2590 | _('hg qseries [-ms]')), |
|
2591 | 2591 | "^strip": |
|
2592 | 2592 | (strip, |
|
2593 | 2593 | [('f', 'force', None, _('force removal with local changes')), |
|
2594 | 2594 | ('b', 'backup', None, _('bundle unrelated changesets')), |
|
2595 | 2595 | ('n', 'nobackup', None, _('no backups'))], |
|
2596 | 2596 | _('hg strip [-f] [-b] [-n] REV')), |
|
2597 | 2597 | "qtop": (top, [] + seriesopts, _('hg qtop [-s]')), |
|
2598 | 2598 | "qunapplied": (unapplied, [] + seriesopts, _('hg qunapplied [-s] [PATCH]')), |
|
2599 | 2599 | "qfinish": |
|
2600 | 2600 | (finish, |
|
2601 | 2601 | [('a', 'applied', None, _('finish all applied changesets'))], |
|
2602 | 2602 | _('hg qfinish [-a] [REV...]')), |
|
2603 | 2603 | } |
@@ -1,3453 +1,3453 b'' | |||
|
1 | 1 | # commands.py - command processing for mercurial |
|
2 | 2 | # |
|
3 | 3 | # Copyright 2005-2007 Matt Mackall <mpm@selenic.com> |
|
4 | 4 | # |
|
5 | 5 | # This software may be used and distributed according to the terms |
|
6 | 6 | # of the GNU General Public License, incorporated herein by reference. |
|
7 | 7 | |
|
8 | 8 | from node import hex, nullid, nullrev, short |
|
9 | 9 | from i18n import _, gettext |
|
10 | 10 | import os, re, sys |
|
11 | 11 | import hg, util, revlog, bundlerepo, extensions, copies, context, error |
|
12 | 12 | import difflib, patch, time, help, mdiff, tempfile, url, encoding |
|
13 | 13 | import archival, changegroup, cmdutil, hgweb.server, sshserver, hbisect |
|
14 | 14 | import merge as merge_ |
|
15 | 15 | |
|
16 | 16 | # Commands start here, listed alphabetically |
|
17 | 17 | |
|
18 | 18 | def add(ui, repo, *pats, **opts): |
|
19 | 19 | """add the specified files on the next commit |
|
20 | 20 | |
|
21 | 21 | Schedule files to be version controlled and added to the |
|
22 | 22 | repository. |
|
23 | 23 | |
|
24 | 24 | The files will be added to the repository at the next commit. To |
|
25 | 25 | undo an add before that, see hg revert. |
|
26 | 26 | |
|
27 | 27 | If no names are given, add all files to the repository. |
|
28 | 28 | """ |
|
29 | 29 | |
|
30 | 30 | rejected = None |
|
31 | 31 | exacts = {} |
|
32 | 32 | names = [] |
|
33 | 33 | m = cmdutil.match(repo, pats, opts) |
|
34 | 34 | m.bad = lambda x,y: True |
|
35 | 35 | for abs in repo.walk(m): |
|
36 | 36 | if m.exact(abs): |
|
37 | 37 | if ui.verbose: |
|
38 | 38 | ui.status(_('adding %s\n') % m.rel(abs)) |
|
39 | 39 | names.append(abs) |
|
40 | 40 | exacts[abs] = 1 |
|
41 | 41 | elif abs not in repo.dirstate: |
|
42 | 42 | ui.status(_('adding %s\n') % m.rel(abs)) |
|
43 | 43 | names.append(abs) |
|
44 | 44 | if not opts.get('dry_run'): |
|
45 | 45 | rejected = repo.add(names) |
|
46 | 46 | rejected = [p for p in rejected if p in exacts] |
|
47 | 47 | return rejected and 1 or 0 |
|
48 | 48 | |
|
49 | 49 | def addremove(ui, repo, *pats, **opts): |
|
50 | 50 | """add all new files, delete all missing files |
|
51 | 51 | |
|
52 | 52 | Add all new files and remove all missing files from the |
|
53 | 53 | repository. |
|
54 | 54 | |
|
55 | 55 | New files are ignored if they match any of the patterns in |
|
56 | 56 | .hgignore. As with add, these changes take effect at the next |
|
57 | 57 | commit. |
|
58 | 58 | |
|
59 | 59 | Use the -s option to detect renamed files. With a parameter > 0, |
|
60 | 60 | this compares every removed file with every added file and records |
|
61 | 61 | those similar enough as renames. This option takes a percentage |
|
62 | 62 | between 0 (disabled) and 100 (files must be identical) as its |
|
63 | 63 | parameter. Detecting renamed files this way can be expensive. |
|
64 | 64 | """ |
|
65 | 65 | try: |
|
66 | 66 | sim = float(opts.get('similarity') or 0) |
|
67 | 67 | except ValueError: |
|
68 | 68 | raise util.Abort(_('similarity must be a number')) |
|
69 | 69 | if sim < 0 or sim > 100: |
|
70 | 70 | raise util.Abort(_('similarity must be between 0 and 100')) |
|
71 | 71 | return cmdutil.addremove(repo, pats, opts, similarity=sim/100.) |
|
72 | 72 | |
|
73 | 73 | def annotate(ui, repo, *pats, **opts): |
|
74 | 74 | """show changeset information per file line |
|
75 | 75 | |
|
76 | 76 | List changes in files, showing the revision id responsible for |
|
77 | 77 | each line |
|
78 | 78 | |
|
79 | 79 | This command is useful to discover who did a change or when a |
|
80 | 80 | change took place. |
|
81 | 81 | |
|
82 | 82 | Without the -a option, annotate will avoid processing files it |
|
83 | 83 | detects as binary. With -a, annotate will generate an annotation |
|
84 | 84 | anyway, probably with undesirable results. |
|
85 | 85 | """ |
|
86 | 86 | datefunc = ui.quiet and util.shortdate or util.datestr |
|
87 | 87 | getdate = util.cachefunc(lambda x: datefunc(x[0].date())) |
|
88 | 88 | |
|
89 | 89 | if not pats: |
|
90 | 90 | raise util.Abort(_('at least one file name or pattern required')) |
|
91 | 91 | |
|
92 | 92 | opmap = [('user', lambda x: ui.shortuser(x[0].user())), |
|
93 | 93 | ('number', lambda x: str(x[0].rev())), |
|
94 | 94 | ('changeset', lambda x: short(x[0].node())), |
|
95 | 95 | ('date', getdate), |
|
96 | 96 | ('follow', lambda x: x[0].path()), |
|
97 | 97 | ] |
|
98 | 98 | |
|
99 | 99 | if (not opts.get('user') and not opts.get('changeset') and not opts.get('date') |
|
100 | 100 | and not opts.get('follow')): |
|
101 | 101 | opts['number'] = 1 |
|
102 | 102 | |
|
103 | 103 | linenumber = opts.get('line_number') is not None |
|
104 | 104 | if (linenumber and (not opts.get('changeset')) and (not opts.get('number'))): |
|
105 | 105 | raise util.Abort(_('at least one of -n/-c is required for -l')) |
|
106 | 106 | |
|
107 | 107 | funcmap = [func for op, func in opmap if opts.get(op)] |
|
108 | 108 | if linenumber: |
|
109 | 109 | lastfunc = funcmap[-1] |
|
110 | 110 | funcmap[-1] = lambda x: "%s:%s" % (lastfunc(x), x[1]) |
|
111 | 111 | |
|
112 | 112 | ctx = repo[opts.get('rev')] |
|
113 | 113 | |
|
114 | 114 | m = cmdutil.match(repo, pats, opts) |
|
115 | 115 | for abs in ctx.walk(m): |
|
116 | 116 | fctx = ctx[abs] |
|
117 | 117 | if not opts.get('text') and util.binary(fctx.data()): |
|
118 | 118 | ui.write(_("%s: binary file\n") % ((pats and m.rel(abs)) or abs)) |
|
119 | 119 | continue |
|
120 | 120 | |
|
121 | 121 | lines = fctx.annotate(follow=opts.get('follow'), |
|
122 | 122 | linenumber=linenumber) |
|
123 | 123 | pieces = [] |
|
124 | 124 | |
|
125 | 125 | for f in funcmap: |
|
126 | 126 | l = [f(n) for n, dummy in lines] |
|
127 | 127 | if l: |
|
128 | 128 | ml = max(map(len, l)) |
|
129 | 129 | pieces.append(["%*s" % (ml, x) for x in l]) |
|
130 | 130 | |
|
131 | 131 | if pieces: |
|
132 | 132 | for p, l in zip(zip(*pieces), lines): |
|
133 | 133 | ui.write("%s: %s" % (" ".join(p), l[1])) |
|
134 | 134 | |
|
135 | 135 | def archive(ui, repo, dest, **opts): |
|
136 | 136 | '''create unversioned archive of a repository revision |
|
137 | 137 | |
|
138 | 138 | By default, the revision used is the parent of the working |
|
139 | 139 | directory; use "-r" to specify a different revision. |
|
140 | 140 | |
|
141 | 141 | To specify the type of archive to create, use "-t". Valid types |
|
142 | 142 | are: |
|
143 | 143 | |
|
144 | 144 | "files" (default): a directory full of files |
|
145 | 145 | "tar": tar archive, uncompressed |
|
146 | 146 | "tbz2": tar archive, compressed using bzip2 |
|
147 | 147 | "tgz": tar archive, compressed using gzip |
|
148 | 148 | "uzip": zip archive, uncompressed |
|
149 | 149 | "zip": zip archive, compressed using deflate |
|
150 | 150 | |
|
151 | 151 | The exact name of the destination archive or directory is given |
|
152 | 152 | using a format string; see 'hg help export' for details. |
|
153 | 153 | |
|
154 | 154 | Each member added to an archive file has a directory prefix |
|
155 | 155 | prepended. Use "-p" to specify a format string for the prefix. The |
|
156 | 156 | default is the basename of the archive, with suffixes removed. |
|
157 | 157 | ''' |
|
158 | 158 | |
|
159 | 159 | ctx = repo[opts.get('rev')] |
|
160 | 160 | if not ctx: |
|
161 | 161 | raise util.Abort(_('no working directory: please specify a revision')) |
|
162 | 162 | node = ctx.node() |
|
163 | 163 | dest = cmdutil.make_filename(repo, dest, node) |
|
164 | 164 | if os.path.realpath(dest) == repo.root: |
|
165 | 165 | raise util.Abort(_('repository root cannot be destination')) |
|
166 | 166 | matchfn = cmdutil.match(repo, [], opts) |
|
167 | 167 | kind = opts.get('type') or 'files' |
|
168 | 168 | prefix = opts.get('prefix') |
|
169 | 169 | if dest == '-': |
|
170 | 170 | if kind == 'files': |
|
171 | 171 | raise util.Abort(_('cannot archive plain files to stdout')) |
|
172 | 172 | dest = sys.stdout |
|
173 | 173 | if not prefix: prefix = os.path.basename(repo.root) + '-%h' |
|
174 | 174 | prefix = cmdutil.make_filename(repo, prefix, node) |
|
175 | 175 | archival.archive(repo, dest, node, kind, not opts.get('no_decode'), |
|
176 | 176 | matchfn, prefix) |
|
177 | 177 | |
|
178 | 178 | def backout(ui, repo, node=None, rev=None, **opts): |
|
179 | 179 | '''reverse effect of earlier changeset |
|
180 | 180 | |
|
181 | 181 | Commit the backed out changes as a new changeset. The new |
|
182 | 182 | changeset is a child of the backed out changeset. |
|
183 | 183 | |
|
184 | 184 | If you back out a changeset other than the tip, a new head is |
|
185 | 185 | created. This head will be the new tip and you should merge this |
|
186 | 186 | backout changeset with another head (current one by default). |
|
187 | 187 | |
|
188 | 188 | The --merge option remembers the parent of the working directory |
|
189 | 189 | before starting the backout, then merges the new head with that |
|
190 | 190 | changeset afterwards. This saves you from doing the merge by hand. |
|
191 | 191 | The result of this merge is not committed, as with a normal merge. |
|
192 | 192 | |
|
193 | 193 | See \'hg help dates\' for a list of formats valid for -d/--date. |
|
194 | 194 | ''' |
|
195 | 195 | if rev and node: |
|
196 | 196 | raise util.Abort(_("please specify just one revision")) |
|
197 | 197 | |
|
198 | 198 | if not rev: |
|
199 | 199 | rev = node |
|
200 | 200 | |
|
201 | 201 | if not rev: |
|
202 | 202 | raise util.Abort(_("please specify a revision to backout")) |
|
203 | 203 | |
|
204 | 204 | date = opts.get('date') |
|
205 | 205 | if date: |
|
206 | 206 | opts['date'] = util.parsedate(date) |
|
207 | 207 | |
|
208 | 208 | cmdutil.bail_if_changed(repo) |
|
209 | 209 | node = repo.lookup(rev) |
|
210 | 210 | |
|
211 | 211 | op1, op2 = repo.dirstate.parents() |
|
212 | 212 | a = repo.changelog.ancestor(op1, node) |
|
213 | 213 | if a != node: |
|
214 | 214 | raise util.Abort(_('cannot back out change on a different branch')) |
|
215 | 215 | |
|
216 | 216 | p1, p2 = repo.changelog.parents(node) |
|
217 | 217 | if p1 == nullid: |
|
218 | 218 | raise util.Abort(_('cannot back out a change with no parents')) |
|
219 | 219 | if p2 != nullid: |
|
220 | 220 | if not opts.get('parent'): |
|
221 | 221 | raise util.Abort(_('cannot back out a merge changeset without ' |
|
222 | 222 | '--parent')) |
|
223 | 223 | p = repo.lookup(opts['parent']) |
|
224 | 224 | if p not in (p1, p2): |
|
225 | 225 | raise util.Abort(_('%s is not a parent of %s') % |
|
226 | 226 | (short(p), short(node))) |
|
227 | 227 | parent = p |
|
228 | 228 | else: |
|
229 | 229 | if opts.get('parent'): |
|
230 | 230 | raise util.Abort(_('cannot use --parent on non-merge changeset')) |
|
231 | 231 | parent = p1 |
|
232 | 232 | |
|
233 | 233 | # the backout should appear on the same branch |
|
234 | 234 | branch = repo.dirstate.branch() |
|
235 | 235 | hg.clean(repo, node, show_stats=False) |
|
236 | 236 | repo.dirstate.setbranch(branch) |
|
237 | 237 | revert_opts = opts.copy() |
|
238 | 238 | revert_opts['date'] = None |
|
239 | 239 | revert_opts['all'] = True |
|
240 | 240 | revert_opts['rev'] = hex(parent) |
|
241 | 241 | revert_opts['no_backup'] = None |
|
242 | 242 | revert(ui, repo, **revert_opts) |
|
243 | 243 | commit_opts = opts.copy() |
|
244 | 244 | commit_opts['addremove'] = False |
|
245 | 245 | if not commit_opts['message'] and not commit_opts['logfile']: |
|
246 | 246 | commit_opts['message'] = _("Backed out changeset %s") % (short(node)) |
|
247 | 247 | commit_opts['force_editor'] = True |
|
248 | 248 | commit(ui, repo, **commit_opts) |
|
249 | 249 | def nice(node): |
|
250 | 250 | return '%d:%s' % (repo.changelog.rev(node), short(node)) |
|
251 | 251 | ui.status(_('changeset %s backs out changeset %s\n') % |
|
252 | 252 | (nice(repo.changelog.tip()), nice(node))) |
|
253 | 253 | if op1 != node: |
|
254 | 254 | hg.clean(repo, op1, show_stats=False) |
|
255 | 255 | if opts.get('merge'): |
|
256 | 256 | ui.status(_('merging with changeset %s\n') % nice(repo.changelog.tip())) |
|
257 | 257 | hg.merge(repo, hex(repo.changelog.tip())) |
|
258 | 258 | else: |
|
259 | 259 | ui.status(_('the backout changeset is a new head - ' |
|
260 | 260 | 'do not forget to merge\n')) |
|
261 | 261 | ui.status(_('(use "backout --merge" ' |
|
262 | 262 | 'if you want to auto-merge)\n')) |
|
263 | 263 | |
|
264 | 264 | def bisect(ui, repo, rev=None, extra=None, command=None, |
|
265 | 265 | reset=None, good=None, bad=None, skip=None, noupdate=None): |
|
266 | 266 | """subdivision search of changesets |
|
267 | 267 | |
|
268 | 268 | This command helps to find changesets which introduce problems. To |
|
269 | 269 | use, mark the earliest changeset you know exhibits the problem as |
|
270 | 270 | bad, then mark the latest changeset which is free from the problem |
|
271 | 271 | as good. Bisect will update your working directory to a revision |
|
272 | 272 | for testing (unless the --noupdate option is specified). Once you |
|
273 | 273 | have performed tests, mark the working directory as bad or good |
|
274 | 274 | and bisect will either update to another candidate changeset or |
|
275 | 275 | announce that it has found the bad revision. |
|
276 | 276 | |
|
277 | 277 | As a shortcut, you can also use the revision argument to mark a |
|
278 | 278 | revision as good or bad without checking it out first. |
|
279 | 279 | |
|
280 | 280 | If you supply a command it will be used for automatic bisection. |
|
281 | 281 | Its exit status will be used as flag to mark revision as bad or |
|
282 | 282 | good. In case exit status is 0 the revision is marked as good, 125 |
|
283 | 283 | - skipped, 127 (command not found) - bisection will be aborted; |
|
284 | 284 | any other status bigger than 0 will mark revision as bad. |
|
285 | 285 | """ |
|
286 | 286 | def print_result(nodes, good): |
|
287 | 287 | displayer = cmdutil.show_changeset(ui, repo, {}) |
|
288 | 288 | transition = (good and "good" or "bad") |
|
289 | 289 | if len(nodes) == 1: |
|
290 | 290 | # narrowed it down to a single revision |
|
291 | 291 | ui.write(_("The first %s revision is:\n") % transition) |
|
292 | 292 | displayer.show(repo[nodes[0]]) |
|
293 | 293 | else: |
|
294 | 294 | # multiple possible revisions |
|
295 | 295 | ui.write(_("Due to skipped revisions, the first " |
|
296 | 296 | "%s revision could be any of:\n") % transition) |
|
297 | 297 | for n in nodes: |
|
298 | 298 | displayer.show(repo[n]) |
|
299 | 299 | |
|
300 | 300 | def check_state(state, interactive=True): |
|
301 | 301 | if not state['good'] or not state['bad']: |
|
302 | 302 | if (good or bad or skip or reset) and interactive: |
|
303 | 303 | return |
|
304 | 304 | if not state['good']: |
|
305 | 305 | raise util.Abort(_('cannot bisect (no known good revisions)')) |
|
306 | 306 | else: |
|
307 | 307 | raise util.Abort(_('cannot bisect (no known bad revisions)')) |
|
308 | 308 | return True |
|
309 | 309 | |
|
310 | 310 | # backward compatibility |
|
311 | 311 | if rev in "good bad reset init".split(): |
|
312 | 312 | ui.warn(_("(use of 'hg bisect <cmd>' is deprecated)\n")) |
|
313 | 313 | cmd, rev, extra = rev, extra, None |
|
314 | 314 | if cmd == "good": |
|
315 | 315 | good = True |
|
316 | 316 | elif cmd == "bad": |
|
317 | 317 | bad = True |
|
318 | 318 | else: |
|
319 | 319 | reset = True |
|
320 | 320 | elif extra or good + bad + skip + reset + bool(command) > 1: |
|
321 | 321 | raise util.Abort(_('incompatible arguments')) |
|
322 | 322 | |
|
323 | 323 | if reset: |
|
324 | 324 | p = repo.join("bisect.state") |
|
325 | 325 | if os.path.exists(p): |
|
326 | 326 | os.unlink(p) |
|
327 | 327 | return |
|
328 | 328 | |
|
329 | 329 | state = hbisect.load_state(repo) |
|
330 | 330 | |
|
331 | 331 | if command: |
|
332 | 332 | commandpath = util.find_exe(command) |
|
333 | 333 | changesets = 1 |
|
334 | 334 | try: |
|
335 | 335 | while changesets: |
|
336 | 336 | # update state |
|
337 | 337 | status = os.spawnl(os.P_WAIT, commandpath, commandpath) |
|
338 | 338 | if status == 125: |
|
339 | 339 | transition = "skip" |
|
340 | 340 | elif status == 0: |
|
341 | 341 | transition = "good" |
|
342 | 342 | # status < 0 means process was killed |
|
343 | 343 | elif status == 127: |
|
344 | 344 | raise util.Abort(_("failed to execute %s") % command) |
|
345 | 345 | elif status < 0: |
|
346 | 346 | raise util.Abort(_("%s killed") % command) |
|
347 | 347 | else: |
|
348 | 348 | transition = "bad" |
|
349 | 349 | node = repo.lookup(rev or '.') |
|
350 | 350 | state[transition].append(node) |
|
351 | 351 | ui.note(_('Changeset %s: %s\n') % (short(node), transition)) |
|
352 | 352 | check_state(state, interactive=False) |
|
353 | 353 | # bisect |
|
354 | 354 | nodes, changesets, good = hbisect.bisect(repo.changelog, state) |
|
355 | 355 | # update to next check |
|
356 | 356 | cmdutil.bail_if_changed(repo) |
|
357 | 357 | hg.clean(repo, nodes[0], show_stats=False) |
|
358 | 358 | finally: |
|
359 | 359 | hbisect.save_state(repo, state) |
|
360 | 360 | return print_result(nodes, not status) |
|
361 | 361 | |
|
362 | 362 | # update state |
|
363 | 363 | node = repo.lookup(rev or '.') |
|
364 | 364 | if good: |
|
365 | 365 | state['good'].append(node) |
|
366 | 366 | elif bad: |
|
367 | 367 | state['bad'].append(node) |
|
368 | 368 | elif skip: |
|
369 | 369 | state['skip'].append(node) |
|
370 | 370 | |
|
371 | 371 | hbisect.save_state(repo, state) |
|
372 | 372 | |
|
373 | 373 | if not check_state(state): |
|
374 | 374 | return |
|
375 | 375 | |
|
376 | 376 | # actually bisect |
|
377 | 377 | nodes, changesets, good = hbisect.bisect(repo.changelog, state) |
|
378 | 378 | if changesets == 0: |
|
379 | 379 | print_result(nodes, good) |
|
380 | 380 | else: |
|
381 | 381 | assert len(nodes) == 1 # only a single node can be tested next |
|
382 | 382 | node = nodes[0] |
|
383 | 383 | # compute the approximate number of remaining tests |
|
384 | 384 | tests, size = 0, 2 |
|
385 | 385 | while size <= changesets: |
|
386 | 386 | tests, size = tests + 1, size * 2 |
|
387 | 387 | rev = repo.changelog.rev(node) |
|
388 | 388 | ui.write(_("Testing changeset %s:%s " |
|
389 | 389 | "(%s changesets remaining, ~%s tests)\n") |
|
390 | 390 | % (rev, short(node), changesets, tests)) |
|
391 | 391 | if not noupdate: |
|
392 | 392 | cmdutil.bail_if_changed(repo) |
|
393 | 393 | return hg.clean(repo, node) |
|
394 | 394 | |
|
395 | 395 | def branch(ui, repo, label=None, **opts): |
|
396 | 396 | """set or show the current branch name |
|
397 | 397 | |
|
398 | 398 | With no argument, show the current branch name. With one argument, |
|
399 | 399 | set the working directory branch name (the branch does not exist |
|
400 | 400 | in the repository until the next commit). It is recommended to use |
|
401 | 401 | the 'default' branch as your primary development branch. |
|
402 | 402 | |
|
403 | 403 | Unless --force is specified, branch will not let you set a branch |
|
404 | 404 | name that shadows an existing branch. |
|
405 | 405 | |
|
406 | 406 | Use --clean to reset the working directory branch to that of the |
|
407 | 407 | parent of the working directory, negating a previous branch |
|
408 | 408 | change. |
|
409 | 409 | |
|
410 | 410 | Use the command 'hg update' to switch to an existing branch. |
|
411 | 411 | """ |
|
412 | 412 | |
|
413 | 413 | if opts.get('clean'): |
|
414 | 414 | label = repo[None].parents()[0].branch() |
|
415 | 415 | repo.dirstate.setbranch(label) |
|
416 | 416 | ui.status(_('reset working directory to branch %s\n') % label) |
|
417 | 417 | elif label: |
|
418 | 418 | if not opts.get('force') and label in repo.branchtags(): |
|
419 | 419 | if label not in [p.branch() for p in repo.parents()]: |
|
420 | 420 | raise util.Abort(_('a branch of the same name already exists' |
|
421 | 421 | ' (use --force to override)')) |
|
422 | 422 | repo.dirstate.setbranch(encoding.fromlocal(label)) |
|
423 | 423 | ui.status(_('marked working directory as branch %s\n') % label) |
|
424 | 424 | else: |
|
425 | 425 | ui.write("%s\n" % encoding.tolocal(repo.dirstate.branch())) |
|
426 | 426 | |
|
427 | 427 | def branches(ui, repo, active=False): |
|
428 | 428 | """list repository named branches |
|
429 | 429 | |
|
430 | 430 | List the repository's named branches, indicating which ones are |
|
431 | 431 | inactive. If active is specified, only show active branches. |
|
432 | 432 | |
|
433 | 433 | A branch is considered active if it contains repository heads. |
|
434 | 434 | |
|
435 | 435 | Use the command 'hg update' to switch to an existing branch. |
|
436 | 436 | """ |
|
437 | 437 | hexfunc = ui.debugflag and hex or short |
|
438 | 438 | activebranches = [encoding.tolocal(repo[n].branch()) |
|
439 | 439 | for n in repo.heads(closed=False)] |
|
440 | 440 | branches = util.sort([(tag in activebranches, repo.changelog.rev(node), tag) |
|
441 | 441 | for tag, node in repo.branchtags().items()]) |
|
442 | 442 | branches.reverse() |
|
443 | 443 | |
|
444 | 444 | for isactive, node, tag in branches: |
|
445 | 445 | if (not active) or isactive: |
|
446 | 446 | if ui.quiet: |
|
447 | 447 | ui.write("%s\n" % tag) |
|
448 | 448 | else: |
|
449 | 449 | hn = repo.lookup(node) |
|
450 | 450 | if isactive: |
|
451 | 451 | notice = '' |
|
452 | 452 | elif hn not in repo.branchheads(tag, closed=False): |
|
453 | 453 | notice = ' (closed)' |
|
454 | 454 | else: |
|
455 | 455 | notice = ' (inactive)' |
|
456 | 456 | rev = str(node).rjust(31 - encoding.colwidth(tag)) |
|
457 | 457 | data = tag, rev, hexfunc(hn), notice |
|
458 | 458 | ui.write("%s %s:%s%s\n" % data) |
|
459 | 459 | |
|
460 | 460 | def bundle(ui, repo, fname, dest=None, **opts): |
|
461 | 461 | """create a changegroup file |
|
462 | 462 | |
|
463 | 463 | Generate a compressed changegroup file collecting changesets not |
|
464 | 464 | known to be in another repository. |
|
465 | 465 | |
|
466 | 466 | If no destination repository is specified the destination is |
|
467 | 467 | assumed to have all the nodes specified by one or more --base |
|
468 | 468 | parameters. To create a bundle containing all changesets, use |
|
469 | 469 | --all (or --base null). To change the compression method applied, |
|
470 | 470 | use the -t option (by default, bundles are compressed using bz2). |
|
471 | 471 | |
|
472 | 472 | The bundle file can then be transferred using conventional means |
|
473 | 473 | and applied to another repository with the unbundle or pull |
|
474 | 474 | command. This is useful when direct push and pull are not |
|
475 | 475 | available or when exporting an entire repository is undesirable. |
|
476 | 476 | |
|
477 | 477 | Applying bundles preserves all changeset contents including |
|
478 | 478 | permissions, copy/rename information, and revision history. |
|
479 | 479 | """ |
|
480 | 480 | revs = opts.get('rev') or None |
|
481 | 481 | if revs: |
|
482 | 482 | revs = [repo.lookup(rev) for rev in revs] |
|
483 | 483 | if opts.get('all'): |
|
484 | 484 | base = ['null'] |
|
485 | 485 | else: |
|
486 | 486 | base = opts.get('base') |
|
487 | 487 | if base: |
|
488 | 488 | if dest: |
|
489 | 489 | raise util.Abort(_("--base is incompatible with specifiying " |
|
490 | 490 | "a destination")) |
|
491 | 491 | base = [repo.lookup(rev) for rev in base] |
|
492 | 492 | # create the right base |
|
493 | 493 | # XXX: nodesbetween / changegroup* should be "fixed" instead |
|
494 | 494 | o = [] |
|
495 | 495 | has = {nullid: None} |
|
496 | 496 | for n in base: |
|
497 | 497 | has.update(repo.changelog.reachable(n)) |
|
498 | 498 | if revs: |
|
499 | 499 | visit = list(revs) |
|
500 | 500 | else: |
|
501 | 501 | visit = repo.changelog.heads() |
|
502 | 502 | seen = {} |
|
503 | 503 | while visit: |
|
504 | 504 | n = visit.pop(0) |
|
505 | 505 | parents = [p for p in repo.changelog.parents(n) if p not in has] |
|
506 | 506 | if len(parents) == 0: |
|
507 | 507 | o.insert(0, n) |
|
508 | 508 | else: |
|
509 | 509 | for p in parents: |
|
510 | 510 | if p not in seen: |
|
511 | 511 | seen[p] = 1 |
|
512 | 512 | visit.append(p) |
|
513 | 513 | else: |
|
514 | 514 | cmdutil.setremoteconfig(ui, opts) |
|
515 | 515 | dest, revs, checkout = hg.parseurl( |
|
516 | 516 | ui.expandpath(dest or 'default-push', dest or 'default'), revs) |
|
517 | 517 | other = hg.repository(ui, dest) |
|
518 | 518 | o = repo.findoutgoing(other, force=opts.get('force')) |
|
519 | 519 | |
|
520 | 520 | if revs: |
|
521 | 521 | cg = repo.changegroupsubset(o, revs, 'bundle') |
|
522 | 522 | else: |
|
523 | 523 | cg = repo.changegroup(o, 'bundle') |
|
524 | 524 | |
|
525 | 525 | bundletype = opts.get('type', 'bzip2').lower() |
|
526 | 526 | btypes = {'none': 'HG10UN', 'bzip2': 'HG10BZ', 'gzip': 'HG10GZ'} |
|
527 | 527 | bundletype = btypes.get(bundletype) |
|
528 | 528 | if bundletype not in changegroup.bundletypes: |
|
529 | 529 | raise util.Abort(_('unknown bundle type specified with --type')) |
|
530 | 530 | |
|
531 | 531 | changegroup.writebundle(cg, fname, bundletype) |
|
532 | 532 | |
|
533 | 533 | def cat(ui, repo, file1, *pats, **opts): |
|
534 | 534 | """output the current or given revision of files |
|
535 | 535 | |
|
536 | 536 | Print the specified files as they were at the given revision. If |
|
537 | 537 | no revision is given, the parent of the working directory is used, |
|
538 | 538 | or tip if no revision is checked out. |
|
539 | 539 | |
|
540 | 540 | Output may be to a file, in which case the name of the file is |
|
541 | 541 | given using a format string. The formatting rules are the same as |
|
542 | 542 | for the export command, with the following additions: |
|
543 | 543 | |
|
544 | 544 | %s basename of file being printed |
|
545 | 545 | %d dirname of file being printed, or '.' if in repo root |
|
546 | 546 | %p root-relative path name of file being printed |
|
547 | 547 | """ |
|
548 | 548 | ctx = repo[opts.get('rev')] |
|
549 | 549 | err = 1 |
|
550 | 550 | m = cmdutil.match(repo, (file1,) + pats, opts) |
|
551 | 551 | for abs in ctx.walk(m): |
|
552 | 552 | fp = cmdutil.make_file(repo, opts.get('output'), ctx.node(), pathname=abs) |
|
553 | 553 | data = ctx[abs].data() |
|
554 | 554 | if opts.get('decode'): |
|
555 | 555 | data = repo.wwritedata(abs, data) |
|
556 | 556 | fp.write(data) |
|
557 | 557 | err = 0 |
|
558 | 558 | return err |
|
559 | 559 | |
|
560 | 560 | def clone(ui, source, dest=None, **opts): |
|
561 | 561 | """make a copy of an existing repository |
|
562 | 562 | |
|
563 | 563 | Create a copy of an existing repository in a new directory. |
|
564 | 564 | |
|
565 | 565 | If no destination directory name is specified, it defaults to the |
|
566 | 566 | basename of the source. |
|
567 | 567 | |
|
568 | 568 | The location of the source is added to the new repository's |
|
569 | 569 | .hg/hgrc file, as the default to be used for future pulls. |
|
570 | 570 | |
|
571 | 571 | If you use the -r option to clone up to a specific revision, no |
|
572 | 572 | subsequent revisions (including subsequent tags) will be present |
|
573 | 573 | in the cloned repository. This option implies --pull, even on |
|
574 | 574 | local repositories. |
|
575 | 575 | |
|
576 | 576 | By default, clone will check out the head of the 'default' branch. |
|
577 | 577 | If the -U option is used, the new clone will contain only a |
|
578 | 578 | repository (.hg) and no working copy (the working copy parent is |
|
579 | 579 | the null revision). |
|
580 | 580 | |
|
581 | 581 | See 'hg help urls' for valid source format details. |
|
582 | 582 | |
|
583 | 583 | It is possible to specify an ssh:// URL as the destination, but no |
|
584 | 584 | .hg/hgrc and working directory will be created on the remote side. |
|
585 | 585 | Look at the help text for URLs for important details about ssh:// |
|
586 | 586 | URLs. |
|
587 | 587 | |
|
588 | 588 | For efficiency, hardlinks are used for cloning whenever the source |
|
589 | 589 | and destination are on the same filesystem (note this applies only |
|
590 | 590 | to the repository data, not to the checked out files). Some |
|
591 | 591 | filesystems, such as AFS, implement hardlinking incorrectly, but |
|
592 | 592 | do not report errors. In these cases, use the --pull option to |
|
593 | 593 | avoid hardlinking. |
|
594 | 594 | |
|
595 | 595 | In some cases, you can clone repositories and checked out files |
|
596 | 596 | using full hardlinks with |
|
597 | 597 | |
|
598 | 598 | $ cp -al REPO REPOCLONE |
|
599 | 599 | |
|
600 | 600 | This is the fastest way to clone, but it is not always safe. The |
|
601 | 601 | operation is not atomic (making sure REPO is not modified during |
|
602 | 602 | the operation is up to you) and you have to make sure your editor |
|
603 | 603 | breaks hardlinks (Emacs and most Linux Kernel tools do so). Also, |
|
604 | 604 | this is not compatible with certain extensions that place their |
|
605 | 605 | metadata under the .hg directory, such as mq. |
|
606 | 606 | |
|
607 | 607 | """ |
|
608 | 608 | cmdutil.setremoteconfig(ui, opts) |
|
609 | 609 | hg.clone(ui, source, dest, |
|
610 | 610 | pull=opts.get('pull'), |
|
611 | 611 | stream=opts.get('uncompressed'), |
|
612 | 612 | rev=opts.get('rev'), |
|
613 | 613 | update=not opts.get('noupdate')) |
|
614 | 614 | |
|
615 | 615 | def commit(ui, repo, *pats, **opts): |
|
616 | 616 | """commit the specified files or all outstanding changes |
|
617 | 617 | |
|
618 | 618 | Commit changes to the given files into the repository. Unlike a |
|
619 | 619 | centralized RCS, this operation is a local operation. See hg push |
|
620 | 620 | for means to actively distribute your changes. |
|
621 | 621 | |
|
622 | 622 | If a list of files is omitted, all changes reported by "hg status" |
|
623 | 623 | will be committed. |
|
624 | 624 | |
|
625 | 625 | If you are committing the result of a merge, do not provide any |
|
626 | 626 | file names or -I/-X filters. |
|
627 | 627 | |
|
628 | 628 | If no commit message is specified, the configured editor is |
|
629 | 629 | started to prompt you for a message. |
|
630 | 630 | |
|
631 | 631 | See 'hg help dates' for a list of formats valid for -d/--date. |
|
632 | 632 | """ |
|
633 | 633 | extra = {} |
|
634 | 634 | if opts.get('close_branch'): |
|
635 | 635 | extra['close'] = 1 |
|
636 | 636 | def commitfunc(ui, repo, message, match, opts): |
|
637 | 637 | return repo.commit(match.files(), message, opts.get('user'), |
|
638 | 638 | opts.get('date'), match, force_editor=opts.get('force_editor'), |
|
639 | 639 | extra=extra) |
|
640 | 640 | |
|
641 | 641 | node = cmdutil.commit(ui, repo, commitfunc, pats, opts) |
|
642 | 642 | if not node: |
|
643 | 643 | return |
|
644 | 644 | cl = repo.changelog |
|
645 | 645 | rev = cl.rev(node) |
|
646 | 646 | parents = cl.parentrevs(rev) |
|
647 | 647 | if rev - 1 in parents: |
|
648 | 648 | # one of the parents was the old tip |
|
649 | 649 | pass |
|
650 | 650 | elif (parents == (nullrev, nullrev) or |
|
651 | 651 | len(cl.heads(cl.node(parents[0]))) > 1 and |
|
652 | 652 | (parents[1] == nullrev or len(cl.heads(cl.node(parents[1]))) > 1)): |
|
653 | 653 | ui.status(_('created new head\n')) |
|
654 | 654 | |
|
655 | 655 | if ui.debugflag: |
|
656 | 656 | ui.write(_('committed changeset %d:%s\n') % (rev,hex(node))) |
|
657 | 657 | elif ui.verbose: |
|
658 | 658 | ui.write(_('committed changeset %d:%s\n') % (rev,short(node))) |
|
659 | 659 | |
|
660 | 660 | def copy(ui, repo, *pats, **opts): |
|
661 | 661 | """mark files as copied for the next commit |
|
662 | 662 | |
|
663 | 663 | Mark dest as having copies of source files. If dest is a |
|
664 | 664 | directory, copies are put in that directory. If dest is a file, |
|
665 | 665 | the source must be a single file. |
|
666 | 666 | |
|
667 | 667 | By default, this command copies the contents of files as they |
|
668 | 668 | stand in the working directory. If invoked with --after, the |
|
669 | 669 | operation is recorded, but no copying is performed. |
|
670 | 670 | |
|
671 | 671 | This command takes effect with the next commit. To undo a copy |
|
672 | 672 | before that, see hg revert. |
|
673 | 673 | """ |
|
674 | 674 | wlock = repo.wlock(False) |
|
675 | 675 | try: |
|
676 | 676 | return cmdutil.copy(ui, repo, pats, opts) |
|
677 | 677 | finally: |
|
678 | 678 | del wlock |
|
679 | 679 | |
|
680 | 680 | def debugancestor(ui, repo, *args): |
|
681 | 681 | """find the ancestor revision of two revisions in a given index""" |
|
682 | 682 | if len(args) == 3: |
|
683 | 683 | index, rev1, rev2 = args |
|
684 | 684 | r = revlog.revlog(util.opener(os.getcwd(), audit=False), index) |
|
685 | 685 | lookup = r.lookup |
|
686 | 686 | elif len(args) == 2: |
|
687 | 687 | if not repo: |
|
688 | 688 | raise util.Abort(_("There is no Mercurial repository here " |
|
689 | 689 | "(.hg not found)")) |
|
690 | 690 | rev1, rev2 = args |
|
691 | 691 | r = repo.changelog |
|
692 | 692 | lookup = repo.lookup |
|
693 | 693 | else: |
|
694 | 694 | raise util.Abort(_('either two or three arguments required')) |
|
695 | 695 | a = r.ancestor(lookup(rev1), lookup(rev2)) |
|
696 | 696 | ui.write("%d:%s\n" % (r.rev(a), hex(a))) |
|
697 | 697 | |
|
698 | 698 | def debugcommands(ui, cmd='', *args): |
|
699 | 699 | for cmd, vals in util.sort(table.iteritems()): |
|
700 | 700 | cmd = cmd.split('|')[0].strip('^') |
|
701 | 701 | opts = ', '.join([i[1] for i in vals[1]]) |
|
702 | 702 | ui.write('%s: %s\n' % (cmd, opts)) |
|
703 | 703 | |
|
704 | 704 | def debugcomplete(ui, cmd='', **opts): |
|
705 | 705 | """returns the completion list associated with the given command""" |
|
706 | 706 | |
|
707 | 707 | if opts.get('options'): |
|
708 | 708 | options = [] |
|
709 | 709 | otables = [globalopts] |
|
710 | 710 | if cmd: |
|
711 | 711 | aliases, entry = cmdutil.findcmd(cmd, table, False) |
|
712 | 712 | otables.append(entry[1]) |
|
713 | 713 | for t in otables: |
|
714 | 714 | for o in t: |
|
715 | 715 | if o[0]: |
|
716 | 716 | options.append('-%s' % o[0]) |
|
717 | 717 | options.append('--%s' % o[1]) |
|
718 | 718 | ui.write("%s\n" % "\n".join(options)) |
|
719 | 719 | return |
|
720 | 720 | |
|
721 | 721 | cmdlist = cmdutil.findpossible(cmd, table) |
|
722 | 722 | if ui.verbose: |
|
723 | 723 | cmdlist = [' '.join(c[0]) for c in cmdlist.values()] |
|
724 | 724 | ui.write("%s\n" % "\n".join(util.sort(cmdlist))) |
|
725 | 725 | |
|
726 | 726 | def debugfsinfo(ui, path = "."): |
|
727 | 727 | file('.debugfsinfo', 'w').write('') |
|
728 | 728 | ui.write('exec: %s\n' % (util.checkexec(path) and 'yes' or 'no')) |
|
729 | 729 | ui.write('symlink: %s\n' % (util.checklink(path) and 'yes' or 'no')) |
|
730 | 730 | ui.write('case-sensitive: %s\n' % (util.checkcase('.debugfsinfo') |
|
731 | 731 | and 'yes' or 'no')) |
|
732 | 732 | os.unlink('.debugfsinfo') |
|
733 | 733 | |
|
734 | 734 | def debugrebuildstate(ui, repo, rev="tip"): |
|
735 | 735 | """rebuild the dirstate as it would look like for the given revision""" |
|
736 | 736 | ctx = repo[rev] |
|
737 | 737 | wlock = repo.wlock() |
|
738 | 738 | try: |
|
739 | 739 | repo.dirstate.rebuild(ctx.node(), ctx.manifest()) |
|
740 | 740 | finally: |
|
741 | 741 | del wlock |
|
742 | 742 | |
|
743 | 743 | def debugcheckstate(ui, repo): |
|
744 | 744 | """validate the correctness of the current dirstate""" |
|
745 | 745 | parent1, parent2 = repo.dirstate.parents() |
|
746 | 746 | m1 = repo[parent1].manifest() |
|
747 | 747 | m2 = repo[parent2].manifest() |
|
748 | 748 | errors = 0 |
|
749 | 749 | for f in repo.dirstate: |
|
750 | 750 | state = repo.dirstate[f] |
|
751 | 751 | if state in "nr" and f not in m1: |
|
752 | 752 | ui.warn(_("%s in state %s, but not in manifest1\n") % (f, state)) |
|
753 | 753 | errors += 1 |
|
754 | 754 | if state in "a" and f in m1: |
|
755 | 755 | ui.warn(_("%s in state %s, but also in manifest1\n") % (f, state)) |
|
756 | 756 | errors += 1 |
|
757 | 757 | if state in "m" and f not in m1 and f not in m2: |
|
758 | 758 | ui.warn(_("%s in state %s, but not in either manifest\n") % |
|
759 | 759 | (f, state)) |
|
760 | 760 | errors += 1 |
|
761 | 761 | for f in m1: |
|
762 | 762 | state = repo.dirstate[f] |
|
763 | 763 | if state not in "nrm": |
|
764 | 764 | ui.warn(_("%s in manifest1, but listed as state %s") % (f, state)) |
|
765 | 765 | errors += 1 |
|
766 | 766 | if errors: |
|
767 | 767 | error = _(".hg/dirstate inconsistent with current parent's manifest") |
|
768 | 768 | raise util.Abort(error) |
|
769 | 769 | |
|
770 | 770 | def showconfig(ui, repo, *values, **opts): |
|
771 | 771 | """show combined config settings from all hgrc files |
|
772 | 772 | |
|
773 | 773 | With no args, print names and values of all config items. |
|
774 | 774 | |
|
775 | 775 | With one arg of the form section.name, print just the value of |
|
776 | 776 | that config item. |
|
777 | 777 | |
|
778 | 778 | With multiple args, print names and values of all config items |
|
779 | 779 | with matching section names.""" |
|
780 | 780 | |
|
781 | 781 | untrusted = bool(opts.get('untrusted')) |
|
782 | 782 | if values: |
|
783 | 783 | if len([v for v in values if '.' in v]) > 1: |
|
784 | 784 | raise util.Abort(_('only one config item permitted')) |
|
785 | 785 | for section, name, value in ui.walkconfig(untrusted=untrusted): |
|
786 | 786 | sectname = section + '.' + name |
|
787 | 787 | if values: |
|
788 | 788 | for v in values: |
|
789 | 789 | if v == section: |
|
790 | 790 | ui.write('%s=%s\n' % (sectname, value)) |
|
791 | 791 | elif v == sectname: |
|
792 | 792 | ui.write(value, '\n') |
|
793 | 793 | else: |
|
794 | 794 | ui.write('%s=%s\n' % (sectname, value)) |
|
795 | 795 | |
|
796 | 796 | def debugsetparents(ui, repo, rev1, rev2=None): |
|
797 | 797 | """manually set the parents of the current working directory |
|
798 | 798 | |
|
799 | 799 | This is useful for writing repository conversion tools, but should |
|
800 | 800 | be used with care. |
|
801 | 801 | """ |
|
802 | 802 | |
|
803 | 803 | if not rev2: |
|
804 | 804 | rev2 = hex(nullid) |
|
805 | 805 | |
|
806 | 806 | wlock = repo.wlock() |
|
807 | 807 | try: |
|
808 | 808 | repo.dirstate.setparents(repo.lookup(rev1), repo.lookup(rev2)) |
|
809 | 809 | finally: |
|
810 | 810 | del wlock |
|
811 | 811 | |
|
812 | 812 | def debugstate(ui, repo, nodates=None): |
|
813 | 813 | """show the contents of the current dirstate""" |
|
814 | 814 | timestr = "" |
|
815 | 815 | showdate = not nodates |
|
816 | 816 | for file_, ent in util.sort(repo.dirstate._map.iteritems()): |
|
817 | 817 | if showdate: |
|
818 | 818 | if ent[3] == -1: |
|
819 | 819 | # Pad or slice to locale representation |
|
820 | 820 | locale_len = len(time.strftime("%Y-%m-%d %H:%M:%S ", time.localtime(0))) |
|
821 | 821 | timestr = 'unset' |
|
822 | 822 | timestr = timestr[:locale_len] + ' '*(locale_len - len(timestr)) |
|
823 | 823 | else: |
|
824 | 824 | timestr = time.strftime("%Y-%m-%d %H:%M:%S ", time.localtime(ent[3])) |
|
825 | 825 | if ent[1] & 020000: |
|
826 | 826 | mode = 'lnk' |
|
827 | 827 | else: |
|
828 | 828 | mode = '%3o' % (ent[1] & 0777) |
|
829 | 829 | ui.write("%c %s %10d %s%s\n" % (ent[0], mode, ent[2], timestr, file_)) |
|
830 | 830 | for f in repo.dirstate.copies(): |
|
831 | 831 | ui.write(_("copy: %s -> %s\n") % (repo.dirstate.copied(f), f)) |
|
832 | 832 | |
|
833 | 833 | def debugdata(ui, file_, rev): |
|
834 | 834 | """dump the contents of a data file revision""" |
|
835 | 835 | r = revlog.revlog(util.opener(os.getcwd(), audit=False), file_[:-2] + ".i") |
|
836 | 836 | try: |
|
837 | 837 | ui.write(r.revision(r.lookup(rev))) |
|
838 | 838 | except KeyError: |
|
839 | 839 | raise util.Abort(_('invalid revision identifier %s') % rev) |
|
840 | 840 | |
|
841 | 841 | def debugdate(ui, date, range=None, **opts): |
|
842 | 842 | """parse and display a date""" |
|
843 | 843 | if opts["extended"]: |
|
844 | 844 | d = util.parsedate(date, util.extendeddateformats) |
|
845 | 845 | else: |
|
846 | 846 | d = util.parsedate(date) |
|
847 | 847 | ui.write("internal: %s %s\n" % d) |
|
848 | 848 | ui.write("standard: %s\n" % util.datestr(d)) |
|
849 | 849 | if range: |
|
850 | 850 | m = util.matchdate(range) |
|
851 | 851 | ui.write("match: %s\n" % m(d[0])) |
|
852 | 852 | |
|
853 | 853 | def debugindex(ui, file_): |
|
854 | 854 | """dump the contents of an index file""" |
|
855 | 855 | r = revlog.revlog(util.opener(os.getcwd(), audit=False), file_) |
|
856 | 856 | ui.write(" rev offset length base linkrev" |
|
857 | 857 | " nodeid p1 p2\n") |
|
858 | 858 | for i in r: |
|
859 | 859 | node = r.node(i) |
|
860 | 860 | try: |
|
861 | 861 | pp = r.parents(node) |
|
862 | 862 | except: |
|
863 | 863 | pp = [nullid, nullid] |
|
864 | 864 | ui.write("% 6d % 9d % 7d % 6d % 7d %s %s %s\n" % ( |
|
865 | 865 | i, r.start(i), r.length(i), r.base(i), r.linkrev(i), |
|
866 | 866 | short(node), short(pp[0]), short(pp[1]))) |
|
867 | 867 | |
|
868 | 868 | def debugindexdot(ui, file_): |
|
869 | 869 | """dump an index DAG as a .dot file""" |
|
870 | 870 | r = revlog.revlog(util.opener(os.getcwd(), audit=False), file_) |
|
871 | 871 | ui.write("digraph G {\n") |
|
872 | 872 | for i in r: |
|
873 | 873 | node = r.node(i) |
|
874 | 874 | pp = r.parents(node) |
|
875 | 875 | ui.write("\t%d -> %d\n" % (r.rev(pp[0]), i)) |
|
876 | 876 | if pp[1] != nullid: |
|
877 | 877 | ui.write("\t%d -> %d\n" % (r.rev(pp[1]), i)) |
|
878 | 878 | ui.write("}\n") |
|
879 | 879 | |
|
880 | 880 | def debuginstall(ui): |
|
881 | 881 | '''test Mercurial installation''' |
|
882 | 882 | |
|
883 | 883 | def writetemp(contents): |
|
884 | 884 | (fd, name) = tempfile.mkstemp(prefix="hg-debuginstall-") |
|
885 | 885 | f = os.fdopen(fd, "wb") |
|
886 | 886 | f.write(contents) |
|
887 | 887 | f.close() |
|
888 | 888 | return name |
|
889 | 889 | |
|
890 | 890 | problems = 0 |
|
891 | 891 | |
|
892 | 892 | # encoding |
|
893 | 893 | ui.status(_("Checking encoding (%s)...\n") % encoding.encoding) |
|
894 | 894 | try: |
|
895 | 895 | encoding.fromlocal("test") |
|
896 | 896 | except util.Abort, inst: |
|
897 | 897 | ui.write(" %s\n" % inst) |
|
898 | 898 | ui.write(_(" (check that your locale is properly set)\n")) |
|
899 | 899 | problems += 1 |
|
900 | 900 | |
|
901 | 901 | # compiled modules |
|
902 | 902 | ui.status(_("Checking extensions...\n")) |
|
903 | 903 | try: |
|
904 | 904 | import bdiff, mpatch, base85 |
|
905 | 905 | except Exception, inst: |
|
906 | 906 | ui.write(" %s\n" % inst) |
|
907 | 907 | ui.write(_(" One or more extensions could not be found")) |
|
908 | 908 | ui.write(_(" (check that you compiled the extensions)\n")) |
|
909 | 909 | problems += 1 |
|
910 | 910 | |
|
911 | 911 | # templates |
|
912 | 912 | ui.status(_("Checking templates...\n")) |
|
913 | 913 | try: |
|
914 | 914 | import templater |
|
915 | 915 | templater.templater(templater.templatepath("map-cmdline.default")) |
|
916 | 916 | except Exception, inst: |
|
917 | 917 | ui.write(" %s\n" % inst) |
|
918 | 918 | ui.write(_(" (templates seem to have been installed incorrectly)\n")) |
|
919 | 919 | problems += 1 |
|
920 | 920 | |
|
921 | 921 | # patch |
|
922 | 922 | ui.status(_("Checking patch...\n")) |
|
923 | 923 | patchproblems = 0 |
|
924 | 924 | a = "1\n2\n3\n4\n" |
|
925 | 925 | b = "1\n2\n3\ninsert\n4\n" |
|
926 | 926 | fa = writetemp(a) |
|
927 | 927 | d = mdiff.unidiff(a, None, b, None, os.path.basename(fa), |
|
928 | 928 | os.path.basename(fa)) |
|
929 | 929 | fd = writetemp(d) |
|
930 | 930 | |
|
931 | 931 | files = {} |
|
932 | 932 | try: |
|
933 | 933 | patch.patch(fd, ui, cwd=os.path.dirname(fa), files=files) |
|
934 | 934 | except util.Abort, e: |
|
935 | 935 | ui.write(_(" patch call failed:\n")) |
|
936 | 936 | ui.write(" " + str(e) + "\n") |
|
937 | 937 | patchproblems += 1 |
|
938 | 938 | else: |
|
939 | 939 | if list(files) != [os.path.basename(fa)]: |
|
940 | 940 | ui.write(_(" unexpected patch output!\n")) |
|
941 | 941 | patchproblems += 1 |
|
942 | 942 | a = file(fa).read() |
|
943 | 943 | if a != b: |
|
944 | 944 | ui.write(_(" patch test failed!\n")) |
|
945 | 945 | patchproblems += 1 |
|
946 | 946 | |
|
947 | 947 | if patchproblems: |
|
948 | 948 | if ui.config('ui', 'patch'): |
|
949 | 949 | ui.write(_(" (Current patch tool may be incompatible with patch," |
|
950 | 950 | " or misconfigured. Please check your .hgrc file)\n")) |
|
951 | 951 | else: |
|
952 | 952 | ui.write(_(" Internal patcher failure, please report this error" |
|
953 | 953 | " to http://www.selenic.com/mercurial/bts\n")) |
|
954 | 954 | problems += patchproblems |
|
955 | 955 | |
|
956 | 956 | os.unlink(fa) |
|
957 | 957 | os.unlink(fd) |
|
958 | 958 | |
|
959 | 959 | # editor |
|
960 | 960 | ui.status(_("Checking commit editor...\n")) |
|
961 | 961 | editor = ui.geteditor() |
|
962 | 962 | cmdpath = util.find_exe(editor) or util.find_exe(editor.split()[0]) |
|
963 | 963 | if not cmdpath: |
|
964 | 964 | if editor == 'vi': |
|
965 | 965 | ui.write(_(" No commit editor set and can't find vi in PATH\n")) |
|
966 | 966 | ui.write(_(" (specify a commit editor in your .hgrc file)\n")) |
|
967 | 967 | else: |
|
968 | 968 | ui.write(_(" Can't find editor '%s' in PATH\n") % editor) |
|
969 | 969 | ui.write(_(" (specify a commit editor in your .hgrc file)\n")) |
|
970 | 970 | problems += 1 |
|
971 | 971 | |
|
972 | 972 | # check username |
|
973 | 973 | ui.status(_("Checking username...\n")) |
|
974 | 974 | user = os.environ.get("HGUSER") |
|
975 | 975 | if user is None: |
|
976 | 976 | user = ui.config("ui", "username") |
|
977 | 977 | if user is None: |
|
978 | 978 | user = os.environ.get("EMAIL") |
|
979 | 979 | if not user: |
|
980 | 980 | ui.warn(" ") |
|
981 | 981 | ui.username() |
|
982 | 982 | ui.write(_(" (specify a username in your .hgrc file)\n")) |
|
983 | 983 | |
|
984 | 984 | if not problems: |
|
985 | 985 | ui.status(_("No problems detected\n")) |
|
986 | 986 | else: |
|
987 | 987 | ui.write(_("%s problems detected," |
|
988 | 988 | " please check your install!\n") % problems) |
|
989 | 989 | |
|
990 | 990 | return problems |
|
991 | 991 | |
|
992 | 992 | def debugrename(ui, repo, file1, *pats, **opts): |
|
993 | 993 | """dump rename information""" |
|
994 | 994 | |
|
995 | 995 | ctx = repo[opts.get('rev')] |
|
996 | 996 | m = cmdutil.match(repo, (file1,) + pats, opts) |
|
997 | 997 | for abs in ctx.walk(m): |
|
998 | 998 | fctx = ctx[abs] |
|
999 | 999 | o = fctx.filelog().renamed(fctx.filenode()) |
|
1000 | 1000 | rel = m.rel(abs) |
|
1001 | 1001 | if o: |
|
1002 | 1002 | ui.write(_("%s renamed from %s:%s\n") % (rel, o[0], hex(o[1]))) |
|
1003 | 1003 | else: |
|
1004 | 1004 | ui.write(_("%s not renamed\n") % rel) |
|
1005 | 1005 | |
|
1006 | 1006 | def debugwalk(ui, repo, *pats, **opts): |
|
1007 | 1007 | """show how files match on given patterns""" |
|
1008 | 1008 | m = cmdutil.match(repo, pats, opts) |
|
1009 | 1009 | items = list(repo.walk(m)) |
|
1010 | 1010 | if not items: |
|
1011 | 1011 | return |
|
1012 | 1012 | fmt = 'f %%-%ds %%-%ds %%s' % ( |
|
1013 | 1013 | max([len(abs) for abs in items]), |
|
1014 | 1014 | max([len(m.rel(abs)) for abs in items])) |
|
1015 | 1015 | for abs in items: |
|
1016 | 1016 | line = fmt % (abs, m.rel(abs), m.exact(abs) and 'exact' or '') |
|
1017 | 1017 | ui.write("%s\n" % line.rstrip()) |
|
1018 | 1018 | |
|
1019 | 1019 | def diff(ui, repo, *pats, **opts): |
|
1020 | 1020 | """diff repository (or selected files) |
|
1021 | 1021 | |
|
1022 | 1022 | Show differences between revisions for the specified files. |
|
1023 | 1023 | |
|
1024 | 1024 | Differences between files are shown using the unified diff format. |
|
1025 | 1025 | |
|
1026 | 1026 | NOTE: diff may generate unexpected results for merges, as it will |
|
1027 | 1027 | default to comparing against the working directory's first parent |
|
1028 | 1028 | changeset if no revisions are specified. |
|
1029 | 1029 | |
|
1030 | 1030 | When two revision arguments are given, then changes are shown |
|
1031 | 1031 | between those revisions. If only one revision is specified then |
|
1032 | 1032 | that revision is compared to the working directory, and, when no |
|
1033 | 1033 | revisions are specified, the working directory files are compared |
|
1034 | 1034 | to its parent. |
|
1035 | 1035 | |
|
1036 | 1036 | Without the -a option, diff will avoid generating diffs of files |
|
1037 | 1037 | it detects as binary. With -a, diff will generate a diff anyway, |
|
1038 | 1038 | probably with undesirable results. |
|
1039 | 1039 | |
|
1040 | 1040 | Use the --git option to generate diffs in the git extended diff |
|
1041 | 1041 | format. For more information, read 'hg help diffs'. |
|
1042 | 1042 | """ |
|
1043 | 1043 | |
|
1044 | 1044 | revs = opts.get('rev') |
|
1045 | 1045 | change = opts.get('change') |
|
1046 | 1046 | |
|
1047 | 1047 | if revs and change: |
|
1048 | 1048 | msg = _('cannot specify --rev and --change at the same time') |
|
1049 | 1049 | raise util.Abort(msg) |
|
1050 | 1050 | elif change: |
|
1051 | 1051 | node2 = repo.lookup(change) |
|
1052 | 1052 | node1 = repo[node2].parents()[0].node() |
|
1053 | 1053 | else: |
|
1054 | 1054 | node1, node2 = cmdutil.revpair(repo, revs) |
|
1055 | 1055 | |
|
1056 | 1056 | m = cmdutil.match(repo, pats, opts) |
|
1057 | 1057 | it = patch.diff(repo, node1, node2, match=m, opts=patch.diffopts(ui, opts)) |
|
1058 | 1058 | for chunk in it: |
|
1059 | 1059 | repo.ui.write(chunk) |
|
1060 | 1060 | |
|
1061 | 1061 | def export(ui, repo, *changesets, **opts): |
|
1062 | 1062 | """dump the header and diffs for one or more changesets |
|
1063 | 1063 | |
|
1064 | 1064 | Print the changeset header and diffs for one or more revisions. |
|
1065 | 1065 | |
|
1066 | 1066 | The information shown in the changeset header is: author, |
|
1067 | 1067 | changeset hash, parent(s) and commit comment. |
|
1068 | 1068 | |
|
1069 | 1069 | NOTE: export may generate unexpected diff output for merge |
|
1070 | 1070 | changesets, as it will compare the merge changeset against its |
|
1071 | 1071 | first parent only. |
|
1072 | 1072 | |
|
1073 | 1073 | Output may be to a file, in which case the name of the file is |
|
1074 | 1074 | given using a format string. The formatting rules are as follows: |
|
1075 | 1075 | |
|
1076 | 1076 | %% literal "%" character |
|
1077 | 1077 | %H changeset hash (40 bytes of hexadecimal) |
|
1078 | 1078 | %N number of patches being generated |
|
1079 | 1079 | %R changeset revision number |
|
1080 | 1080 | %b basename of the exporting repository |
|
1081 | 1081 | %h short-form changeset hash (12 bytes of hexadecimal) |
|
1082 | 1082 | %n zero-padded sequence number, starting at 1 |
|
1083 | 1083 | %r zero-padded changeset revision number |
|
1084 | 1084 | |
|
1085 | 1085 | Without the -a option, export will avoid generating diffs of files |
|
1086 | 1086 | it detects as binary. With -a, export will generate a diff anyway, |
|
1087 | 1087 | probably with undesirable results. |
|
1088 | 1088 | |
|
1089 | 1089 | Use the --git option to generate diffs in the git extended diff |
|
1090 | 1090 | format. Read the diffs help topic for more information. |
|
1091 | 1091 | |
|
1092 | 1092 | With the --switch-parent option, the diff will be against the |
|
1093 | 1093 | second parent. It can be useful to review a merge. |
|
1094 | 1094 | """ |
|
1095 | 1095 | if not changesets: |
|
1096 | 1096 | raise util.Abort(_("export requires at least one changeset")) |
|
1097 | 1097 | revs = cmdutil.revrange(repo, changesets) |
|
1098 | 1098 | if len(revs) > 1: |
|
1099 | 1099 | ui.note(_('exporting patches:\n')) |
|
1100 | 1100 | else: |
|
1101 | 1101 | ui.note(_('exporting patch:\n')) |
|
1102 | 1102 | patch.export(repo, revs, template=opts.get('output'), |
|
1103 | 1103 | switch_parent=opts.get('switch_parent'), |
|
1104 | 1104 | opts=patch.diffopts(ui, opts)) |
|
1105 | 1105 | |
|
1106 | 1106 | def grep(ui, repo, pattern, *pats, **opts): |
|
1107 | 1107 | """search for a pattern in specified files and revisions |
|
1108 | 1108 | |
|
1109 | 1109 | Search revisions of files for a regular expression. |
|
1110 | 1110 | |
|
1111 | 1111 | This command behaves differently than Unix grep. It only accepts |
|
1112 | 1112 | Python/Perl regexps. It searches repository history, not the |
|
1113 | 1113 | working directory. It always prints the revision number in which a |
|
1114 | 1114 | match appears. |
|
1115 | 1115 | |
|
1116 | 1116 | By default, grep only prints output for the first revision of a |
|
1117 | 1117 | file in which it finds a match. To get it to print every revision |
|
1118 | 1118 | that contains a change in match status ("-" for a match that |
|
1119 | 1119 | becomes a non-match, or "+" for a non-match that becomes a match), |
|
1120 | 1120 | use the --all flag. |
|
1121 | 1121 | """ |
|
1122 | 1122 | reflags = 0 |
|
1123 | 1123 | if opts.get('ignore_case'): |
|
1124 | 1124 | reflags |= re.I |
|
1125 | 1125 | try: |
|
1126 | 1126 | regexp = re.compile(pattern, reflags) |
|
1127 | 1127 | except Exception, inst: |
|
1128 | 1128 | ui.warn(_("grep: invalid match pattern: %s\n") % inst) |
|
1129 | 1129 | return None |
|
1130 | 1130 | sep, eol = ':', '\n' |
|
1131 | 1131 | if opts.get('print0'): |
|
1132 | 1132 | sep = eol = '\0' |
|
1133 | 1133 | |
|
1134 | 1134 | fcache = {} |
|
1135 | 1135 | def getfile(fn): |
|
1136 | 1136 | if fn not in fcache: |
|
1137 | 1137 | fcache[fn] = repo.file(fn) |
|
1138 | 1138 | return fcache[fn] |
|
1139 | 1139 | |
|
1140 | 1140 | def matchlines(body): |
|
1141 | 1141 | begin = 0 |
|
1142 | 1142 | linenum = 0 |
|
1143 | 1143 | while True: |
|
1144 | 1144 | match = regexp.search(body, begin) |
|
1145 | 1145 | if not match: |
|
1146 | 1146 | break |
|
1147 | 1147 | mstart, mend = match.span() |
|
1148 | 1148 | linenum += body.count('\n', begin, mstart) + 1 |
|
1149 | 1149 | lstart = body.rfind('\n', begin, mstart) + 1 or begin |
|
1150 | 1150 | begin = body.find('\n', mend) + 1 or len(body) |
|
1151 | 1151 | lend = begin - 1 |
|
1152 | 1152 | yield linenum, mstart - lstart, mend - lstart, body[lstart:lend] |
|
1153 | 1153 | |
|
1154 | 1154 | class linestate(object): |
|
1155 | 1155 | def __init__(self, line, linenum, colstart, colend): |
|
1156 | 1156 | self.line = line |
|
1157 | 1157 | self.linenum = linenum |
|
1158 | 1158 | self.colstart = colstart |
|
1159 | 1159 | self.colend = colend |
|
1160 | 1160 | |
|
1161 | 1161 | def __hash__(self): |
|
1162 | 1162 | return hash((self.linenum, self.line)) |
|
1163 | 1163 | |
|
1164 | 1164 | def __eq__(self, other): |
|
1165 | 1165 | return self.line == other.line |
|
1166 | 1166 | |
|
1167 | 1167 | matches = {} |
|
1168 | 1168 | copies = {} |
|
1169 | 1169 | def grepbody(fn, rev, body): |
|
1170 | 1170 | matches[rev].setdefault(fn, []) |
|
1171 | 1171 | m = matches[rev][fn] |
|
1172 | 1172 | for lnum, cstart, cend, line in matchlines(body): |
|
1173 | 1173 | s = linestate(line, lnum, cstart, cend) |
|
1174 | 1174 | m.append(s) |
|
1175 | 1175 | |
|
1176 | 1176 | def difflinestates(a, b): |
|
1177 | 1177 | sm = difflib.SequenceMatcher(None, a, b) |
|
1178 | 1178 | for tag, alo, ahi, blo, bhi in sm.get_opcodes(): |
|
1179 | 1179 | if tag == 'insert': |
|
1180 | 1180 | for i in xrange(blo, bhi): |
|
1181 | 1181 | yield ('+', b[i]) |
|
1182 | 1182 | elif tag == 'delete': |
|
1183 | 1183 | for i in xrange(alo, ahi): |
|
1184 | 1184 | yield ('-', a[i]) |
|
1185 | 1185 | elif tag == 'replace': |
|
1186 | 1186 | for i in xrange(alo, ahi): |
|
1187 | 1187 | yield ('-', a[i]) |
|
1188 | 1188 | for i in xrange(blo, bhi): |
|
1189 | 1189 | yield ('+', b[i]) |
|
1190 | 1190 | |
|
1191 | 1191 | prev = {} |
|
1192 | 1192 | def display(fn, rev, states, prevstates): |
|
1193 | 1193 | datefunc = ui.quiet and util.shortdate or util.datestr |
|
1194 | 1194 | found = False |
|
1195 | 1195 | filerevmatches = {} |
|
1196 | 1196 | r = prev.get(fn, -1) |
|
1197 | 1197 | if opts.get('all'): |
|
1198 | 1198 | iter = difflinestates(states, prevstates) |
|
1199 | 1199 | else: |
|
1200 | 1200 | iter = [('', l) for l in prevstates] |
|
1201 | 1201 | for change, l in iter: |
|
1202 | 1202 | cols = [fn, str(r)] |
|
1203 | 1203 | if opts.get('line_number'): |
|
1204 | 1204 | cols.append(str(l.linenum)) |
|
1205 | 1205 | if opts.get('all'): |
|
1206 | 1206 | cols.append(change) |
|
1207 | 1207 | if opts.get('user'): |
|
1208 | 1208 | cols.append(ui.shortuser(get(r)[1])) |
|
1209 | 1209 | if opts.get('date'): |
|
1210 | 1210 | cols.append(datefunc(get(r)[2])) |
|
1211 | 1211 | if opts.get('files_with_matches'): |
|
1212 | 1212 | c = (fn, r) |
|
1213 | 1213 | if c in filerevmatches: |
|
1214 | 1214 | continue |
|
1215 | 1215 | filerevmatches[c] = 1 |
|
1216 | 1216 | else: |
|
1217 | 1217 | cols.append(l.line) |
|
1218 | 1218 | ui.write(sep.join(cols), eol) |
|
1219 | 1219 | found = True |
|
1220 | 1220 | return found |
|
1221 | 1221 | |
|
1222 | 1222 | fstate = {} |
|
1223 | 1223 | skip = {} |
|
1224 | 1224 | get = util.cachefunc(lambda r: repo[r].changeset()) |
|
1225 | 1225 | changeiter, matchfn = cmdutil.walkchangerevs(ui, repo, pats, get, opts) |
|
1226 | 1226 | found = False |
|
1227 | 1227 | follow = opts.get('follow') |
|
1228 | 1228 | for st, rev, fns in changeiter: |
|
1229 | 1229 | if st == 'window': |
|
1230 | 1230 | matches.clear() |
|
1231 | 1231 | elif st == 'add': |
|
1232 | 1232 | ctx = repo[rev] |
|
1233 | 1233 | matches[rev] = {} |
|
1234 | 1234 | for fn in fns: |
|
1235 | 1235 | if fn in skip: |
|
1236 | 1236 | continue |
|
1237 | 1237 | try: |
|
1238 | 1238 | grepbody(fn, rev, getfile(fn).read(ctx.filenode(fn))) |
|
1239 | 1239 | fstate.setdefault(fn, []) |
|
1240 | 1240 | if follow: |
|
1241 | 1241 | copied = getfile(fn).renamed(ctx.filenode(fn)) |
|
1242 | 1242 | if copied: |
|
1243 | 1243 | copies.setdefault(rev, {})[fn] = copied[0] |
|
1244 | 1244 | except error.LookupError: |
|
1245 | 1245 | pass |
|
1246 | 1246 | elif st == 'iter': |
|
1247 | 1247 | for fn, m in util.sort(matches[rev].items()): |
|
1248 | 1248 | copy = copies.get(rev, {}).get(fn) |
|
1249 | 1249 | if fn in skip: |
|
1250 | 1250 | if copy: |
|
1251 | 1251 | skip[copy] = True |
|
1252 | 1252 | continue |
|
1253 | 1253 | if fn in prev or fstate[fn]: |
|
1254 | 1254 | r = display(fn, rev, m, fstate[fn]) |
|
1255 | 1255 | found = found or r |
|
1256 | 1256 | if r and not opts.get('all'): |
|
1257 | 1257 | skip[fn] = True |
|
1258 | 1258 | if copy: |
|
1259 | 1259 | skip[copy] = True |
|
1260 | 1260 | fstate[fn] = m |
|
1261 | 1261 | if copy: |
|
1262 | 1262 | fstate[copy] = m |
|
1263 | 1263 | prev[fn] = rev |
|
1264 | 1264 | |
|
1265 | 1265 | for fn, state in util.sort(fstate.items()): |
|
1266 | 1266 | if fn in skip: |
|
1267 | 1267 | continue |
|
1268 | 1268 | if fn not in copies.get(prev[fn], {}): |
|
1269 | 1269 | found = display(fn, rev, {}, state) or found |
|
1270 | 1270 | return (not found and 1) or 0 |
|
1271 | 1271 | |
|
1272 | 1272 | def heads(ui, repo, *branchrevs, **opts): |
|
1273 | 1273 | """show current repository heads or show branch heads |
|
1274 | 1274 | |
|
1275 | 1275 | With no arguments, show all repository head changesets. |
|
1276 | 1276 | |
|
1277 | 1277 | If branch or revisions names are given this will show the heads of |
|
1278 | 1278 | the specified branches or the branches those revisions are tagged |
|
1279 | 1279 | with. |
|
1280 | 1280 | |
|
1281 | 1281 | Repository "heads" are changesets that don't have child |
|
1282 | 1282 | changesets. They are where development generally takes place and |
|
1283 | 1283 | are the usual targets for update and merge operations. |
|
1284 | 1284 | |
|
1285 | 1285 | Branch heads are changesets that have a given branch tag, but have |
|
1286 | 1286 | no child changesets with that tag. They are usually where |
|
1287 | 1287 | development on the given branch takes place. |
|
1288 | 1288 | """ |
|
1289 | 1289 | if opts.get('rev'): |
|
1290 | 1290 | start = repo.lookup(opts['rev']) |
|
1291 | 1291 | else: |
|
1292 | 1292 | start = None |
|
1293 | 1293 | closed = not opts.get('active') |
|
1294 | 1294 | if not branchrevs: |
|
1295 | 1295 | # Assume we're looking repo-wide heads if no revs were specified. |
|
1296 | 1296 | heads = repo.heads(start, closed=closed) |
|
1297 | 1297 | else: |
|
1298 | 1298 | heads = [] |
|
1299 | 1299 | visitedset = util.set() |
|
1300 | 1300 | for branchrev in branchrevs: |
|
1301 | 1301 | branch = repo[branchrev].branch() |
|
1302 | 1302 | if branch in visitedset: |
|
1303 | 1303 | continue |
|
1304 | 1304 | visitedset.add(branch) |
|
1305 | 1305 | bheads = repo.branchheads(branch, start, closed=closed) |
|
1306 | 1306 | if not bheads: |
|
1307 | 1307 | if branch != branchrev: |
|
1308 | 1308 | ui.warn(_("no changes on branch %s containing %s are " |
|
1309 | 1309 | "reachable from %s\n") |
|
1310 | 1310 | % (branch, branchrev, opts.get('rev'))) |
|
1311 | 1311 | else: |
|
1312 | 1312 | ui.warn(_("no changes on branch %s are reachable from %s\n") |
|
1313 | 1313 | % (branch, opts.get('rev'))) |
|
1314 | 1314 | heads.extend(bheads) |
|
1315 | 1315 | if not heads: |
|
1316 | 1316 | return 1 |
|
1317 | 1317 | displayer = cmdutil.show_changeset(ui, repo, opts) |
|
1318 | 1318 | for n in heads: |
|
1319 | 1319 | displayer.show(repo[n]) |
|
1320 | 1320 | |
|
1321 | 1321 | def help_(ui, name=None, with_version=False): |
|
1322 | 1322 | """show help for a given topic or a help overview |
|
1323 | 1323 | |
|
1324 | 1324 | With no arguments, print a list of commands and short help. |
|
1325 | 1325 | |
|
1326 | 1326 | Given a topic, extension, or command name, print help for that |
|
1327 | 1327 | topic.""" |
|
1328 | 1328 | option_lists = [] |
|
1329 | 1329 | |
|
1330 | 1330 | def addglobalopts(aliases): |
|
1331 | 1331 | if ui.verbose: |
|
1332 | 1332 | option_lists.append((_("global options:"), globalopts)) |
|
1333 | 1333 | if name == 'shortlist': |
|
1334 | 1334 | option_lists.append((_('use "hg help" for the full list ' |
|
1335 | 1335 | 'of commands'), ())) |
|
1336 | 1336 | else: |
|
1337 | 1337 | if name == 'shortlist': |
|
1338 | 1338 | msg = _('use "hg help" for the full list of commands ' |
|
1339 | 1339 | 'or "hg -v" for details') |
|
1340 | 1340 | elif aliases: |
|
1341 | 1341 | msg = _('use "hg -v help%s" to show aliases and ' |
|
1342 | 1342 | 'global options') % (name and " " + name or "") |
|
1343 | 1343 | else: |
|
1344 | 1344 | msg = _('use "hg -v help %s" to show global options') % name |
|
1345 | 1345 | option_lists.append((msg, ())) |
|
1346 | 1346 | |
|
1347 | 1347 | def helpcmd(name): |
|
1348 | 1348 | if with_version: |
|
1349 | 1349 | version_(ui) |
|
1350 | 1350 | ui.write('\n') |
|
1351 | 1351 | |
|
1352 | 1352 | try: |
|
1353 | 1353 | aliases, i = cmdutil.findcmd(name, table, False) |
|
1354 | 1354 | except error.AmbiguousCommand, inst: |
|
1355 | 1355 | select = lambda c: c.lstrip('^').startswith(inst.args[0]) |
|
1356 | 1356 | helplist(_('list of commands:\n\n'), select) |
|
1357 | 1357 | return |
|
1358 | 1358 | |
|
1359 | 1359 | # synopsis |
|
1360 | 1360 | if len(i) > 2: |
|
1361 | 1361 | if i[2].startswith('hg'): |
|
1362 | 1362 | ui.write("%s\n" % i[2]) |
|
1363 | 1363 | else: |
|
1364 | 1364 | ui.write('hg %s %s\n' % (aliases[0], i[2])) |
|
1365 | 1365 | else: |
|
1366 | 1366 | ui.write('hg %s\n' % aliases[0]) |
|
1367 | 1367 | |
|
1368 | 1368 | # aliases |
|
1369 | 1369 | if not ui.quiet and len(aliases) > 1: |
|
1370 | 1370 | ui.write(_("\naliases: %s\n") % ', '.join(aliases[1:])) |
|
1371 | 1371 | |
|
1372 | 1372 | # description |
|
1373 | 1373 | doc = gettext(i[0].__doc__) |
|
1374 | 1374 | if not doc: |
|
1375 | 1375 | doc = _("(no help text available)") |
|
1376 | 1376 | if ui.quiet: |
|
1377 | 1377 | doc = doc.splitlines(0)[0] |
|
1378 | 1378 | ui.write("\n%s\n" % doc.rstrip()) |
|
1379 | 1379 | |
|
1380 | 1380 | if not ui.quiet: |
|
1381 | 1381 | # options |
|
1382 | 1382 | if i[1]: |
|
1383 | 1383 | option_lists.append((_("options:\n"), i[1])) |
|
1384 | 1384 | |
|
1385 | 1385 | addglobalopts(False) |
|
1386 | 1386 | |
|
1387 | 1387 | def helplist(header, select=None): |
|
1388 | 1388 | h = {} |
|
1389 | 1389 | cmds = {} |
|
1390 | 1390 | for c, e in table.iteritems(): |
|
1391 | 1391 | f = c.split("|", 1)[0] |
|
1392 | 1392 | if select and not select(f): |
|
1393 | 1393 | continue |
|
1394 | 1394 | if (not select and name != 'shortlist' and |
|
1395 | 1395 | e[0].__module__ != __name__): |
|
1396 | 1396 | continue |
|
1397 | 1397 | if name == "shortlist" and not f.startswith("^"): |
|
1398 | 1398 | continue |
|
1399 | 1399 | f = f.lstrip("^") |
|
1400 | 1400 | if not ui.debugflag and f.startswith("debug"): |
|
1401 | 1401 | continue |
|
1402 | 1402 | doc = gettext(e[0].__doc__) |
|
1403 | 1403 | if not doc: |
|
1404 | 1404 | doc = _("(no help text available)") |
|
1405 | 1405 | h[f] = doc.splitlines(0)[0].rstrip() |
|
1406 | 1406 | cmds[f] = c.lstrip("^") |
|
1407 | 1407 | |
|
1408 | 1408 | if not h: |
|
1409 | 1409 | ui.status(_('no commands defined\n')) |
|
1410 | 1410 | return |
|
1411 | 1411 | |
|
1412 | 1412 | ui.status(header) |
|
1413 | 1413 | fns = util.sort(h) |
|
1414 | 1414 | m = max(map(len, fns)) |
|
1415 | 1415 | for f in fns: |
|
1416 | 1416 | if ui.verbose: |
|
1417 | 1417 | commands = cmds[f].replace("|",", ") |
|
1418 | 1418 | ui.write(" %s:\n %s\n"%(commands, h[f])) |
|
1419 | 1419 | else: |
|
1420 | 1420 | ui.write(' %-*s %s\n' % (m, f, h[f])) |
|
1421 | 1421 | |
|
1422 | 1422 | exts = list(extensions.extensions()) |
|
1423 | 1423 | if exts and name != 'shortlist': |
|
1424 | 1424 | ui.write(_('\nenabled extensions:\n\n')) |
|
1425 | 1425 | maxlength = 0 |
|
1426 | 1426 | exthelps = [] |
|
1427 | 1427 | for ename, ext in exts: |
|
1428 | 1428 | doc = (gettext(ext.__doc__) or _('(no help text available)')) |
|
1429 | 1429 | ename = ename.split('.')[-1] |
|
1430 | 1430 | maxlength = max(len(ename), maxlength) |
|
1431 | 1431 | exthelps.append((ename, doc.splitlines(0)[0].strip())) |
|
1432 | 1432 | for ename, text in exthelps: |
|
1433 | 1433 | ui.write(_(' %s %s\n') % (ename.ljust(maxlength), text)) |
|
1434 | 1434 | |
|
1435 | 1435 | if not ui.quiet: |
|
1436 | 1436 | addglobalopts(True) |
|
1437 | 1437 | |
|
1438 | 1438 | def helptopic(name): |
|
1439 | 1439 | for names, header, doc in help.helptable: |
|
1440 | 1440 | if name in names: |
|
1441 | 1441 | break |
|
1442 | 1442 | else: |
|
1443 | 1443 | raise error.UnknownCommand(name) |
|
1444 | 1444 | |
|
1445 | 1445 | # description |
|
1446 | 1446 | if not doc: |
|
1447 | 1447 | doc = _("(no help text available)") |
|
1448 | 1448 | if callable(doc): |
|
1449 | 1449 | doc = doc() |
|
1450 | 1450 | |
|
1451 | 1451 | ui.write("%s\n" % header) |
|
1452 | 1452 | ui.write("%s\n" % doc.rstrip()) |
|
1453 | 1453 | |
|
1454 | 1454 | def helpext(name): |
|
1455 | 1455 | try: |
|
1456 | 1456 | mod = extensions.find(name) |
|
1457 | 1457 | except KeyError: |
|
1458 | 1458 | raise error.UnknownCommand(name) |
|
1459 | 1459 | |
|
1460 | 1460 | doc = gettext(mod.__doc__) or _('no help text available') |
|
1461 | 1461 | doc = doc.splitlines(0) |
|
1462 | 1462 | ui.write(_('%s extension - %s\n') % (name.split('.')[-1], doc[0])) |
|
1463 | 1463 | for d in doc[1:]: |
|
1464 | 1464 | ui.write(d, '\n') |
|
1465 | 1465 | |
|
1466 | 1466 | ui.status('\n') |
|
1467 | 1467 | |
|
1468 | 1468 | try: |
|
1469 | 1469 | ct = mod.cmdtable |
|
1470 | 1470 | except AttributeError: |
|
1471 | 1471 | ct = {} |
|
1472 | 1472 | |
|
1473 | 1473 | modcmds = dict.fromkeys([c.split('|', 1)[0] for c in ct]) |
|
1474 | 1474 | helplist(_('list of commands:\n\n'), modcmds.has_key) |
|
1475 | 1475 | |
|
1476 | 1476 | if name and name != 'shortlist': |
|
1477 | 1477 | i = None |
|
1478 | 1478 | for f in (helptopic, helpcmd, helpext): |
|
1479 | 1479 | try: |
|
1480 | 1480 | f(name) |
|
1481 | 1481 | i = None |
|
1482 | 1482 | break |
|
1483 | 1483 | except error.UnknownCommand, inst: |
|
1484 | 1484 | i = inst |
|
1485 | 1485 | if i: |
|
1486 | 1486 | raise i |
|
1487 | 1487 | |
|
1488 | 1488 | else: |
|
1489 | 1489 | # program name |
|
1490 | 1490 | if ui.verbose or with_version: |
|
1491 | 1491 | version_(ui) |
|
1492 | 1492 | else: |
|
1493 | 1493 | ui.status(_("Mercurial Distributed SCM\n")) |
|
1494 | 1494 | ui.status('\n') |
|
1495 | 1495 | |
|
1496 | 1496 | # list of commands |
|
1497 | 1497 | if name == "shortlist": |
|
1498 | 1498 | header = _('basic commands:\n\n') |
|
1499 | 1499 | else: |
|
1500 | 1500 | header = _('list of commands:\n\n') |
|
1501 | 1501 | |
|
1502 | 1502 | helplist(header) |
|
1503 | 1503 | |
|
1504 | 1504 | # list all option lists |
|
1505 | 1505 | opt_output = [] |
|
1506 | 1506 | for title, options in option_lists: |
|
1507 | 1507 | opt_output.append(("\n%s" % title, None)) |
|
1508 | 1508 | for shortopt, longopt, default, desc in options: |
|
1509 | 1509 | if "DEPRECATED" in desc and not ui.verbose: continue |
|
1510 | 1510 | opt_output.append(("%2s%s" % (shortopt and "-%s" % shortopt, |
|
1511 | 1511 | longopt and " --%s" % longopt), |
|
1512 | 1512 | "%s%s" % (desc, |
|
1513 | 1513 | default |
|
1514 | 1514 | and _(" (default: %s)") % default |
|
1515 | 1515 | or ""))) |
|
1516 | 1516 | |
|
1517 | 1517 | if not name: |
|
1518 | 1518 | ui.write(_("\nadditional help topics:\n\n")) |
|
1519 | 1519 | topics = [] |
|
1520 | 1520 | for names, header, doc in help.helptable: |
|
1521 | 1521 | names = [(-len(name), name) for name in names] |
|
1522 | 1522 | names.sort() |
|
1523 | 1523 | topics.append((names[0][1], header)) |
|
1524 | 1524 | topics_len = max([len(s[0]) for s in topics]) |
|
1525 | 1525 | for t, desc in topics: |
|
1526 | 1526 | ui.write(" %-*s %s\n" % (topics_len, t, desc)) |
|
1527 | 1527 | |
|
1528 | 1528 | if opt_output: |
|
1529 | 1529 | opts_len = max([len(line[0]) for line in opt_output if line[1]] or [0]) |
|
1530 | 1530 | for first, second in opt_output: |
|
1531 | 1531 | if second: |
|
1532 | 1532 | ui.write(" %-*s %s\n" % (opts_len, first, second)) |
|
1533 | 1533 | else: |
|
1534 | 1534 | ui.write("%s\n" % first) |
|
1535 | 1535 | |
|
1536 | 1536 | def identify(ui, repo, source=None, |
|
1537 | 1537 | rev=None, num=None, id=None, branch=None, tags=None): |
|
1538 | 1538 | """identify the working copy or specified revision |
|
1539 | 1539 | |
|
1540 | 1540 | With no revision, print a summary of the current state of the |
|
1541 | 1541 | repo. |
|
1542 | 1542 | |
|
1543 | 1543 | With a path, do a lookup in another repository. |
|
1544 | 1544 | |
|
1545 | 1545 | This summary identifies the repository state using one or two |
|
1546 | 1546 | parent hash identifiers, followed by a "+" if there are |
|
1547 | 1547 | uncommitted changes in the working directory, a list of tags for |
|
1548 | 1548 | this revision and a branch name for non-default branches. |
|
1549 | 1549 | """ |
|
1550 | 1550 | |
|
1551 | 1551 | if not repo and not source: |
|
1552 | 1552 | raise util.Abort(_("There is no Mercurial repository here " |
|
1553 | 1553 | "(.hg not found)")) |
|
1554 | 1554 | |
|
1555 | 1555 | hexfunc = ui.debugflag and hex or short |
|
1556 | 1556 | default = not (num or id or branch or tags) |
|
1557 | 1557 | output = [] |
|
1558 | 1558 | |
|
1559 | 1559 | revs = [] |
|
1560 | 1560 | if source: |
|
1561 | 1561 | source, revs, checkout = hg.parseurl(ui.expandpath(source), []) |
|
1562 | 1562 | repo = hg.repository(ui, source) |
|
1563 | 1563 | |
|
1564 | 1564 | if not repo.local(): |
|
1565 | 1565 | if not rev and revs: |
|
1566 | 1566 | rev = revs[0] |
|
1567 | 1567 | if not rev: |
|
1568 | 1568 | rev = "tip" |
|
1569 | 1569 | if num or branch or tags: |
|
1570 | 1570 | raise util.Abort( |
|
1571 | 1571 | "can't query remote revision number, branch, or tags") |
|
1572 | 1572 | output = [hexfunc(repo.lookup(rev))] |
|
1573 | 1573 | elif not rev: |
|
1574 | 1574 | ctx = repo[None] |
|
1575 | 1575 | parents = ctx.parents() |
|
1576 | 1576 | changed = False |
|
1577 | 1577 | if default or id or num: |
|
1578 | 1578 | changed = ctx.files() + ctx.deleted() |
|
1579 | 1579 | if default or id: |
|
1580 | 1580 | output = ["%s%s" % ('+'.join([hexfunc(p.node()) for p in parents]), |
|
1581 | 1581 | (changed) and "+" or "")] |
|
1582 | 1582 | if num: |
|
1583 | 1583 | output.append("%s%s" % ('+'.join([str(p.rev()) for p in parents]), |
|
1584 | 1584 | (changed) and "+" or "")) |
|
1585 | 1585 | else: |
|
1586 | 1586 | ctx = repo[rev] |
|
1587 | 1587 | if default or id: |
|
1588 | 1588 | output = [hexfunc(ctx.node())] |
|
1589 | 1589 | if num: |
|
1590 | 1590 | output.append(str(ctx.rev())) |
|
1591 | 1591 | |
|
1592 | 1592 | if repo.local() and default and not ui.quiet: |
|
1593 | 1593 | b = encoding.tolocal(ctx.branch()) |
|
1594 | 1594 | if b != 'default': |
|
1595 | 1595 | output.append("(%s)" % b) |
|
1596 | 1596 | |
|
1597 | 1597 | # multiple tags for a single parent separated by '/' |
|
1598 | 1598 | t = "/".join(ctx.tags()) |
|
1599 | 1599 | if t: |
|
1600 | 1600 | output.append(t) |
|
1601 | 1601 | |
|
1602 | 1602 | if branch: |
|
1603 | 1603 | output.append(encoding.tolocal(ctx.branch())) |
|
1604 | 1604 | |
|
1605 | 1605 | if tags: |
|
1606 | 1606 | output.extend(ctx.tags()) |
|
1607 | 1607 | |
|
1608 | 1608 | ui.write("%s\n" % ' '.join(output)) |
|
1609 | 1609 | |
|
1610 | 1610 | def import_(ui, repo, patch1, *patches, **opts): |
|
1611 | 1611 | """import an ordered set of patches |
|
1612 | 1612 | |
|
1613 | 1613 | Import a list of patches and commit them individually. |
|
1614 | 1614 | |
|
1615 | 1615 | If there are outstanding changes in the working directory, import |
|
1616 | 1616 | will abort unless given the -f flag. |
|
1617 | 1617 | |
|
1618 | 1618 | You can import a patch straight from a mail message. Even patches |
|
1619 | 1619 | as attachments work (body part must be type text/plain or |
|
1620 | 1620 | text/x-patch to be used). From and Subject headers of email |
|
1621 | 1621 | message are used as default committer and commit message. All |
|
1622 | 1622 | text/plain body parts before first diff are added to commit |
|
1623 | 1623 | message. |
|
1624 | 1624 | |
|
1625 | 1625 | If the imported patch was generated by hg export, user and |
|
1626 | 1626 | description from patch override values from message headers and |
|
1627 | 1627 | body. Values given on command line with -m and -u override these. |
|
1628 | 1628 | |
|
1629 | 1629 | If --exact is specified, import will set the working directory to |
|
1630 | 1630 | the parent of each patch before applying it, and will abort if the |
|
1631 | 1631 | resulting changeset has a different ID than the one recorded in |
|
1632 | 1632 | the patch. This may happen due to character set problems or other |
|
1633 | 1633 | deficiencies in the text patch format. |
|
1634 | 1634 | |
|
1635 | 1635 | With --similarity, hg will attempt to discover renames and copies |
|
1636 | 1636 | in the patch in the same way as 'addremove'. |
|
1637 | 1637 | |
|
1638 | 1638 | To read a patch from standard input, use patch name "-". See 'hg |
|
1639 | 1639 | help dates' for a list of formats valid for -d/--date. |
|
1640 | 1640 | """ |
|
1641 | 1641 | patches = (patch1,) + patches |
|
1642 | 1642 | |
|
1643 | 1643 | date = opts.get('date') |
|
1644 | 1644 | if date: |
|
1645 | 1645 | opts['date'] = util.parsedate(date) |
|
1646 | 1646 | |
|
1647 | 1647 | try: |
|
1648 | 1648 | sim = float(opts.get('similarity') or 0) |
|
1649 | 1649 | except ValueError: |
|
1650 | 1650 | raise util.Abort(_('similarity must be a number')) |
|
1651 | 1651 | if sim < 0 or sim > 100: |
|
1652 | 1652 | raise util.Abort(_('similarity must be between 0 and 100')) |
|
1653 | 1653 | |
|
1654 | 1654 | if opts.get('exact') or not opts.get('force'): |
|
1655 | 1655 | cmdutil.bail_if_changed(repo) |
|
1656 | 1656 | |
|
1657 | 1657 | d = opts["base"] |
|
1658 | 1658 | strip = opts["strip"] |
|
1659 | 1659 | wlock = lock = None |
|
1660 | 1660 | try: |
|
1661 | 1661 | wlock = repo.wlock() |
|
1662 | 1662 | lock = repo.lock() |
|
1663 | 1663 | for p in patches: |
|
1664 | 1664 | pf = os.path.join(d, p) |
|
1665 | 1665 | |
|
1666 | 1666 | if pf == '-': |
|
1667 | 1667 | ui.status(_("applying patch from stdin\n")) |
|
1668 | 1668 | pf = sys.stdin |
|
1669 | 1669 | else: |
|
1670 | 1670 | ui.status(_("applying %s\n") % p) |
|
1671 | 1671 | pf = url.open(ui, pf) |
|
1672 | 1672 | data = patch.extract(ui, pf) |
|
1673 | 1673 | tmpname, message, user, date, branch, nodeid, p1, p2 = data |
|
1674 | 1674 | |
|
1675 | 1675 | if tmpname is None: |
|
1676 | 1676 | raise util.Abort(_('no diffs found')) |
|
1677 | 1677 | |
|
1678 | 1678 | try: |
|
1679 | 1679 | cmdline_message = cmdutil.logmessage(opts) |
|
1680 | 1680 | if cmdline_message: |
|
1681 | 1681 | # pickup the cmdline msg |
|
1682 | 1682 | message = cmdline_message |
|
1683 | 1683 | elif message: |
|
1684 | 1684 | # pickup the patch msg |
|
1685 | 1685 | message = message.strip() |
|
1686 | 1686 | else: |
|
1687 | 1687 | # launch the editor |
|
1688 | 1688 | message = None |
|
1689 | 1689 | ui.debug(_('message:\n%s\n') % message) |
|
1690 | 1690 | |
|
1691 | 1691 | wp = repo.parents() |
|
1692 | 1692 | if opts.get('exact'): |
|
1693 | 1693 | if not nodeid or not p1: |
|
1694 | 1694 | raise util.Abort(_('not a mercurial patch')) |
|
1695 | 1695 | p1 = repo.lookup(p1) |
|
1696 | 1696 | p2 = repo.lookup(p2 or hex(nullid)) |
|
1697 | 1697 | |
|
1698 | 1698 | if p1 != wp[0].node(): |
|
1699 | 1699 | hg.clean(repo, p1) |
|
1700 | 1700 | repo.dirstate.setparents(p1, p2) |
|
1701 | 1701 | elif p2: |
|
1702 | 1702 | try: |
|
1703 | 1703 | p1 = repo.lookup(p1) |
|
1704 | 1704 | p2 = repo.lookup(p2) |
|
1705 | 1705 | if p1 == wp[0].node(): |
|
1706 | 1706 | repo.dirstate.setparents(p1, p2) |
|
1707 | 1707 | except error.RepoError: |
|
1708 | 1708 | pass |
|
1709 | 1709 | if opts.get('exact') or opts.get('import_branch'): |
|
1710 | 1710 | repo.dirstate.setbranch(branch or 'default') |
|
1711 | 1711 | |
|
1712 | 1712 | files = {} |
|
1713 | 1713 | try: |
|
1714 | 1714 | patch.patch(tmpname, ui, strip=strip, cwd=repo.root, |
|
1715 | 1715 | files=files) |
|
1716 | 1716 | finally: |
|
1717 | 1717 | files = patch.updatedir(ui, repo, files, similarity=sim/100.) |
|
1718 | 1718 | if not opts.get('no_commit'): |
|
1719 | 1719 | n = repo.commit(files, message, opts.get('user') or user, |
|
1720 | 1720 | opts.get('date') or date) |
|
1721 | 1721 | if opts.get('exact'): |
|
1722 | 1722 | if hex(n) != nodeid: |
|
1723 | 1723 | repo.rollback() |
|
1724 | 1724 | raise util.Abort(_('patch is damaged' |
|
1725 | 1725 | ' or loses information')) |
|
1726 | 1726 | # Force a dirstate write so that the next transaction |
|
1727 | 1727 | # backups an up-do-date file. |
|
1728 | 1728 | repo.dirstate.write() |
|
1729 | 1729 | finally: |
|
1730 | 1730 | os.unlink(tmpname) |
|
1731 | 1731 | finally: |
|
1732 | 1732 | del lock, wlock |
|
1733 | 1733 | |
|
1734 | 1734 | def incoming(ui, repo, source="default", **opts): |
|
1735 | 1735 | """show new changesets found in source |
|
1736 | 1736 | |
|
1737 | 1737 | Show new changesets found in the specified path/URL or the default |
|
1738 | 1738 | pull location. These are the changesets that would be pulled if a |
|
1739 | 1739 | pull was requested. |
|
1740 | 1740 | |
|
1741 | 1741 | For remote repository, using --bundle avoids downloading the |
|
1742 | 1742 | changesets twice if the incoming is followed by a pull. |
|
1743 | 1743 | |
|
1744 | 1744 | See pull for valid source format details. |
|
1745 | 1745 | """ |
|
1746 | 1746 | limit = cmdutil.loglimit(opts) |
|
1747 | 1747 | source, revs, checkout = hg.parseurl(ui.expandpath(source), opts.get('rev')) |
|
1748 | 1748 | cmdutil.setremoteconfig(ui, opts) |
|
1749 | 1749 | |
|
1750 | 1750 | other = hg.repository(ui, source) |
|
1751 | 1751 | ui.status(_('comparing with %s\n') % url.hidepassword(source)) |
|
1752 | 1752 | if revs: |
|
1753 | 1753 | revs = [other.lookup(rev) for rev in revs] |
|
1754 | 1754 | common, incoming, rheads = repo.findcommonincoming(other, heads=revs, |
|
1755 | 1755 | force=opts["force"]) |
|
1756 | 1756 | if not incoming: |
|
1757 | 1757 | try: |
|
1758 | 1758 | os.unlink(opts["bundle"]) |
|
1759 | 1759 | except: |
|
1760 | 1760 | pass |
|
1761 | 1761 | ui.status(_("no changes found\n")) |
|
1762 | 1762 | return 1 |
|
1763 | 1763 | |
|
1764 | 1764 | cleanup = None |
|
1765 | 1765 | try: |
|
1766 | 1766 | fname = opts["bundle"] |
|
1767 | 1767 | if fname or not other.local(): |
|
1768 | 1768 | # create a bundle (uncompressed if other repo is not local) |
|
1769 | 1769 | |
|
1770 | 1770 | if revs is None and other.capable('changegroupsubset'): |
|
1771 | 1771 | revs = rheads |
|
1772 | 1772 | |
|
1773 | 1773 | if revs is None: |
|
1774 | 1774 | cg = other.changegroup(incoming, "incoming") |
|
1775 | 1775 | else: |
|
1776 | 1776 | cg = other.changegroupsubset(incoming, revs, 'incoming') |
|
1777 | 1777 | bundletype = other.local() and "HG10BZ" or "HG10UN" |
|
1778 | 1778 | fname = cleanup = changegroup.writebundle(cg, fname, bundletype) |
|
1779 | 1779 | # keep written bundle? |
|
1780 | 1780 | if opts["bundle"]: |
|
1781 | 1781 | cleanup = None |
|
1782 | 1782 | if not other.local(): |
|
1783 | 1783 | # use the created uncompressed bundlerepo |
|
1784 | 1784 | other = bundlerepo.bundlerepository(ui, repo.root, fname) |
|
1785 | 1785 | |
|
1786 | 1786 | o = other.changelog.nodesbetween(incoming, revs)[0] |
|
1787 | 1787 | if opts.get('newest_first'): |
|
1788 | 1788 | o.reverse() |
|
1789 | 1789 | displayer = cmdutil.show_changeset(ui, other, opts) |
|
1790 | 1790 | count = 0 |
|
1791 | 1791 | for n in o: |
|
1792 | 1792 | if count >= limit: |
|
1793 | 1793 | break |
|
1794 | 1794 | parents = [p for p in other.changelog.parents(n) if p != nullid] |
|
1795 | 1795 | if opts.get('no_merges') and len(parents) == 2: |
|
1796 | 1796 | continue |
|
1797 | 1797 | count += 1 |
|
1798 | 1798 | displayer.show(other[n]) |
|
1799 | 1799 | finally: |
|
1800 | 1800 | if hasattr(other, 'close'): |
|
1801 | 1801 | other.close() |
|
1802 | 1802 | if cleanup: |
|
1803 | 1803 | os.unlink(cleanup) |
|
1804 | 1804 | |
|
1805 | 1805 | def init(ui, dest=".", **opts): |
|
1806 | 1806 | """create a new repository in the given directory |
|
1807 | 1807 | |
|
1808 | 1808 | Initialize a new repository in the given directory. If the given |
|
1809 | 1809 | directory does not exist, it is created. |
|
1810 | 1810 | |
|
1811 | 1811 | If no directory is given, the current directory is used. |
|
1812 | 1812 | |
|
1813 | 1813 | It is possible to specify an ssh:// URL as the destination. |
|
1814 | 1814 | See 'hg help urls' for more information. |
|
1815 | 1815 | """ |
|
1816 | 1816 | cmdutil.setremoteconfig(ui, opts) |
|
1817 | 1817 | hg.repository(ui, dest, create=1) |
|
1818 | 1818 | |
|
1819 | 1819 | def locate(ui, repo, *pats, **opts): |
|
1820 | 1820 | """locate files matching specific patterns |
|
1821 | 1821 | |
|
1822 | 1822 | Print all files under Mercurial control whose names match the |
|
1823 | 1823 | given patterns. |
|
1824 | 1824 | |
|
1825 | 1825 | This command searches the entire repository by default. To search |
|
1826 | 1826 | just the current directory and its subdirectories, use |
|
1827 | 1827 | "--include .". |
|
1828 | 1828 | |
|
1829 | 1829 | If no patterns are given to match, this command prints all file |
|
1830 | 1830 | names. |
|
1831 | 1831 | |
|
1832 | 1832 | If you want to feed the output of this command into the "xargs" |
|
1833 | 1833 | command, use the "-0" option to both this command and "xargs". |
|
1834 | 1834 | This will avoid the problem of "xargs" treating single filenames |
|
1835 | 1835 | that contain white space as multiple filenames. |
|
1836 | 1836 | """ |
|
1837 | 1837 | end = opts.get('print0') and '\0' or '\n' |
|
1838 | 1838 | rev = opts.get('rev') or None |
|
1839 | 1839 | |
|
1840 | 1840 | ret = 1 |
|
1841 | 1841 | m = cmdutil.match(repo, pats, opts, default='relglob') |
|
1842 | 1842 | m.bad = lambda x,y: False |
|
1843 | 1843 | for abs in repo[rev].walk(m): |
|
1844 | 1844 | if not rev and abs not in repo.dirstate: |
|
1845 | 1845 | continue |
|
1846 | 1846 | if opts.get('fullpath'): |
|
1847 | 1847 | ui.write(repo.wjoin(abs), end) |
|
1848 | 1848 | else: |
|
1849 | 1849 | ui.write(((pats and m.rel(abs)) or abs), end) |
|
1850 | 1850 | ret = 0 |
|
1851 | 1851 | |
|
1852 | 1852 | return ret |
|
1853 | 1853 | |
|
1854 | 1854 | def log(ui, repo, *pats, **opts): |
|
1855 | 1855 | """show revision history of entire repository or files |
|
1856 | 1856 | |
|
1857 | 1857 | Print the revision history of the specified files or the entire |
|
1858 | 1858 | project. |
|
1859 | 1859 | |
|
1860 | 1860 | File history is shown without following rename or copy history of |
|
1861 | 1861 | files. Use -f/--follow with a file name to follow history across |
|
1862 | 1862 | renames and copies. --follow without a file name will only show |
|
1863 | 1863 | ancestors or descendants of the starting revision. --follow-first |
|
1864 | 1864 | only follows the first parent of merge revisions. |
|
1865 | 1865 | |
|
1866 | 1866 | If no revision range is specified, the default is tip:0 unless |
|
1867 | 1867 | --follow is set, in which case the working directory parent is |
|
1868 | 1868 | used as the starting revision. |
|
1869 | 1869 | |
|
1870 | 1870 | See 'hg help dates' for a list of formats valid for -d/--date. |
|
1871 | 1871 | |
|
1872 | 1872 | By default this command outputs: changeset id and hash, tags, |
|
1873 | 1873 | non-trivial parents, user, date and time, and a summary for each |
|
1874 | 1874 | commit. When the -v/--verbose switch is used, the list of changed |
|
1875 | 1875 | files and full commit message is shown. |
|
1876 | 1876 | |
|
1877 | 1877 | NOTE: log -p may generate unexpected diff output for merge |
|
1878 | 1878 | changesets, as it will only compare the merge changeset against |
|
1879 | 1879 | its first parent. Also, the files: list will only reflect files |
|
1880 | 1880 | that are different from BOTH parents. |
|
1881 | 1881 | |
|
1882 | 1882 | """ |
|
1883 | 1883 | |
|
1884 | 1884 | get = util.cachefunc(lambda r: repo[r].changeset()) |
|
1885 | 1885 | changeiter, matchfn = cmdutil.walkchangerevs(ui, repo, pats, get, opts) |
|
1886 | 1886 | |
|
1887 | 1887 | limit = cmdutil.loglimit(opts) |
|
1888 | 1888 | count = 0 |
|
1889 | 1889 | |
|
1890 | 1890 | if opts.get('copies') and opts.get('rev'): |
|
1891 | 1891 | endrev = max(cmdutil.revrange(repo, opts.get('rev'))) + 1 |
|
1892 | 1892 | else: |
|
1893 | 1893 | endrev = len(repo) |
|
1894 | 1894 | rcache = {} |
|
1895 | 1895 | ncache = {} |
|
1896 | 1896 | def getrenamed(fn, rev): |
|
1897 | 1897 | '''looks up all renames for a file (up to endrev) the first |
|
1898 | 1898 | time the file is given. It indexes on the changerev and only |
|
1899 | 1899 | parses the manifest if linkrev != changerev. |
|
1900 | 1900 | Returns rename info for fn at changerev rev.''' |
|
1901 | 1901 | if fn not in rcache: |
|
1902 | 1902 | rcache[fn] = {} |
|
1903 | 1903 | ncache[fn] = {} |
|
1904 | 1904 | fl = repo.file(fn) |
|
1905 | 1905 | for i in fl: |
|
1906 | 1906 | node = fl.node(i) |
|
1907 | 1907 | lr = fl.linkrev(i) |
|
1908 | 1908 | renamed = fl.renamed(node) |
|
1909 | 1909 | rcache[fn][lr] = renamed |
|
1910 | 1910 | if renamed: |
|
1911 | 1911 | ncache[fn][node] = renamed |
|
1912 | 1912 | if lr >= endrev: |
|
1913 | 1913 | break |
|
1914 | 1914 | if rev in rcache[fn]: |
|
1915 | 1915 | return rcache[fn][rev] |
|
1916 | 1916 | |
|
1917 | 1917 | # If linkrev != rev (i.e. rev not found in rcache) fallback to |
|
1918 | 1918 | # filectx logic. |
|
1919 | 1919 | |
|
1920 | 1920 | try: |
|
1921 | 1921 | return repo[rev][fn].renamed() |
|
1922 | 1922 | except error.LookupError: |
|
1923 | 1923 | pass |
|
1924 | 1924 | return None |
|
1925 | 1925 | |
|
1926 | 1926 | df = False |
|
1927 | 1927 | if opts["date"]: |
|
1928 | 1928 | df = util.matchdate(opts["date"]) |
|
1929 | 1929 | |
|
1930 | 1930 | only_branches = opts.get('only_branch') |
|
1931 | 1931 | |
|
1932 | 1932 | displayer = cmdutil.show_changeset(ui, repo, opts, True, matchfn) |
|
1933 | 1933 | for st, rev, fns in changeiter: |
|
1934 | 1934 | if st == 'add': |
|
1935 | 1935 | parents = [p for p in repo.changelog.parentrevs(rev) |
|
1936 | 1936 | if p != nullrev] |
|
1937 | 1937 | if opts.get('no_merges') and len(parents) == 2: |
|
1938 | 1938 | continue |
|
1939 | 1939 | if opts.get('only_merges') and len(parents) != 2: |
|
1940 | 1940 | continue |
|
1941 | 1941 | |
|
1942 | 1942 | if only_branches: |
|
1943 | 1943 | revbranch = get(rev)[5]['branch'] |
|
1944 | 1944 | if revbranch not in only_branches: |
|
1945 | 1945 | continue |
|
1946 | 1946 | |
|
1947 | 1947 | if df: |
|
1948 | 1948 | changes = get(rev) |
|
1949 | 1949 | if not df(changes[2][0]): |
|
1950 | 1950 | continue |
|
1951 | 1951 | |
|
1952 | 1952 | if opts.get('keyword'): |
|
1953 | 1953 | changes = get(rev) |
|
1954 | 1954 | miss = 0 |
|
1955 | 1955 | for k in [kw.lower() for kw in opts['keyword']]: |
|
1956 | 1956 | if not (k in changes[1].lower() or |
|
1957 | 1957 | k in changes[4].lower() or |
|
1958 | 1958 | k in " ".join(changes[3]).lower()): |
|
1959 | 1959 | miss = 1 |
|
1960 | 1960 | break |
|
1961 | 1961 | if miss: |
|
1962 | 1962 | continue |
|
1963 | 1963 | |
|
1964 | 1964 | if opts['user']: |
|
1965 | 1965 | changes = get(rev) |
|
1966 | 1966 | if not [k for k in opts['user'] if k in changes[1]]: |
|
1967 | 1967 | continue |
|
1968 | 1968 | |
|
1969 | 1969 | copies = [] |
|
1970 | 1970 | if opts.get('copies') and rev: |
|
1971 | 1971 | for fn in get(rev)[3]: |
|
1972 | 1972 | rename = getrenamed(fn, rev) |
|
1973 | 1973 | if rename: |
|
1974 | 1974 | copies.append((fn, rename[0])) |
|
1975 | 1975 | displayer.show(context.changectx(repo, rev), copies=copies) |
|
1976 | 1976 | elif st == 'iter': |
|
1977 | 1977 | if count == limit: break |
|
1978 | 1978 | if displayer.flush(rev): |
|
1979 | 1979 | count += 1 |
|
1980 | 1980 | |
|
1981 | 1981 | def manifest(ui, repo, node=None, rev=None): |
|
1982 | 1982 | """output the current or given revision of the project manifest |
|
1983 | 1983 | |
|
1984 | 1984 | Print a list of version controlled files for the given revision. |
|
1985 | 1985 | If no revision is given, the first parent of the working directory |
|
1986 | 1986 | is used, or tip if no revision is checked out. |
|
1987 | 1987 | |
|
1988 | 1988 | With -v flag, print file permissions, symlink and executable bits. |
|
1989 | 1989 | With --debug flag, print file revision hashes. |
|
1990 | 1990 | """ |
|
1991 | 1991 | |
|
1992 | 1992 | if rev and node: |
|
1993 | 1993 | raise util.Abort(_("please specify just one revision")) |
|
1994 | 1994 | |
|
1995 | 1995 | if not node: |
|
1996 | 1996 | node = rev |
|
1997 | 1997 | |
|
1998 | 1998 | decor = {'l':'644 @ ', 'x':'755 * ', '':'644 '} |
|
1999 | 1999 | ctx = repo[node] |
|
2000 | 2000 | for f in ctx: |
|
2001 | 2001 | if ui.debugflag: |
|
2002 | 2002 | ui.write("%40s " % hex(ctx.manifest()[f])) |
|
2003 | 2003 | if ui.verbose: |
|
2004 | 2004 | ui.write(decor[ctx.flags(f)]) |
|
2005 | 2005 | ui.write("%s\n" % f) |
|
2006 | 2006 | |
|
2007 | 2007 | def merge(ui, repo, node=None, force=None, rev=None): |
|
2008 | 2008 | """merge working directory with another revision |
|
2009 | 2009 | |
|
2010 | 2010 | The contents of the current working directory is updated with all |
|
2011 | 2011 | changes made in the requested revision since the last common |
|
2012 | 2012 | predecessor revision. |
|
2013 | 2013 | |
|
2014 | 2014 | Files that changed between either parent are marked as changed for |
|
2015 | 2015 | the next commit and a commit must be performed before any further |
|
2016 | 2016 | updates are allowed. The next commit has two parents. |
|
2017 | 2017 | |
|
2018 | 2018 | If no revision is specified, the working directory's parent is a |
|
2019 | 2019 | head revision, and the current branch contains exactly one other |
|
2020 | 2020 | head, the other head is merged with by default. Otherwise, an |
|
2021 | 2021 | explicit revision to merge with must be provided. |
|
2022 | 2022 | """ |
|
2023 | 2023 | |
|
2024 | 2024 | if rev and node: |
|
2025 | 2025 | raise util.Abort(_("please specify just one revision")) |
|
2026 | 2026 | if not node: |
|
2027 | 2027 | node = rev |
|
2028 | 2028 | |
|
2029 | 2029 | if not node: |
|
2030 | 2030 | branch = repo.changectx(None).branch() |
|
2031 | 2031 | bheads = repo.branchheads(branch) |
|
2032 | 2032 | if len(bheads) > 2: |
|
2033 | 2033 | raise util.Abort(_("branch '%s' has %d heads - " |
|
2034 | 2034 | "please merge with an explicit rev") % |
|
2035 | 2035 | (branch, len(bheads))) |
|
2036 | 2036 | |
|
2037 | 2037 | parent = repo.dirstate.parents()[0] |
|
2038 | 2038 | if len(bheads) == 1: |
|
2039 | 2039 | if len(repo.heads()) > 1: |
|
2040 | 2040 | raise util.Abort(_("branch '%s' has one head - " |
|
2041 | 2041 | "please merge with an explicit rev") % |
|
2042 | 2042 | branch) |
|
2043 | 2043 | msg = _('there is nothing to merge') |
|
2044 | 2044 | if parent != repo.lookup(repo[None].branch()): |
|
2045 | 2045 | msg = _('%s - use "hg update" instead') % msg |
|
2046 | 2046 | raise util.Abort(msg) |
|
2047 | 2047 | |
|
2048 | 2048 | if parent not in bheads: |
|
2049 | 2049 | raise util.Abort(_('working dir not at a head rev - ' |
|
2050 | 2050 | 'use "hg update" or merge with an explicit rev')) |
|
2051 | 2051 | node = parent == bheads[0] and bheads[-1] or bheads[0] |
|
2052 | 2052 | return hg.merge(repo, node, force=force) |
|
2053 | 2053 | |
|
2054 | 2054 | def outgoing(ui, repo, dest=None, **opts): |
|
2055 | 2055 | """show changesets not found in destination |
|
2056 | 2056 | |
|
2057 | 2057 | Show changesets not found in the specified destination repository |
|
2058 | 2058 | or the default push location. These are the changesets that would |
|
2059 | 2059 | be pushed if a push was requested. |
|
2060 | 2060 | |
|
2061 | 2061 | See pull for valid destination format details. |
|
2062 | 2062 | """ |
|
2063 | 2063 | limit = cmdutil.loglimit(opts) |
|
2064 | 2064 | dest, revs, checkout = hg.parseurl( |
|
2065 | 2065 | ui.expandpath(dest or 'default-push', dest or 'default'), opts.get('rev')) |
|
2066 | 2066 | cmdutil.setremoteconfig(ui, opts) |
|
2067 | 2067 | if revs: |
|
2068 | 2068 | revs = [repo.lookup(rev) for rev in revs] |
|
2069 | 2069 | |
|
2070 | 2070 | other = hg.repository(ui, dest) |
|
2071 | 2071 | ui.status(_('comparing with %s\n') % url.hidepassword(dest)) |
|
2072 | 2072 | o = repo.findoutgoing(other, force=opts.get('force')) |
|
2073 | 2073 | if not o: |
|
2074 | 2074 | ui.status(_("no changes found\n")) |
|
2075 | 2075 | return 1 |
|
2076 | 2076 | o = repo.changelog.nodesbetween(o, revs)[0] |
|
2077 | 2077 | if opts.get('newest_first'): |
|
2078 | 2078 | o.reverse() |
|
2079 | 2079 | displayer = cmdutil.show_changeset(ui, repo, opts) |
|
2080 | 2080 | count = 0 |
|
2081 | 2081 | for n in o: |
|
2082 | 2082 | if count >= limit: |
|
2083 | 2083 | break |
|
2084 | 2084 | parents = [p for p in repo.changelog.parents(n) if p != nullid] |
|
2085 | 2085 | if opts.get('no_merges') and len(parents) == 2: |
|
2086 | 2086 | continue |
|
2087 | 2087 | count += 1 |
|
2088 | 2088 | displayer.show(repo[n]) |
|
2089 | 2089 | |
|
2090 | 2090 | def parents(ui, repo, file_=None, **opts): |
|
2091 | """show the parents of the working dir or revision | |
|
2091 | """show the parents of the working directory or revision | |
|
2092 | 2092 | |
|
2093 | 2093 | Print the working directory's parent revisions. If a revision is |
|
2094 | 2094 | given via --rev, the parent of that revision will be printed. If a |
|
2095 | 2095 | file argument is given, revision in which the file was last |
|
2096 | 2096 | changed (before the working directory revision or the argument to |
|
2097 | 2097 | --rev if given) is printed. |
|
2098 | 2098 | """ |
|
2099 | 2099 | rev = opts.get('rev') |
|
2100 | 2100 | if rev: |
|
2101 | 2101 | ctx = repo[rev] |
|
2102 | 2102 | else: |
|
2103 | 2103 | ctx = repo[None] |
|
2104 | 2104 | |
|
2105 | 2105 | if file_: |
|
2106 | 2106 | m = cmdutil.match(repo, (file_,), opts) |
|
2107 | 2107 | if m.anypats() or len(m.files()) != 1: |
|
2108 | 2108 | raise util.Abort(_('can only specify an explicit file name')) |
|
2109 | 2109 | file_ = m.files()[0] |
|
2110 | 2110 | filenodes = [] |
|
2111 | 2111 | for cp in ctx.parents(): |
|
2112 | 2112 | if not cp: |
|
2113 | 2113 | continue |
|
2114 | 2114 | try: |
|
2115 | 2115 | filenodes.append(cp.filenode(file_)) |
|
2116 | 2116 | except error.LookupError: |
|
2117 | 2117 | pass |
|
2118 | 2118 | if not filenodes: |
|
2119 | 2119 | raise util.Abort(_("'%s' not found in manifest!") % file_) |
|
2120 | 2120 | fl = repo.file(file_) |
|
2121 | 2121 | p = [repo.lookup(fl.linkrev(fl.rev(fn))) for fn in filenodes] |
|
2122 | 2122 | else: |
|
2123 | 2123 | p = [cp.node() for cp in ctx.parents()] |
|
2124 | 2124 | |
|
2125 | 2125 | displayer = cmdutil.show_changeset(ui, repo, opts) |
|
2126 | 2126 | for n in p: |
|
2127 | 2127 | if n != nullid: |
|
2128 | 2128 | displayer.show(repo[n]) |
|
2129 | 2129 | |
|
2130 | 2130 | def paths(ui, repo, search=None): |
|
2131 | 2131 | """show aliases for remote repositories |
|
2132 | 2132 | |
|
2133 | 2133 | Show definition of symbolic path name NAME. If no name is given, |
|
2134 | 2134 | show definition of available names. |
|
2135 | 2135 | |
|
2136 | 2136 | Path names are defined in the [paths] section of /etc/mercurial/hgrc |
|
2137 | 2137 | and $HOME/.hgrc. If run inside a repository, .hg/hgrc is used, too. |
|
2138 | 2138 | |
|
2139 | 2139 | See 'hg help urls' for more information. |
|
2140 | 2140 | """ |
|
2141 | 2141 | if search: |
|
2142 | 2142 | for name, path in ui.configitems("paths"): |
|
2143 | 2143 | if name == search: |
|
2144 | 2144 | ui.write("%s\n" % url.hidepassword(path)) |
|
2145 | 2145 | return |
|
2146 | 2146 | ui.warn(_("not found!\n")) |
|
2147 | 2147 | return 1 |
|
2148 | 2148 | else: |
|
2149 | 2149 | for name, path in ui.configitems("paths"): |
|
2150 | 2150 | ui.write("%s = %s\n" % (name, url.hidepassword(path))) |
|
2151 | 2151 | |
|
2152 | 2152 | def postincoming(ui, repo, modheads, optupdate, checkout): |
|
2153 | 2153 | if modheads == 0: |
|
2154 | 2154 | return |
|
2155 | 2155 | if optupdate: |
|
2156 | 2156 | if (modheads <= 1 or len(repo.branchheads()) == 1) or checkout: |
|
2157 | 2157 | return hg.update(repo, checkout) |
|
2158 | 2158 | else: |
|
2159 | 2159 | ui.status(_("not updating, since new heads added\n")) |
|
2160 | 2160 | if modheads > 1: |
|
2161 | 2161 | ui.status(_("(run 'hg heads' to see heads, 'hg merge' to merge)\n")) |
|
2162 | 2162 | else: |
|
2163 | 2163 | ui.status(_("(run 'hg update' to get a working copy)\n")) |
|
2164 | 2164 | |
|
2165 | 2165 | def pull(ui, repo, source="default", **opts): |
|
2166 | 2166 | """pull changes from the specified source |
|
2167 | 2167 | |
|
2168 | 2168 | Pull changes from a remote repository to the local one. |
|
2169 | 2169 | |
|
2170 | 2170 | This finds all changes from the repository at the specified path |
|
2171 | 2171 | or URL and adds them to the local repository. By default, this |
|
2172 | 2172 | does not update the copy of the project in the working directory. |
|
2173 | 2173 | |
|
2174 | 2174 | Use hg incoming if you want to see what will be added by the next |
|
2175 | 2175 | pull without actually adding the changes to the repository. |
|
2176 | 2176 | |
|
2177 | 2177 | If SOURCE is omitted, the 'default' path will be used. |
|
2178 | 2178 | See 'hg help urls' for more information. |
|
2179 | 2179 | """ |
|
2180 | 2180 | source, revs, checkout = hg.parseurl(ui.expandpath(source), opts.get('rev')) |
|
2181 | 2181 | cmdutil.setremoteconfig(ui, opts) |
|
2182 | 2182 | |
|
2183 | 2183 | other = hg.repository(ui, source) |
|
2184 | 2184 | ui.status(_('pulling from %s\n') % url.hidepassword(source)) |
|
2185 | 2185 | if revs: |
|
2186 | 2186 | try: |
|
2187 | 2187 | revs = [other.lookup(rev) for rev in revs] |
|
2188 | 2188 | except error.CapabilityError: |
|
2189 | 2189 | err = _("Other repository doesn't support revision lookup, " |
|
2190 | 2190 | "so a rev cannot be specified.") |
|
2191 | 2191 | raise util.Abort(err) |
|
2192 | 2192 | |
|
2193 | 2193 | modheads = repo.pull(other, heads=revs, force=opts.get('force')) |
|
2194 | 2194 | return postincoming(ui, repo, modheads, opts.get('update'), checkout) |
|
2195 | 2195 | |
|
2196 | 2196 | def push(ui, repo, dest=None, **opts): |
|
2197 | 2197 | """push changes to the specified destination |
|
2198 | 2198 | |
|
2199 | 2199 | Push changes from the local repository to the given destination. |
|
2200 | 2200 | |
|
2201 | 2201 | This is the symmetrical operation for pull. It moves changes from |
|
2202 | 2202 | the current repository to a different one. If the destination is |
|
2203 | 2203 | local this is identical to a pull in that directory from the |
|
2204 | 2204 | current one. |
|
2205 | 2205 | |
|
2206 | 2206 | By default, push will refuse to run if it detects the result would |
|
2207 | 2207 | increase the number of remote heads. This generally indicates the |
|
2208 | 2208 | the client has forgotten to pull and merge before pushing. |
|
2209 | 2209 | |
|
2210 | 2210 | If -r is used, the named revision and all its ancestors will be |
|
2211 | 2211 | pushed to the remote repository. |
|
2212 | 2212 | |
|
2213 | 2213 | Look at the help text for URLs for important details about ssh:// |
|
2214 | 2214 | URLs. If DESTINATION is omitted, a default path will be used. |
|
2215 | 2215 | See 'hg help urls' for more information. |
|
2216 | 2216 | """ |
|
2217 | 2217 | dest, revs, checkout = hg.parseurl( |
|
2218 | 2218 | ui.expandpath(dest or 'default-push', dest or 'default'), opts.get('rev')) |
|
2219 | 2219 | cmdutil.setremoteconfig(ui, opts) |
|
2220 | 2220 | |
|
2221 | 2221 | other = hg.repository(ui, dest) |
|
2222 | 2222 | ui.status(_('pushing to %s\n') % url.hidepassword(dest)) |
|
2223 | 2223 | if revs: |
|
2224 | 2224 | revs = [repo.lookup(rev) for rev in revs] |
|
2225 | 2225 | r = repo.push(other, opts.get('force'), revs=revs) |
|
2226 | 2226 | return r == 0 |
|
2227 | 2227 | |
|
2228 | 2228 | def rawcommit(ui, repo, *pats, **opts): |
|
2229 | 2229 | """raw commit interface (DEPRECATED) |
|
2230 | 2230 | |
|
2231 | 2231 | (DEPRECATED) |
|
2232 | 2232 | Lowlevel commit, for use in helper scripts. |
|
2233 | 2233 | |
|
2234 | 2234 | This command is not intended to be used by normal users, as it is |
|
2235 | 2235 | primarily useful for importing from other SCMs. |
|
2236 | 2236 | |
|
2237 | 2237 | This command is now deprecated and will be removed in a future |
|
2238 | 2238 | release, please use debugsetparents and commit instead. |
|
2239 | 2239 | """ |
|
2240 | 2240 | |
|
2241 | 2241 | ui.warn(_("(the rawcommit command is deprecated)\n")) |
|
2242 | 2242 | |
|
2243 | 2243 | message = cmdutil.logmessage(opts) |
|
2244 | 2244 | |
|
2245 | 2245 | files = cmdutil.match(repo, pats, opts).files() |
|
2246 | 2246 | if opts.get('files'): |
|
2247 | 2247 | files += open(opts['files']).read().splitlines() |
|
2248 | 2248 | |
|
2249 | 2249 | parents = [repo.lookup(p) for p in opts['parent']] |
|
2250 | 2250 | |
|
2251 | 2251 | try: |
|
2252 | 2252 | repo.rawcommit(files, message, opts['user'], opts['date'], *parents) |
|
2253 | 2253 | except ValueError, inst: |
|
2254 | 2254 | raise util.Abort(str(inst)) |
|
2255 | 2255 | |
|
2256 | 2256 | def recover(ui, repo): |
|
2257 | 2257 | """roll back an interrupted transaction |
|
2258 | 2258 | |
|
2259 | 2259 | Recover from an interrupted commit or pull. |
|
2260 | 2260 | |
|
2261 | 2261 | This command tries to fix the repository status after an |
|
2262 | 2262 | interrupted operation. It should only be necessary when Mercurial |
|
2263 | 2263 | suggests it. |
|
2264 | 2264 | """ |
|
2265 | 2265 | if repo.recover(): |
|
2266 | 2266 | return hg.verify(repo) |
|
2267 | 2267 | return 1 |
|
2268 | 2268 | |
|
2269 | 2269 | def remove(ui, repo, *pats, **opts): |
|
2270 | 2270 | """remove the specified files on the next commit |
|
2271 | 2271 | |
|
2272 | 2272 | Schedule the indicated files for removal from the repository. |
|
2273 | 2273 | |
|
2274 | 2274 | This only removes files from the current branch, not from the |
|
2275 | 2275 | entire project history. -A can be used to remove only files that |
|
2276 | 2276 | have already been deleted, -f can be used to force deletion, and |
|
2277 | 2277 | -Af can be used to remove files from the next revision without |
|
2278 | 2278 | deleting them. |
|
2279 | 2279 | |
|
2280 | 2280 | The following table details the behavior of remove for different |
|
2281 | 2281 | file states (columns) and option combinations (rows). The file |
|
2282 | 2282 | states are Added, Clean, Modified and Missing (as reported by hg |
|
2283 | 2283 | status). The actions are Warn, Remove (from branch) and Delete |
|
2284 | 2284 | (from disk). |
|
2285 | 2285 | |
|
2286 | 2286 | A C M ! |
|
2287 | 2287 | none W RD W R |
|
2288 | 2288 | -f R RD RD R |
|
2289 | 2289 | -A W W W R |
|
2290 | 2290 | -Af R R R R |
|
2291 | 2291 | |
|
2292 | 2292 | This command schedules the files to be removed at the next commit. |
|
2293 | 2293 | To undo a remove before that, see hg revert. |
|
2294 | 2294 | """ |
|
2295 | 2295 | |
|
2296 | 2296 | after, force = opts.get('after'), opts.get('force') |
|
2297 | 2297 | if not pats and not after: |
|
2298 | 2298 | raise util.Abort(_('no files specified')) |
|
2299 | 2299 | |
|
2300 | 2300 | m = cmdutil.match(repo, pats, opts) |
|
2301 | 2301 | s = repo.status(match=m, clean=True) |
|
2302 | 2302 | modified, added, deleted, clean = s[0], s[1], s[3], s[6] |
|
2303 | 2303 | |
|
2304 | 2304 | def warn(files, reason): |
|
2305 | 2305 | for f in files: |
|
2306 | 2306 | ui.warn(_('not removing %s: file %s (use -f to force removal)\n') |
|
2307 | 2307 | % (m.rel(f), reason)) |
|
2308 | 2308 | |
|
2309 | 2309 | if force: |
|
2310 | 2310 | remove, forget = modified + deleted + clean, added |
|
2311 | 2311 | elif after: |
|
2312 | 2312 | remove, forget = deleted, [] |
|
2313 | 2313 | warn(modified + added + clean, _('still exists')) |
|
2314 | 2314 | else: |
|
2315 | 2315 | remove, forget = deleted + clean, [] |
|
2316 | 2316 | warn(modified, _('is modified')) |
|
2317 | 2317 | warn(added, _('has been marked for add')) |
|
2318 | 2318 | |
|
2319 | 2319 | for f in util.sort(remove + forget): |
|
2320 | 2320 | if ui.verbose or not m.exact(f): |
|
2321 | 2321 | ui.status(_('removing %s\n') % m.rel(f)) |
|
2322 | 2322 | |
|
2323 | 2323 | repo.forget(forget) |
|
2324 | 2324 | repo.remove(remove, unlink=not after) |
|
2325 | 2325 | |
|
2326 | 2326 | def rename(ui, repo, *pats, **opts): |
|
2327 | 2327 | """rename files; equivalent of copy + remove |
|
2328 | 2328 | |
|
2329 | 2329 | Mark dest as copies of sources; mark sources for deletion. If dest |
|
2330 | 2330 | is a directory, copies are put in that directory. If dest is a |
|
2331 | 2331 | file, there can only be one source. |
|
2332 | 2332 | |
|
2333 | 2333 | By default, this command copies the contents of files as they |
|
2334 | 2334 | exist in the working directory. If invoked with --after, the |
|
2335 | 2335 | operation is recorded, but no copying is performed. |
|
2336 | 2336 | |
|
2337 | 2337 | This command takes effect at the next commit. To undo a rename |
|
2338 | 2338 | before that, see hg revert. |
|
2339 | 2339 | """ |
|
2340 | 2340 | wlock = repo.wlock(False) |
|
2341 | 2341 | try: |
|
2342 | 2342 | return cmdutil.copy(ui, repo, pats, opts, rename=True) |
|
2343 | 2343 | finally: |
|
2344 | 2344 | del wlock |
|
2345 | 2345 | |
|
2346 | 2346 | def resolve(ui, repo, *pats, **opts): |
|
2347 | 2347 | """retry file merges from a merge or update |
|
2348 | 2348 | |
|
2349 | 2349 | This command will cleanly retry unresolved file merges using file |
|
2350 | 2350 | revisions preserved from the last update or merge. To attempt to |
|
2351 | 2351 | resolve all unresolved files, use the -a switch. |
|
2352 | 2352 | |
|
2353 | 2353 | If a conflict is resolved manually, please note that the changes |
|
2354 | 2354 | will be overwritten if the merge is retried with resolve. The -m |
|
2355 | 2355 | switch should be used to mark the file as resolved. |
|
2356 | 2356 | |
|
2357 | 2357 | This command will also allow listing resolved files and manually |
|
2358 | 2358 | marking and unmarking files as resolved. All files must be marked |
|
2359 | 2359 | as resolved before the new commits are permitted. |
|
2360 | 2360 | |
|
2361 | 2361 | The codes used to show the status of files are: |
|
2362 | 2362 | U = unresolved |
|
2363 | 2363 | R = resolved |
|
2364 | 2364 | """ |
|
2365 | 2365 | |
|
2366 | 2366 | all, mark, unmark, show = [opts.get(o) for o in 'all mark unmark list'.split()] |
|
2367 | 2367 | |
|
2368 | 2368 | if (show and (mark or unmark)) or (mark and unmark): |
|
2369 | 2369 | raise util.Abort(_("too many options specified")) |
|
2370 | 2370 | if pats and all: |
|
2371 | 2371 | raise util.Abort(_("can't specify --all and patterns")) |
|
2372 | 2372 | if not (all or pats or show or mark or unmark): |
|
2373 | 2373 | raise util.Abort(_('no files or directories specified; ' |
|
2374 | 2374 | 'use --all to remerge all files')) |
|
2375 | 2375 | |
|
2376 | 2376 | ms = merge_.mergestate(repo) |
|
2377 | 2377 | m = cmdutil.match(repo, pats, opts) |
|
2378 | 2378 | |
|
2379 | 2379 | for f in ms: |
|
2380 | 2380 | if m(f): |
|
2381 | 2381 | if show: |
|
2382 | 2382 | ui.write("%s %s\n" % (ms[f].upper(), f)) |
|
2383 | 2383 | elif mark: |
|
2384 | 2384 | ms.mark(f, "r") |
|
2385 | 2385 | elif unmark: |
|
2386 | 2386 | ms.mark(f, "u") |
|
2387 | 2387 | else: |
|
2388 | 2388 | wctx = repo[None] |
|
2389 | 2389 | mctx = wctx.parents()[-1] |
|
2390 | 2390 | |
|
2391 | 2391 | # backup pre-resolve (merge uses .orig for its own purposes) |
|
2392 | 2392 | a = repo.wjoin(f) |
|
2393 | 2393 | util.copyfile(a, a + ".resolve") |
|
2394 | 2394 | |
|
2395 | 2395 | # resolve file |
|
2396 | 2396 | ms.resolve(f, wctx, mctx) |
|
2397 | 2397 | |
|
2398 | 2398 | # replace filemerge's .orig file with our resolve file |
|
2399 | 2399 | util.rename(a + ".resolve", a + ".orig") |
|
2400 | 2400 | |
|
2401 | 2401 | def revert(ui, repo, *pats, **opts): |
|
2402 | """restore individual files or dirs to an earlier state | |
|
2402 | """restore individual files or directories to an earlier state | |
|
2403 | 2403 | |
|
2404 | 2404 | (use update -r to check out earlier revisions, revert does not |
|
2405 | change the working dir parents) | |
|
2405 | change the working directory parents) | |
|
2406 | 2406 | |
|
2407 | 2407 | With no revision specified, revert the named files or directories |
|
2408 | 2408 | to the contents they had in the parent of the working directory. |
|
2409 | 2409 | This restores the contents of the affected files to an unmodified |
|
2410 | 2410 | state and unschedules adds, removes, copies, and renames. If the |
|
2411 | 2411 | working directory has two parents, you must explicitly specify the |
|
2412 | 2412 | revision to revert to. |
|
2413 | 2413 | |
|
2414 | 2414 | Using the -r option, revert the given files or directories to |
|
2415 | 2415 | their contents as of a specific revision. This can be helpful to |
|
2416 | 2416 | "roll back" some or all of an earlier change. See 'hg help dates' |
|
2417 | 2417 | for a list of formats valid for -d/--date. |
|
2418 | 2418 | |
|
2419 | 2419 | Revert modifies the working directory. It does not commit any |
|
2420 | 2420 | changes, or change the parent of the working directory. If you |
|
2421 | 2421 | revert to a revision other than the parent of the working |
|
2422 | 2422 | directory, the reverted files will thus appear modified |
|
2423 | 2423 | afterwards. |
|
2424 | 2424 | |
|
2425 | 2425 | If a file has been deleted, it is restored. If the executable mode |
|
2426 | 2426 | of a file was changed, it is reset. |
|
2427 | 2427 | |
|
2428 | 2428 | If names are given, all files matching the names are reverted. |
|
2429 | 2429 | If no arguments are given, no files are reverted. |
|
2430 | 2430 | |
|
2431 | 2431 | Modified files are saved with a .orig suffix before reverting. |
|
2432 | 2432 | To disable these backups, use --no-backup. |
|
2433 | 2433 | """ |
|
2434 | 2434 | |
|
2435 | 2435 | if opts["date"]: |
|
2436 | 2436 | if opts["rev"]: |
|
2437 | 2437 | raise util.Abort(_("you can't specify a revision and a date")) |
|
2438 | 2438 | opts["rev"] = cmdutil.finddate(ui, repo, opts["date"]) |
|
2439 | 2439 | |
|
2440 | 2440 | if not pats and not opts.get('all'): |
|
2441 | 2441 | raise util.Abort(_('no files or directories specified; ' |
|
2442 | 2442 | 'use --all to revert the whole repo')) |
|
2443 | 2443 | |
|
2444 | 2444 | parent, p2 = repo.dirstate.parents() |
|
2445 | 2445 | if not opts.get('rev') and p2 != nullid: |
|
2446 | 2446 | raise util.Abort(_('uncommitted merge - please provide a ' |
|
2447 | 2447 | 'specific revision')) |
|
2448 | 2448 | ctx = repo[opts.get('rev')] |
|
2449 | 2449 | node = ctx.node() |
|
2450 | 2450 | mf = ctx.manifest() |
|
2451 | 2451 | if node == parent: |
|
2452 | 2452 | pmf = mf |
|
2453 | 2453 | else: |
|
2454 | 2454 | pmf = None |
|
2455 | 2455 | |
|
2456 | 2456 | # need all matching names in dirstate and manifest of target rev, |
|
2457 | 2457 | # so have to walk both. do not print errors if files exist in one |
|
2458 | 2458 | # but not other. |
|
2459 | 2459 | |
|
2460 | 2460 | names = {} |
|
2461 | 2461 | |
|
2462 | 2462 | wlock = repo.wlock() |
|
2463 | 2463 | try: |
|
2464 | 2464 | # walk dirstate. |
|
2465 | 2465 | |
|
2466 | 2466 | m = cmdutil.match(repo, pats, opts) |
|
2467 | 2467 | m.bad = lambda x,y: False |
|
2468 | 2468 | for abs in repo.walk(m): |
|
2469 | 2469 | names[abs] = m.rel(abs), m.exact(abs) |
|
2470 | 2470 | |
|
2471 | 2471 | # walk target manifest. |
|
2472 | 2472 | |
|
2473 | 2473 | def badfn(path, msg): |
|
2474 | 2474 | if path in names: |
|
2475 | 2475 | return False |
|
2476 | 2476 | path_ = path + '/' |
|
2477 | 2477 | for f in names: |
|
2478 | 2478 | if f.startswith(path_): |
|
2479 | 2479 | return False |
|
2480 | 2480 | repo.ui.warn("%s: %s\n" % (m.rel(path), msg)) |
|
2481 | 2481 | return False |
|
2482 | 2482 | |
|
2483 | 2483 | m = cmdutil.match(repo, pats, opts) |
|
2484 | 2484 | m.bad = badfn |
|
2485 | 2485 | for abs in repo[node].walk(m): |
|
2486 | 2486 | if abs not in names: |
|
2487 | 2487 | names[abs] = m.rel(abs), m.exact(abs) |
|
2488 | 2488 | |
|
2489 | 2489 | m = cmdutil.matchfiles(repo, names) |
|
2490 | 2490 | changes = repo.status(match=m)[:4] |
|
2491 | 2491 | modified, added, removed, deleted = map(dict.fromkeys, changes) |
|
2492 | 2492 | |
|
2493 | 2493 | # if f is a rename, also revert the source |
|
2494 | 2494 | cwd = repo.getcwd() |
|
2495 | 2495 | for f in added: |
|
2496 | 2496 | src = repo.dirstate.copied(f) |
|
2497 | 2497 | if src and src not in names and repo.dirstate[src] == 'r': |
|
2498 | 2498 | removed[src] = None |
|
2499 | 2499 | names[src] = (repo.pathto(src, cwd), True) |
|
2500 | 2500 | |
|
2501 | 2501 | def removeforget(abs): |
|
2502 | 2502 | if repo.dirstate[abs] == 'a': |
|
2503 | 2503 | return _('forgetting %s\n') |
|
2504 | 2504 | return _('removing %s\n') |
|
2505 | 2505 | |
|
2506 | 2506 | revert = ([], _('reverting %s\n')) |
|
2507 | 2507 | add = ([], _('adding %s\n')) |
|
2508 | 2508 | remove = ([], removeforget) |
|
2509 | 2509 | undelete = ([], _('undeleting %s\n')) |
|
2510 | 2510 | |
|
2511 | 2511 | disptable = ( |
|
2512 | 2512 | # dispatch table: |
|
2513 | 2513 | # file state |
|
2514 | 2514 | # action if in target manifest |
|
2515 | 2515 | # action if not in target manifest |
|
2516 | 2516 | # make backup if in target manifest |
|
2517 | 2517 | # make backup if not in target manifest |
|
2518 | 2518 | (modified, revert, remove, True, True), |
|
2519 | 2519 | (added, revert, remove, True, False), |
|
2520 | 2520 | (removed, undelete, None, False, False), |
|
2521 | 2521 | (deleted, revert, remove, False, False), |
|
2522 | 2522 | ) |
|
2523 | 2523 | |
|
2524 | 2524 | for abs, (rel, exact) in util.sort(names.items()): |
|
2525 | 2525 | mfentry = mf.get(abs) |
|
2526 | 2526 | target = repo.wjoin(abs) |
|
2527 | 2527 | def handle(xlist, dobackup): |
|
2528 | 2528 | xlist[0].append(abs) |
|
2529 | 2529 | if dobackup and not opts.get('no_backup') and util.lexists(target): |
|
2530 | 2530 | bakname = "%s.orig" % rel |
|
2531 | 2531 | ui.note(_('saving current version of %s as %s\n') % |
|
2532 | 2532 | (rel, bakname)) |
|
2533 | 2533 | if not opts.get('dry_run'): |
|
2534 | 2534 | util.copyfile(target, bakname) |
|
2535 | 2535 | if ui.verbose or not exact: |
|
2536 | 2536 | msg = xlist[1] |
|
2537 | 2537 | if not isinstance(msg, basestring): |
|
2538 | 2538 | msg = msg(abs) |
|
2539 | 2539 | ui.status(msg % rel) |
|
2540 | 2540 | for table, hitlist, misslist, backuphit, backupmiss in disptable: |
|
2541 | 2541 | if abs not in table: continue |
|
2542 | 2542 | # file has changed in dirstate |
|
2543 | 2543 | if mfentry: |
|
2544 | 2544 | handle(hitlist, backuphit) |
|
2545 | 2545 | elif misslist is not None: |
|
2546 | 2546 | handle(misslist, backupmiss) |
|
2547 | 2547 | break |
|
2548 | 2548 | else: |
|
2549 | 2549 | if abs not in repo.dirstate: |
|
2550 | 2550 | if mfentry: |
|
2551 | 2551 | handle(add, True) |
|
2552 | 2552 | elif exact: |
|
2553 | 2553 | ui.warn(_('file not managed: %s\n') % rel) |
|
2554 | 2554 | continue |
|
2555 | 2555 | # file has not changed in dirstate |
|
2556 | 2556 | if node == parent: |
|
2557 | 2557 | if exact: ui.warn(_('no changes needed to %s\n') % rel) |
|
2558 | 2558 | continue |
|
2559 | 2559 | if pmf is None: |
|
2560 | 2560 | # only need parent manifest in this unlikely case, |
|
2561 | 2561 | # so do not read by default |
|
2562 | 2562 | pmf = repo[parent].manifest() |
|
2563 | 2563 | if abs in pmf: |
|
2564 | 2564 | if mfentry: |
|
2565 | 2565 | # if version of file is same in parent and target |
|
2566 | 2566 | # manifests, do nothing |
|
2567 | 2567 | if (pmf[abs] != mfentry or |
|
2568 | 2568 | pmf.flags(abs) != mf.flags(abs)): |
|
2569 | 2569 | handle(revert, False) |
|
2570 | 2570 | else: |
|
2571 | 2571 | handle(remove, False) |
|
2572 | 2572 | |
|
2573 | 2573 | if not opts.get('dry_run'): |
|
2574 | 2574 | def checkout(f): |
|
2575 | 2575 | fc = ctx[f] |
|
2576 | 2576 | repo.wwrite(f, fc.data(), fc.flags()) |
|
2577 | 2577 | |
|
2578 | 2578 | audit_path = util.path_auditor(repo.root) |
|
2579 | 2579 | for f in remove[0]: |
|
2580 | 2580 | if repo.dirstate[f] == 'a': |
|
2581 | 2581 | repo.dirstate.forget(f) |
|
2582 | 2582 | continue |
|
2583 | 2583 | audit_path(f) |
|
2584 | 2584 | try: |
|
2585 | 2585 | util.unlink(repo.wjoin(f)) |
|
2586 | 2586 | except OSError: |
|
2587 | 2587 | pass |
|
2588 | 2588 | repo.dirstate.remove(f) |
|
2589 | 2589 | |
|
2590 | 2590 | normal = None |
|
2591 | 2591 | if node == parent: |
|
2592 | 2592 | # We're reverting to our parent. If possible, we'd like status |
|
2593 | 2593 | # to report the file as clean. We have to use normallookup for |
|
2594 | 2594 | # merges to avoid losing information about merged/dirty files. |
|
2595 | 2595 | if p2 != nullid: |
|
2596 | 2596 | normal = repo.dirstate.normallookup |
|
2597 | 2597 | else: |
|
2598 | 2598 | normal = repo.dirstate.normal |
|
2599 | 2599 | for f in revert[0]: |
|
2600 | 2600 | checkout(f) |
|
2601 | 2601 | if normal: |
|
2602 | 2602 | normal(f) |
|
2603 | 2603 | |
|
2604 | 2604 | for f in add[0]: |
|
2605 | 2605 | checkout(f) |
|
2606 | 2606 | repo.dirstate.add(f) |
|
2607 | 2607 | |
|
2608 | 2608 | normal = repo.dirstate.normallookup |
|
2609 | 2609 | if node == parent and p2 == nullid: |
|
2610 | 2610 | normal = repo.dirstate.normal |
|
2611 | 2611 | for f in undelete[0]: |
|
2612 | 2612 | checkout(f) |
|
2613 | 2613 | normal(f) |
|
2614 | 2614 | |
|
2615 | 2615 | finally: |
|
2616 | 2616 | del wlock |
|
2617 | 2617 | |
|
2618 | 2618 | def rollback(ui, repo): |
|
2619 | 2619 | """roll back the last transaction |
|
2620 | 2620 | |
|
2621 | 2621 | This command should be used with care. There is only one level of |
|
2622 | 2622 | rollback, and there is no way to undo a rollback. It will also |
|
2623 | 2623 | restore the dirstate at the time of the last transaction, losing |
|
2624 | 2624 | any dirstate changes since that time. |
|
2625 | 2625 | |
|
2626 | 2626 | Transactions are used to encapsulate the effects of all commands |
|
2627 | 2627 | that create new changesets or propagate existing changesets into a |
|
2628 | 2628 | repository. For example, the following commands are transactional, |
|
2629 | 2629 | and their effects can be rolled back: |
|
2630 | 2630 | |
|
2631 | 2631 | commit |
|
2632 | 2632 | import |
|
2633 | 2633 | pull |
|
2634 | 2634 | push (with this repository as destination) |
|
2635 | 2635 | unbundle |
|
2636 | 2636 | |
|
2637 | 2637 | This command is not intended for use on public repositories. Once |
|
2638 | 2638 | changes are visible for pull by other users, rolling a transaction |
|
2639 | 2639 | back locally is ineffective (someone else may already have pulled |
|
2640 | 2640 | the changes). Furthermore, a race is possible with readers of the |
|
2641 | 2641 | repository; for example an in-progress pull from the repository |
|
2642 | 2642 | may fail if a rollback is performed. |
|
2643 | 2643 | """ |
|
2644 | 2644 | repo.rollback() |
|
2645 | 2645 | |
|
2646 | 2646 | def root(ui, repo): |
|
2647 | """print the root (top) of the current working dir | |
|
2647 | """print the root (top) of the current working directory | |
|
2648 | 2648 | |
|
2649 | 2649 | Print the root directory of the current repository. |
|
2650 | 2650 | """ |
|
2651 | 2651 | ui.write(repo.root + "\n") |
|
2652 | 2652 | |
|
2653 | 2653 | def serve(ui, repo, **opts): |
|
2654 | 2654 | """export the repository via HTTP |
|
2655 | 2655 | |
|
2656 | 2656 | Start a local HTTP repository browser and pull server. |
|
2657 | 2657 | |
|
2658 | 2658 | By default, the server logs accesses to stdout and errors to |
|
2659 | 2659 | stderr. Use the "-A" and "-E" options to log to files. |
|
2660 | 2660 | """ |
|
2661 | 2661 | |
|
2662 | 2662 | if opts["stdio"]: |
|
2663 | 2663 | if repo is None: |
|
2664 | 2664 | raise error.RepoError(_("There is no Mercurial repository here" |
|
2665 | 2665 | " (.hg not found)")) |
|
2666 | 2666 | s = sshserver.sshserver(ui, repo) |
|
2667 | 2667 | s.serve_forever() |
|
2668 | 2668 | |
|
2669 | 2669 | parentui = ui.parentui or ui |
|
2670 | 2670 | optlist = ("name templates style address port prefix ipv6" |
|
2671 | 2671 | " accesslog errorlog webdir_conf certificate") |
|
2672 | 2672 | for o in optlist.split(): |
|
2673 | 2673 | if opts[o]: |
|
2674 | 2674 | parentui.setconfig("web", o, str(opts[o])) |
|
2675 | 2675 | if (repo is not None) and (repo.ui != parentui): |
|
2676 | 2676 | repo.ui.setconfig("web", o, str(opts[o])) |
|
2677 | 2677 | |
|
2678 | 2678 | if repo is None and not ui.config("web", "webdir_conf"): |
|
2679 | 2679 | raise error.RepoError(_("There is no Mercurial repository here" |
|
2680 | 2680 | " (.hg not found)")) |
|
2681 | 2681 | |
|
2682 | 2682 | class service: |
|
2683 | 2683 | def init(self): |
|
2684 | 2684 | util.set_signal_handler() |
|
2685 | 2685 | self.httpd = hgweb.server.create_server(parentui, repo) |
|
2686 | 2686 | |
|
2687 | 2687 | if not ui.verbose: return |
|
2688 | 2688 | |
|
2689 | 2689 | if self.httpd.prefix: |
|
2690 | 2690 | prefix = self.httpd.prefix.strip('/') + '/' |
|
2691 | 2691 | else: |
|
2692 | 2692 | prefix = '' |
|
2693 | 2693 | |
|
2694 | 2694 | port = ':%d' % self.httpd.port |
|
2695 | 2695 | if port == ':80': |
|
2696 | 2696 | port = '' |
|
2697 | 2697 | |
|
2698 | 2698 | bindaddr = self.httpd.addr |
|
2699 | 2699 | if bindaddr == '0.0.0.0': |
|
2700 | 2700 | bindaddr = '*' |
|
2701 | 2701 | elif ':' in bindaddr: # IPv6 |
|
2702 | 2702 | bindaddr = '[%s]' % bindaddr |
|
2703 | 2703 | |
|
2704 | 2704 | fqaddr = self.httpd.fqaddr |
|
2705 | 2705 | if ':' in fqaddr: |
|
2706 | 2706 | fqaddr = '[%s]' % fqaddr |
|
2707 | 2707 | ui.status(_('listening at http://%s%s/%s (bound to %s:%d)\n') % |
|
2708 | 2708 | (fqaddr, port, prefix, bindaddr, self.httpd.port)) |
|
2709 | 2709 | |
|
2710 | 2710 | def run(self): |
|
2711 | 2711 | self.httpd.serve_forever() |
|
2712 | 2712 | |
|
2713 | 2713 | service = service() |
|
2714 | 2714 | |
|
2715 | 2715 | cmdutil.service(opts, initfn=service.init, runfn=service.run) |
|
2716 | 2716 | |
|
2717 | 2717 | def status(ui, repo, *pats, **opts): |
|
2718 | 2718 | """show changed files in the working directory |
|
2719 | 2719 | |
|
2720 | 2720 | Show status of files in the repository. If names are given, only |
|
2721 | 2721 | files that match are shown. Files that are clean or ignored or |
|
2722 | 2722 | source of a copy/move operation, are not listed unless -c (clean), |
|
2723 | 2723 | -i (ignored), -C (copies) or -A is given. Unless options described |
|
2724 | 2724 | with "show only ..." are given, the options -mardu are used. |
|
2725 | 2725 | |
|
2726 | 2726 | Option -q/--quiet hides untracked (unknown and ignored) files |
|
2727 | 2727 | unless explicitly requested with -u/--unknown or -i/--ignored. |
|
2728 | 2728 | |
|
2729 | 2729 | NOTE: status may appear to disagree with diff if permissions have |
|
2730 | 2730 | changed or a merge has occurred. The standard diff format does not |
|
2731 | 2731 | report permission changes and diff only reports changes relative |
|
2732 | 2732 | to one merge parent. |
|
2733 | 2733 | |
|
2734 | 2734 | If one revision is given, it is used as the base revision. |
|
2735 | 2735 | If two revisions are given, the difference between them is shown. |
|
2736 | 2736 | |
|
2737 | 2737 | The codes used to show the status of files are: |
|
2738 | 2738 | M = modified |
|
2739 | 2739 | A = added |
|
2740 | 2740 | R = removed |
|
2741 | 2741 | C = clean |
|
2742 | 2742 | ! = missing, but still tracked |
|
2743 | 2743 | ? = not tracked |
|
2744 | 2744 | I = ignored |
|
2745 | 2745 | = the previous added file was copied from here |
|
2746 | 2746 | """ |
|
2747 | 2747 | |
|
2748 | 2748 | node1, node2 = cmdutil.revpair(repo, opts.get('rev')) |
|
2749 | 2749 | cwd = (pats and repo.getcwd()) or '' |
|
2750 | 2750 | end = opts.get('print0') and '\0' or '\n' |
|
2751 | 2751 | copy = {} |
|
2752 | 2752 | states = 'modified added removed deleted unknown ignored clean'.split() |
|
2753 | 2753 | show = [k for k in states if opts.get(k)] |
|
2754 | 2754 | if opts.get('all'): |
|
2755 | 2755 | show += ui.quiet and (states[:4] + ['clean']) or states |
|
2756 | 2756 | if not show: |
|
2757 | 2757 | show = ui.quiet and states[:4] or states[:5] |
|
2758 | 2758 | |
|
2759 | 2759 | stat = repo.status(node1, node2, cmdutil.match(repo, pats, opts), |
|
2760 | 2760 | 'ignored' in show, 'clean' in show, 'unknown' in show) |
|
2761 | 2761 | changestates = zip(states, 'MAR!?IC', stat) |
|
2762 | 2762 | |
|
2763 | 2763 | if (opts.get('all') or opts.get('copies')) and not opts.get('no_status'): |
|
2764 | 2764 | ctxn = repo[nullid] |
|
2765 | 2765 | ctx1 = repo[node1] |
|
2766 | 2766 | ctx2 = repo[node2] |
|
2767 | 2767 | added = stat[1] |
|
2768 | 2768 | if node2 is None: |
|
2769 | 2769 | added = stat[0] + stat[1] # merged? |
|
2770 | 2770 | |
|
2771 | 2771 | for k, v in copies.copies(repo, ctx1, ctx2, ctxn)[0].iteritems(): |
|
2772 | 2772 | if k in added: |
|
2773 | 2773 | copy[k] = v |
|
2774 | 2774 | elif v in added: |
|
2775 | 2775 | copy[v] = k |
|
2776 | 2776 | |
|
2777 | 2777 | for state, char, files in changestates: |
|
2778 | 2778 | if state in show: |
|
2779 | 2779 | format = "%s %%s%s" % (char, end) |
|
2780 | 2780 | if opts.get('no_status'): |
|
2781 | 2781 | format = "%%s%s" % end |
|
2782 | 2782 | |
|
2783 | 2783 | for f in files: |
|
2784 | 2784 | ui.write(format % repo.pathto(f, cwd)) |
|
2785 | 2785 | if f in copy: |
|
2786 | 2786 | ui.write(' %s%s' % (repo.pathto(copy[f], cwd), end)) |
|
2787 | 2787 | |
|
2788 | 2788 | def tag(ui, repo, name1, *names, **opts): |
|
2789 | 2789 | """add one or more tags for the current or given revision |
|
2790 | 2790 | |
|
2791 | 2791 | Name a particular revision using <name>. |
|
2792 | 2792 | |
|
2793 | 2793 | Tags are used to name particular revisions of the repository and are |
|
2794 | 2794 | very useful to compare different revisions, to go back to significant |
|
2795 | 2795 | earlier versions or to mark branch points as releases, etc. |
|
2796 | 2796 | |
|
2797 | 2797 | If no revision is given, the parent of the working directory is |
|
2798 | 2798 | used, or tip if no revision is checked out. |
|
2799 | 2799 | |
|
2800 | 2800 | To facilitate version control, distribution, and merging of tags, |
|
2801 | 2801 | they are stored as a file named ".hgtags" which is managed |
|
2802 | 2802 | similarly to other project files and can be hand-edited if |
|
2803 | 2803 | necessary. The file '.hg/localtags' is used for local tags (not |
|
2804 | 2804 | shared among repositories). |
|
2805 | 2805 | |
|
2806 | 2806 | See 'hg help dates' for a list of formats valid for -d/--date. |
|
2807 | 2807 | """ |
|
2808 | 2808 | |
|
2809 | 2809 | rev_ = "." |
|
2810 | 2810 | names = (name1,) + names |
|
2811 | 2811 | if len(names) != len(dict.fromkeys(names)): |
|
2812 | 2812 | raise util.Abort(_('tag names must be unique')) |
|
2813 | 2813 | for n in names: |
|
2814 | 2814 | if n in ['tip', '.', 'null']: |
|
2815 | 2815 | raise util.Abort(_('the name \'%s\' is reserved') % n) |
|
2816 | 2816 | if opts.get('rev') and opts.get('remove'): |
|
2817 | 2817 | raise util.Abort(_("--rev and --remove are incompatible")) |
|
2818 | 2818 | if opts.get('rev'): |
|
2819 | 2819 | rev_ = opts['rev'] |
|
2820 | 2820 | message = opts.get('message') |
|
2821 | 2821 | if opts.get('remove'): |
|
2822 | 2822 | expectedtype = opts.get('local') and 'local' or 'global' |
|
2823 | 2823 | for n in names: |
|
2824 | 2824 | if not repo.tagtype(n): |
|
2825 | 2825 | raise util.Abort(_('tag \'%s\' does not exist') % n) |
|
2826 | 2826 | if repo.tagtype(n) != expectedtype: |
|
2827 | 2827 | if expectedtype == 'global': |
|
2828 | 2828 | raise util.Abort(_('tag \'%s\' is not a global tag') % n) |
|
2829 | 2829 | else: |
|
2830 | 2830 | raise util.Abort(_('tag \'%s\' is not a local tag') % n) |
|
2831 | 2831 | rev_ = nullid |
|
2832 | 2832 | if not message: |
|
2833 | 2833 | message = _('Removed tag %s') % ', '.join(names) |
|
2834 | 2834 | elif not opts.get('force'): |
|
2835 | 2835 | for n in names: |
|
2836 | 2836 | if n in repo.tags(): |
|
2837 | 2837 | raise util.Abort(_('tag \'%s\' already exists ' |
|
2838 | 2838 | '(use -f to force)') % n) |
|
2839 | 2839 | if not rev_ and repo.dirstate.parents()[1] != nullid: |
|
2840 | 2840 | raise util.Abort(_('uncommitted merge - please provide a ' |
|
2841 | 2841 | 'specific revision')) |
|
2842 | 2842 | r = repo[rev_].node() |
|
2843 | 2843 | |
|
2844 | 2844 | if not message: |
|
2845 | 2845 | message = (_('Added tag %s for changeset %s') % |
|
2846 | 2846 | (', '.join(names), short(r))) |
|
2847 | 2847 | |
|
2848 | 2848 | date = opts.get('date') |
|
2849 | 2849 | if date: |
|
2850 | 2850 | date = util.parsedate(date) |
|
2851 | 2851 | |
|
2852 | 2852 | repo.tag(names, r, message, opts.get('local'), opts.get('user'), date) |
|
2853 | 2853 | |
|
2854 | 2854 | def tags(ui, repo): |
|
2855 | 2855 | """list repository tags |
|
2856 | 2856 | |
|
2857 | 2857 | This lists both regular and local tags. When the -v/--verbose |
|
2858 | 2858 | switch is used, a third column "local" is printed for local tags. |
|
2859 | 2859 | """ |
|
2860 | 2860 | |
|
2861 | 2861 | l = repo.tagslist() |
|
2862 | 2862 | l.reverse() |
|
2863 | 2863 | hexfunc = ui.debugflag and hex or short |
|
2864 | 2864 | tagtype = "" |
|
2865 | 2865 | |
|
2866 | 2866 | for t, n in l: |
|
2867 | 2867 | if ui.quiet: |
|
2868 | 2868 | ui.write("%s\n" % t) |
|
2869 | 2869 | continue |
|
2870 | 2870 | |
|
2871 | 2871 | try: |
|
2872 | 2872 | hn = hexfunc(n) |
|
2873 | 2873 | r = "%5d:%s" % (repo.changelog.rev(n), hn) |
|
2874 | 2874 | except error.LookupError: |
|
2875 | 2875 | r = " ?:%s" % hn |
|
2876 | 2876 | else: |
|
2877 | 2877 | spaces = " " * (30 - encoding.colwidth(t)) |
|
2878 | 2878 | if ui.verbose: |
|
2879 | 2879 | if repo.tagtype(t) == 'local': |
|
2880 | 2880 | tagtype = " local" |
|
2881 | 2881 | else: |
|
2882 | 2882 | tagtype = "" |
|
2883 | 2883 | ui.write("%s%s %s%s\n" % (t, spaces, r, tagtype)) |
|
2884 | 2884 | |
|
2885 | 2885 | def tip(ui, repo, **opts): |
|
2886 | 2886 | """show the tip revision |
|
2887 | 2887 | |
|
2888 | 2888 | The tip revision (usually just called the tip) is the most |
|
2889 | 2889 | recently added changeset in the repository, the most recently |
|
2890 | 2890 | changed head. |
|
2891 | 2891 | |
|
2892 | 2892 | If you have just made a commit, that commit will be the tip. If |
|
2893 | 2893 | you have just pulled changes from another repository, the tip of |
|
2894 | 2894 | that repository becomes the current tip. The "tip" tag is special |
|
2895 | 2895 | and cannot be renamed or assigned to a different changeset. |
|
2896 | 2896 | """ |
|
2897 | 2897 | cmdutil.show_changeset(ui, repo, opts).show(repo[len(repo) - 1]) |
|
2898 | 2898 | |
|
2899 | 2899 | def unbundle(ui, repo, fname1, *fnames, **opts): |
|
2900 | 2900 | """apply one or more changegroup files |
|
2901 | 2901 | |
|
2902 | 2902 | Apply one or more compressed changegroup files generated by the |
|
2903 | 2903 | bundle command. |
|
2904 | 2904 | """ |
|
2905 | 2905 | fnames = (fname1,) + fnames |
|
2906 | 2906 | |
|
2907 | 2907 | lock = None |
|
2908 | 2908 | try: |
|
2909 | 2909 | lock = repo.lock() |
|
2910 | 2910 | for fname in fnames: |
|
2911 | 2911 | f = url.open(ui, fname) |
|
2912 | 2912 | gen = changegroup.readbundle(f, fname) |
|
2913 | 2913 | modheads = repo.addchangegroup(gen, 'unbundle', 'bundle:' + fname) |
|
2914 | 2914 | finally: |
|
2915 | 2915 | del lock |
|
2916 | 2916 | |
|
2917 | 2917 | return postincoming(ui, repo, modheads, opts.get('update'), None) |
|
2918 | 2918 | |
|
2919 | 2919 | def update(ui, repo, node=None, rev=None, clean=False, date=None): |
|
2920 | 2920 | """update working directory |
|
2921 | 2921 | |
|
2922 | 2922 | Update the repository's working directory to the specified |
|
2923 | 2923 | revision, or the tip of the current branch if none is specified. |
|
2924 | 2924 | Use null as the revision to remove the working copy (like 'hg |
|
2925 | 2925 | clone -U'). |
|
2926 | 2926 | |
|
2927 | When the working dir contains no uncommitted changes, it will be | |
|
2927 | When the working directory contains no uncommitted changes, it will be | |
|
2928 | 2928 | replaced by the state of the requested revision from the repo. |
|
2929 | 2929 | When the requested revision is on a different branch, the working |
|
2930 | dir will additionally be switched to that branch. | |
|
2930 | directory will additionally be switched to that branch. | |
|
2931 | 2931 | |
|
2932 | 2932 | When there are uncommitted changes, use option -C to discard them, |
|
2933 | forcibly replacing the state of the working dir with the requested | |
|
2933 | forcibly replacing the state of the working directory with the requested | |
|
2934 | 2934 | revision. |
|
2935 | 2935 | |
|
2936 | 2936 | When there are uncommitted changes and option -C is not used, and |
|
2937 | 2937 | the parent revision and requested revision are on the same branch, |
|
2938 | 2938 | and one of them is an ancestor of the other, then the new working |
|
2939 | 2939 | directory will contain the requested revision merged with the |
|
2940 | 2940 | uncommitted changes. Otherwise, the update will fail with a |
|
2941 | 2941 | suggestion to use 'merge' or 'update -C' instead. |
|
2942 | 2942 | |
|
2943 | 2943 | If you want to update just one file to an older revision, use |
|
2944 | 2944 | revert. |
|
2945 | 2945 | |
|
2946 | 2946 | See 'hg help dates' for a list of formats valid for --date. |
|
2947 | 2947 | """ |
|
2948 | 2948 | if rev and node: |
|
2949 | 2949 | raise util.Abort(_("please specify just one revision")) |
|
2950 | 2950 | |
|
2951 | 2951 | if not rev: |
|
2952 | 2952 | rev = node |
|
2953 | 2953 | |
|
2954 | 2954 | if date: |
|
2955 | 2955 | if rev: |
|
2956 | 2956 | raise util.Abort(_("you can't specify a revision and a date")) |
|
2957 | 2957 | rev = cmdutil.finddate(ui, repo, date) |
|
2958 | 2958 | |
|
2959 | 2959 | if clean: |
|
2960 | 2960 | return hg.clean(repo, rev) |
|
2961 | 2961 | else: |
|
2962 | 2962 | return hg.update(repo, rev) |
|
2963 | 2963 | |
|
2964 | 2964 | def verify(ui, repo): |
|
2965 | 2965 | """verify the integrity of the repository |
|
2966 | 2966 | |
|
2967 | 2967 | Verify the integrity of the current repository. |
|
2968 | 2968 | |
|
2969 | 2969 | This will perform an extensive check of the repository's |
|
2970 | 2970 | integrity, validating the hashes and checksums of each entry in |
|
2971 | 2971 | the changelog, manifest, and tracked files, as well as the |
|
2972 | 2972 | integrity of their crosslinks and indices. |
|
2973 | 2973 | """ |
|
2974 | 2974 | return hg.verify(repo) |
|
2975 | 2975 | |
|
2976 | 2976 | def version_(ui): |
|
2977 | 2977 | """output version and copyright information""" |
|
2978 | 2978 | ui.write(_("Mercurial Distributed SCM (version %s)\n") |
|
2979 | 2979 | % util.version()) |
|
2980 | 2980 | ui.status(_( |
|
2981 | 2981 | "\nCopyright (C) 2005-2009 Matt Mackall <mpm@selenic.com> and others\n" |
|
2982 | 2982 | "This is free software; see the source for copying conditions. " |
|
2983 | 2983 | "There is NO\nwarranty; " |
|
2984 | 2984 | "not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n" |
|
2985 | 2985 | )) |
|
2986 | 2986 | |
|
2987 | 2987 | # Command options and aliases are listed here, alphabetically |
|
2988 | 2988 | |
|
2989 | 2989 | globalopts = [ |
|
2990 | 2990 | ('R', 'repository', '', |
|
2991 | 2991 | _('repository root directory or symbolic path name')), |
|
2992 | 2992 | ('', 'cwd', '', _('change working directory')), |
|
2993 | 2993 | ('y', 'noninteractive', None, |
|
2994 | 2994 | _('do not prompt, assume \'yes\' for any required answers')), |
|
2995 | 2995 | ('q', 'quiet', None, _('suppress output')), |
|
2996 | 2996 | ('v', 'verbose', None, _('enable additional output')), |
|
2997 | 2997 | ('', 'config', [], _('set/override config option')), |
|
2998 | 2998 | ('', 'debug', None, _('enable debugging output')), |
|
2999 | 2999 | ('', 'debugger', None, _('start debugger')), |
|
3000 | 3000 | ('', 'encoding', encoding.encoding, _('set the charset encoding')), |
|
3001 | 3001 | ('', 'encodingmode', encoding.encodingmode, |
|
3002 | 3002 | _('set the charset encoding mode')), |
|
3003 | 3003 | ('', 'traceback', None, _('print traceback on exception')), |
|
3004 | 3004 | ('', 'time', None, _('time how long the command takes')), |
|
3005 | 3005 | ('', 'profile', None, _('print command execution profile')), |
|
3006 | 3006 | ('', 'version', None, _('output version information and exit')), |
|
3007 | 3007 | ('h', 'help', None, _('display help and exit')), |
|
3008 | 3008 | ] |
|
3009 | 3009 | |
|
3010 | 3010 | dryrunopts = [('n', 'dry-run', None, |
|
3011 | 3011 | _('do not perform actions, just print output'))] |
|
3012 | 3012 | |
|
3013 | 3013 | remoteopts = [ |
|
3014 | 3014 | ('e', 'ssh', '', _('specify ssh command to use')), |
|
3015 | 3015 | ('', 'remotecmd', '', _('specify hg command to run on the remote side')), |
|
3016 | 3016 | ] |
|
3017 | 3017 | |
|
3018 | 3018 | walkopts = [ |
|
3019 | 3019 | ('I', 'include', [], _('include names matching the given patterns')), |
|
3020 | 3020 | ('X', 'exclude', [], _('exclude names matching the given patterns')), |
|
3021 | 3021 | ] |
|
3022 | 3022 | |
|
3023 | 3023 | commitopts = [ |
|
3024 | 3024 | ('m', 'message', '', _('use <text> as commit message')), |
|
3025 | 3025 | ('l', 'logfile', '', _('read commit message from <file>')), |
|
3026 | 3026 | ] |
|
3027 | 3027 | |
|
3028 | 3028 | commitopts2 = [ |
|
3029 | 3029 | ('d', 'date', '', _('record datecode as commit date')), |
|
3030 | 3030 | ('u', 'user', '', _('record user as committer')), |
|
3031 | 3031 | ] |
|
3032 | 3032 | |
|
3033 | 3033 | templateopts = [ |
|
3034 | 3034 | ('', 'style', '', _('display using template map file')), |
|
3035 | 3035 | ('', 'template', '', _('display with template')), |
|
3036 | 3036 | ] |
|
3037 | 3037 | |
|
3038 | 3038 | logopts = [ |
|
3039 | 3039 | ('p', 'patch', None, _('show patch')), |
|
3040 | 3040 | ('g', 'git', None, _('use git extended diff format')), |
|
3041 | 3041 | ('l', 'limit', '', _('limit number of changes displayed')), |
|
3042 | 3042 | ('M', 'no-merges', None, _('do not show merges')), |
|
3043 | 3043 | ] + templateopts |
|
3044 | 3044 | |
|
3045 | 3045 | diffopts = [ |
|
3046 | 3046 | ('a', 'text', None, _('treat all files as text')), |
|
3047 | 3047 | ('g', 'git', None, _('use git extended diff format')), |
|
3048 | 3048 | ('', 'nodates', None, _("don't include dates in diff headers")) |
|
3049 | 3049 | ] |
|
3050 | 3050 | |
|
3051 | 3051 | diffopts2 = [ |
|
3052 | 3052 | ('p', 'show-function', None, _('show which function each change is in')), |
|
3053 | 3053 | ('w', 'ignore-all-space', None, |
|
3054 | 3054 | _('ignore white space when comparing lines')), |
|
3055 | 3055 | ('b', 'ignore-space-change', None, |
|
3056 | 3056 | _('ignore changes in the amount of white space')), |
|
3057 | 3057 | ('B', 'ignore-blank-lines', None, |
|
3058 | 3058 | _('ignore changes whose lines are all blank')), |
|
3059 | 3059 | ('U', 'unified', '', _('number of lines of context to show')) |
|
3060 | 3060 | ] |
|
3061 | 3061 | |
|
3062 | 3062 | similarityopts = [ |
|
3063 | 3063 | ('s', 'similarity', '', |
|
3064 | 3064 | _('guess renamed files by similarity (0<=s<=100)')) |
|
3065 | 3065 | ] |
|
3066 | 3066 | |
|
3067 | 3067 | table = { |
|
3068 | 3068 | "^add": (add, walkopts + dryrunopts, _('[OPTION]... [FILE]...')), |
|
3069 | 3069 | "addremove": |
|
3070 | 3070 | (addremove, similarityopts + walkopts + dryrunopts, |
|
3071 | 3071 | _('[OPTION]... [FILE]...')), |
|
3072 | 3072 | "^annotate|blame": |
|
3073 | 3073 | (annotate, |
|
3074 | 3074 | [('r', 'rev', '', _('annotate the specified revision')), |
|
3075 | 3075 | ('f', 'follow', None, _('follow file copies and renames')), |
|
3076 | 3076 | ('a', 'text', None, _('treat all files as text')), |
|
3077 | 3077 | ('u', 'user', None, _('list the author (long with -v)')), |
|
3078 | 3078 | ('d', 'date', None, _('list the date (short with -q)')), |
|
3079 | 3079 | ('n', 'number', None, _('list the revision number (default)')), |
|
3080 | 3080 | ('c', 'changeset', None, _('list the changeset')), |
|
3081 | 3081 | ('l', 'line-number', None, |
|
3082 | 3082 | _('show line number at the first appearance')) |
|
3083 | 3083 | ] + walkopts, |
|
3084 | 3084 | _('[-r REV] [-f] [-a] [-u] [-d] [-n] [-c] [-l] FILE...')), |
|
3085 | 3085 | "archive": |
|
3086 | 3086 | (archive, |
|
3087 | 3087 | [('', 'no-decode', None, _('do not pass files through decoders')), |
|
3088 | 3088 | ('p', 'prefix', '', _('directory prefix for files in archive')), |
|
3089 | 3089 | ('r', 'rev', '', _('revision to distribute')), |
|
3090 | 3090 | ('t', 'type', '', _('type of distribution to create')), |
|
3091 | 3091 | ] + walkopts, |
|
3092 | 3092 | _('[OPTION]... DEST')), |
|
3093 | 3093 | "backout": |
|
3094 | 3094 | (backout, |
|
3095 | 3095 | [('', 'merge', None, |
|
3096 | 3096 | _('merge with old dirstate parent after backout')), |
|
3097 | 3097 | ('', 'parent', '', _('parent to choose when backing out merge')), |
|
3098 | 3098 | ('r', 'rev', '', _('revision to backout')), |
|
3099 | 3099 | ] + walkopts + commitopts + commitopts2, |
|
3100 | 3100 | _('[OPTION]... [-r] REV')), |
|
3101 | 3101 | "bisect": |
|
3102 | 3102 | (bisect, |
|
3103 | 3103 | [('r', 'reset', False, _('reset bisect state')), |
|
3104 | 3104 | ('g', 'good', False, _('mark changeset good')), |
|
3105 | 3105 | ('b', 'bad', False, _('mark changeset bad')), |
|
3106 | 3106 | ('s', 'skip', False, _('skip testing changeset')), |
|
3107 | 3107 | ('c', 'command', '', _('use command to check changeset state')), |
|
3108 | 3108 | ('U', 'noupdate', False, _('do not update to target'))], |
|
3109 | 3109 | _("[-gbsr] [-c CMD] [REV]")), |
|
3110 | 3110 | "branch": |
|
3111 | 3111 | (branch, |
|
3112 | 3112 | [('f', 'force', None, |
|
3113 | 3113 | _('set branch name even if it shadows an existing branch')), |
|
3114 | 3114 | ('C', 'clean', None, _('reset branch name to parent branch name'))], |
|
3115 | 3115 | _('[-fC] [NAME]')), |
|
3116 | 3116 | "branches": |
|
3117 | 3117 | (branches, |
|
3118 | 3118 | [('a', 'active', False, |
|
3119 | 3119 | _('show only branches that have unmerged heads'))], |
|
3120 | 3120 | _('[-a]')), |
|
3121 | 3121 | "bundle": |
|
3122 | 3122 | (bundle, |
|
3123 | 3123 | [('f', 'force', None, |
|
3124 | 3124 | _('run even when remote repository is unrelated')), |
|
3125 | 3125 | ('r', 'rev', [], |
|
3126 | 3126 | _('a changeset up to which you would like to bundle')), |
|
3127 | 3127 | ('', 'base', [], |
|
3128 | 3128 | _('a base changeset to specify instead of a destination')), |
|
3129 | 3129 | ('a', 'all', None, _('bundle all changesets in the repository')), |
|
3130 | 3130 | ('t', 'type', 'bzip2', _('bundle compression type to use')), |
|
3131 | 3131 | ] + remoteopts, |
|
3132 | 3132 | _('[-f] [-a] [-r REV]... [--base REV]... FILE [DEST]')), |
|
3133 | 3133 | "cat": |
|
3134 | 3134 | (cat, |
|
3135 | 3135 | [('o', 'output', '', _('print output to file with formatted name')), |
|
3136 | 3136 | ('r', 'rev', '', _('print the given revision')), |
|
3137 | 3137 | ('', 'decode', None, _('apply any matching decode filter')), |
|
3138 | 3138 | ] + walkopts, |
|
3139 | 3139 | _('[OPTION]... FILE...')), |
|
3140 | 3140 | "^clone": |
|
3141 | 3141 | (clone, |
|
3142 | 3142 | [('U', 'noupdate', None, |
|
3143 | 3143 | _('the clone will only contain a repository (no working copy)')), |
|
3144 | 3144 | ('r', 'rev', [], |
|
3145 | 3145 | _('a changeset you would like to have after cloning')), |
|
3146 | 3146 | ('', 'pull', None, _('use pull protocol to copy metadata')), |
|
3147 | 3147 | ('', 'uncompressed', None, |
|
3148 | 3148 | _('use uncompressed transfer (fast over LAN)')), |
|
3149 | 3149 | ] + remoteopts, |
|
3150 | 3150 | _('[OPTION]... SOURCE [DEST]')), |
|
3151 | 3151 | "^commit|ci": |
|
3152 | 3152 | (commit, |
|
3153 | 3153 | [('A', 'addremove', None, |
|
3154 | 3154 | _('mark new/missing files as added/removed before committing')), |
|
3155 | 3155 | ('', 'close-branch', None, |
|
3156 | 3156 | _('mark a branch as closed, hiding it from the branch list')), |
|
3157 | 3157 | ] + walkopts + commitopts + commitopts2, |
|
3158 | 3158 | _('[OPTION]... [FILE]...')), |
|
3159 | 3159 | "copy|cp": |
|
3160 | 3160 | (copy, |
|
3161 | 3161 | [('A', 'after', None, _('record a copy that has already occurred')), |
|
3162 | 3162 | ('f', 'force', None, |
|
3163 | 3163 | _('forcibly copy over an existing managed file')), |
|
3164 | 3164 | ] + walkopts + dryrunopts, |
|
3165 | 3165 | _('[OPTION]... [SOURCE]... DEST')), |
|
3166 | 3166 | "debugancestor": (debugancestor, [], _('[INDEX] REV1 REV2')), |
|
3167 | 3167 | "debugcheckstate": (debugcheckstate, []), |
|
3168 | 3168 | "debugcommands": (debugcommands, [], _('[COMMAND]')), |
|
3169 | 3169 | "debugcomplete": |
|
3170 | 3170 | (debugcomplete, |
|
3171 | 3171 | [('o', 'options', None, _('show the command options'))], |
|
3172 | 3172 | _('[-o] CMD')), |
|
3173 | 3173 | "debugdate": |
|
3174 | 3174 | (debugdate, |
|
3175 | 3175 | [('e', 'extended', None, _('try extended date formats'))], |
|
3176 | 3176 | _('[-e] DATE [RANGE]')), |
|
3177 | 3177 | "debugdata": (debugdata, [], _('FILE REV')), |
|
3178 | 3178 | "debugfsinfo": (debugfsinfo, [], _('[PATH]')), |
|
3179 | 3179 | "debugindex": (debugindex, [], _('FILE')), |
|
3180 | 3180 | "debugindexdot": (debugindexdot, [], _('FILE')), |
|
3181 | 3181 | "debuginstall": (debuginstall, []), |
|
3182 | 3182 | "debugrawcommit|rawcommit": |
|
3183 | 3183 | (rawcommit, |
|
3184 | 3184 | [('p', 'parent', [], _('parent')), |
|
3185 | 3185 | ('F', 'files', '', _('file list')) |
|
3186 | 3186 | ] + commitopts + commitopts2, |
|
3187 | 3187 | _('[OPTION]... [FILE]...')), |
|
3188 | 3188 | "debugrebuildstate": |
|
3189 | 3189 | (debugrebuildstate, |
|
3190 | 3190 | [('r', 'rev', '', _('revision to rebuild to'))], |
|
3191 | 3191 | _('[-r REV] [REV]')), |
|
3192 | 3192 | "debugrename": |
|
3193 | 3193 | (debugrename, |
|
3194 | 3194 | [('r', 'rev', '', _('revision to debug'))], |
|
3195 | 3195 | _('[-r REV] FILE')), |
|
3196 | 3196 | "debugsetparents": |
|
3197 | 3197 | (debugsetparents, [], _('REV1 [REV2]')), |
|
3198 | 3198 | "debugstate": |
|
3199 | 3199 | (debugstate, |
|
3200 | 3200 | [('', 'nodates', None, _('do not display the saved mtime'))], |
|
3201 | 3201 | _('[OPTION]...')), |
|
3202 | 3202 | "debugwalk": (debugwalk, walkopts, _('[OPTION]... [FILE]...')), |
|
3203 | 3203 | "^diff": |
|
3204 | 3204 | (diff, |
|
3205 | 3205 | [('r', 'rev', [], _('revision')), |
|
3206 | 3206 | ('c', 'change', '', _('change made by revision')) |
|
3207 | 3207 | ] + diffopts + diffopts2 + walkopts, |
|
3208 | 3208 | _('[OPTION]... [-r REV1 [-r REV2]] [FILE]...')), |
|
3209 | 3209 | "^export": |
|
3210 | 3210 | (export, |
|
3211 | 3211 | [('o', 'output', '', _('print output to file with formatted name')), |
|
3212 | 3212 | ('', 'switch-parent', None, _('diff against the second parent')) |
|
3213 | 3213 | ] + diffopts, |
|
3214 | 3214 | _('[OPTION]... [-o OUTFILESPEC] REV...')), |
|
3215 | 3215 | "grep": |
|
3216 | 3216 | (grep, |
|
3217 | 3217 | [('0', 'print0', None, _('end fields with NUL')), |
|
3218 | 3218 | ('', 'all', None, _('print all revisions that match')), |
|
3219 | 3219 | ('f', 'follow', None, |
|
3220 | 3220 | _('follow changeset history, or file history across copies and renames')), |
|
3221 | 3221 | ('i', 'ignore-case', None, _('ignore case when matching')), |
|
3222 | 3222 | ('l', 'files-with-matches', None, |
|
3223 | 3223 | _('print only filenames and revs that match')), |
|
3224 | 3224 | ('n', 'line-number', None, _('print matching line numbers')), |
|
3225 | 3225 | ('r', 'rev', [], _('search in given revision range')), |
|
3226 | 3226 | ('u', 'user', None, _('list the author (long with -v)')), |
|
3227 | 3227 | ('d', 'date', None, _('list the date (short with -q)')), |
|
3228 | 3228 | ] + walkopts, |
|
3229 | 3229 | _('[OPTION]... PATTERN [FILE]...')), |
|
3230 | 3230 | "heads": |
|
3231 | 3231 | (heads, |
|
3232 | 3232 | [('r', 'rev', '', _('show only heads which are descendants of rev')), |
|
3233 | 3233 | ('a', 'active', False, |
|
3234 | 3234 | _('show only the active heads from open branches')), |
|
3235 | 3235 | ] + templateopts, |
|
3236 | 3236 | _('[-r REV] [REV]...')), |
|
3237 | 3237 | "help": (help_, [], _('[TOPIC]')), |
|
3238 | 3238 | "identify|id": |
|
3239 | 3239 | (identify, |
|
3240 | 3240 | [('r', 'rev', '', _('identify the specified rev')), |
|
3241 | 3241 | ('n', 'num', None, _('show local revision number')), |
|
3242 | 3242 | ('i', 'id', None, _('show global revision id')), |
|
3243 | 3243 | ('b', 'branch', None, _('show branch')), |
|
3244 | 3244 | ('t', 'tags', None, _('show tags'))], |
|
3245 | 3245 | _('[-nibt] [-r REV] [SOURCE]')), |
|
3246 | 3246 | "import|patch": |
|
3247 | 3247 | (import_, |
|
3248 | 3248 | [('p', 'strip', 1, |
|
3249 | 3249 | _('directory strip option for patch. This has the same\n' |
|
3250 | 3250 | 'meaning as the corresponding patch option')), |
|
3251 | 3251 | ('b', 'base', '', _('base path')), |
|
3252 | 3252 | ('f', 'force', None, |
|
3253 | 3253 | _('skip check for outstanding uncommitted changes')), |
|
3254 | 3254 | ('', 'no-commit', None, _("don't commit, just update the working directory")), |
|
3255 | 3255 | ('', 'exact', None, |
|
3256 | 3256 | _('apply patch to the nodes from which it was generated')), |
|
3257 | 3257 | ('', 'import-branch', None, |
|
3258 | 3258 | _('Use any branch information in patch (implied by --exact)'))] + |
|
3259 | 3259 | commitopts + commitopts2 + similarityopts, |
|
3260 | 3260 | _('[OPTION]... PATCH...')), |
|
3261 | 3261 | "incoming|in": |
|
3262 | 3262 | (incoming, |
|
3263 | 3263 | [('f', 'force', None, |
|
3264 | 3264 | _('run even when remote repository is unrelated')), |
|
3265 | 3265 | ('n', 'newest-first', None, _('show newest record first')), |
|
3266 | 3266 | ('', 'bundle', '', _('file to store the bundles into')), |
|
3267 | 3267 | ('r', 'rev', [], |
|
3268 | 3268 | _('a specific revision up to which you would like to pull')), |
|
3269 | 3269 | ] + logopts + remoteopts, |
|
3270 | 3270 | _('[-p] [-n] [-M] [-f] [-r REV]...' |
|
3271 | 3271 | ' [--bundle FILENAME] [SOURCE]')), |
|
3272 | 3272 | "^init": |
|
3273 | 3273 | (init, |
|
3274 | 3274 | remoteopts, |
|
3275 | 3275 | _('[-e CMD] [--remotecmd CMD] [DEST]')), |
|
3276 | 3276 | "locate": |
|
3277 | 3277 | (locate, |
|
3278 | 3278 | [('r', 'rev', '', _('search the repository as it stood at rev')), |
|
3279 | 3279 | ('0', 'print0', None, |
|
3280 | 3280 | _('end filenames with NUL, for use with xargs')), |
|
3281 | 3281 | ('f', 'fullpath', None, |
|
3282 | 3282 | _('print complete paths from the filesystem root')), |
|
3283 | 3283 | ] + walkopts, |
|
3284 | 3284 | _('[OPTION]... [PATTERN]...')), |
|
3285 | 3285 | "^log|history": |
|
3286 | 3286 | (log, |
|
3287 | 3287 | [('f', 'follow', None, |
|
3288 | 3288 | _('follow changeset history, or file history across copies and renames')), |
|
3289 | 3289 | ('', 'follow-first', None, |
|
3290 | 3290 | _('only follow the first parent of merge changesets')), |
|
3291 | 3291 | ('d', 'date', '', _('show revs matching date spec')), |
|
3292 | 3292 | ('C', 'copies', None, _('show copied files')), |
|
3293 | 3293 | ('k', 'keyword', [], _('do case-insensitive search for a keyword')), |
|
3294 | 3294 | ('r', 'rev', [], _('show the specified revision or range')), |
|
3295 | 3295 | ('', 'removed', None, _('include revs where files were removed')), |
|
3296 | 3296 | ('m', 'only-merges', None, _('show only merges')), |
|
3297 | 3297 | ('u', 'user', [], _('revs committed by user')), |
|
3298 | 3298 | ('b', 'only-branch', [], |
|
3299 | 3299 | _('show only changesets within the given named branch')), |
|
3300 | 3300 | ('P', 'prune', [], _('do not display revision or any of its ancestors')), |
|
3301 | 3301 | ] + logopts + walkopts, |
|
3302 | 3302 | _('[OPTION]... [FILE]')), |
|
3303 | 3303 | "manifest": |
|
3304 | 3304 | (manifest, |
|
3305 | 3305 | [('r', 'rev', '', _('revision to display'))], |
|
3306 | 3306 | _('[-r REV]')), |
|
3307 | 3307 | "^merge": |
|
3308 | 3308 | (merge, |
|
3309 | 3309 | [('f', 'force', None, _('force a merge with outstanding changes')), |
|
3310 | 3310 | ('r', 'rev', '', _('revision to merge')), |
|
3311 | 3311 | ], |
|
3312 | 3312 | _('[-f] [[-r] REV]')), |
|
3313 | 3313 | "outgoing|out": |
|
3314 | 3314 | (outgoing, |
|
3315 | 3315 | [('f', 'force', None, |
|
3316 | 3316 | _('run even when remote repository is unrelated')), |
|
3317 | 3317 | ('r', 'rev', [], |
|
3318 | 3318 | _('a specific revision up to which you would like to push')), |
|
3319 | 3319 | ('n', 'newest-first', None, _('show newest record first')), |
|
3320 | 3320 | ] + logopts + remoteopts, |
|
3321 | 3321 | _('[-M] [-p] [-n] [-f] [-r REV]... [DEST]')), |
|
3322 | 3322 | "^parents": |
|
3323 | 3323 | (parents, |
|
3324 | 3324 | [('r', 'rev', '', _('show parents from the specified rev')), |
|
3325 | 3325 | ] + templateopts, |
|
3326 | 3326 | _('hg parents [-r REV] [FILE]')), |
|
3327 | 3327 | "paths": (paths, [], _('[NAME]')), |
|
3328 | 3328 | "^pull": |
|
3329 | 3329 | (pull, |
|
3330 | 3330 | [('u', 'update', None, |
|
3331 | 3331 | _('update to new tip if changesets were pulled')), |
|
3332 | 3332 | ('f', 'force', None, |
|
3333 | 3333 | _('run even when remote repository is unrelated')), |
|
3334 | 3334 | ('r', 'rev', [], |
|
3335 | 3335 | _('a specific revision up to which you would like to pull')), |
|
3336 | 3336 | ] + remoteopts, |
|
3337 | 3337 | _('[-u] [-f] [-r REV]... [-e CMD] [--remotecmd CMD] [SOURCE]')), |
|
3338 | 3338 | "^push": |
|
3339 | 3339 | (push, |
|
3340 | 3340 | [('f', 'force', None, _('force push')), |
|
3341 | 3341 | ('r', 'rev', [], |
|
3342 | 3342 | _('a specific revision up to which you would like to push')), |
|
3343 | 3343 | ] + remoteopts, |
|
3344 | 3344 | _('[-f] [-r REV]... [-e CMD] [--remotecmd CMD] [DEST]')), |
|
3345 | 3345 | "recover": (recover, []), |
|
3346 | 3346 | "^remove|rm": |
|
3347 | 3347 | (remove, |
|
3348 | 3348 | [('A', 'after', None, _('record delete for missing files')), |
|
3349 | 3349 | ('f', 'force', None, |
|
3350 | 3350 | _('remove (and delete) file even if added or modified')), |
|
3351 | 3351 | ] + walkopts, |
|
3352 | 3352 | _('[OPTION]... FILE...')), |
|
3353 | 3353 | "rename|mv": |
|
3354 | 3354 | (rename, |
|
3355 | 3355 | [('A', 'after', None, _('record a rename that has already occurred')), |
|
3356 | 3356 | ('f', 'force', None, |
|
3357 | 3357 | _('forcibly copy over an existing managed file')), |
|
3358 | 3358 | ] + walkopts + dryrunopts, |
|
3359 | 3359 | _('[OPTION]... SOURCE... DEST')), |
|
3360 | 3360 | "resolve": |
|
3361 | 3361 | (resolve, |
|
3362 | 3362 | [('a', 'all', None, _('remerge all unresolved files')), |
|
3363 | 3363 | ('l', 'list', None, _('list state of files needing merge')), |
|
3364 | 3364 | ('m', 'mark', None, _('mark files as resolved')), |
|
3365 | 3365 | ('u', 'unmark', None, _('unmark files as resolved'))] |
|
3366 | 3366 | + walkopts, |
|
3367 | 3367 | _('[OPTION]... [FILE]...')), |
|
3368 | 3368 | "revert": |
|
3369 | 3369 | (revert, |
|
3370 | 3370 | [('a', 'all', None, _('revert all changes when no arguments given')), |
|
3371 | 3371 | ('d', 'date', '', _('tipmost revision matching date')), |
|
3372 | 3372 | ('r', 'rev', '', _('revision to revert to')), |
|
3373 | 3373 | ('', 'no-backup', None, _('do not save backup copies of files')), |
|
3374 | 3374 | ] + walkopts + dryrunopts, |
|
3375 | 3375 | _('[OPTION]... [-r REV] [NAME]...')), |
|
3376 | 3376 | "rollback": (rollback, []), |
|
3377 | 3377 | "root": (root, []), |
|
3378 | 3378 | "^serve": |
|
3379 | 3379 | (serve, |
|
3380 | 3380 | [('A', 'accesslog', '', _('name of access log file to write to')), |
|
3381 | 3381 | ('d', 'daemon', None, _('run server in background')), |
|
3382 | 3382 | ('', 'daemon-pipefds', '', _('used internally by daemon mode')), |
|
3383 | 3383 | ('E', 'errorlog', '', _('name of error log file to write to')), |
|
3384 | 3384 | ('p', 'port', 0, _('port to listen on (default: 8000)')), |
|
3385 | 3385 | ('a', 'address', '', _('address to listen on (default: all interfaces)')), |
|
3386 | 3386 | ('', 'prefix', '', _('prefix path to serve from (default: server root)')), |
|
3387 | 3387 | ('n', 'name', '', |
|
3388 | _('name to show in web pages (default: working dir)')), | |
|
3388 | _('name to show in web pages (default: working directory)')), | |
|
3389 | 3389 | ('', 'webdir-conf', '', _('name of the webdir config file' |
|
3390 | 3390 | ' (serve more than one repo)')), |
|
3391 | 3391 | ('', 'pid-file', '', _('name of file to write process ID to')), |
|
3392 | 3392 | ('', 'stdio', None, _('for remote clients')), |
|
3393 | 3393 | ('t', 'templates', '', _('web templates to use')), |
|
3394 | 3394 | ('', 'style', '', _('template style to use')), |
|
3395 | 3395 | ('6', 'ipv6', None, _('use IPv6 in addition to IPv4')), |
|
3396 | 3396 | ('', 'certificate', '', _('SSL certificate file'))], |
|
3397 | 3397 | _('[OPTION]...')), |
|
3398 | 3398 | "showconfig|debugconfig": |
|
3399 | 3399 | (showconfig, |
|
3400 | 3400 | [('u', 'untrusted', None, _('show untrusted configuration options'))], |
|
3401 | 3401 | _('[-u] [NAME]...')), |
|
3402 | 3402 | "^status|st": |
|
3403 | 3403 | (status, |
|
3404 | 3404 | [('A', 'all', None, _('show status of all files')), |
|
3405 | 3405 | ('m', 'modified', None, _('show only modified files')), |
|
3406 | 3406 | ('a', 'added', None, _('show only added files')), |
|
3407 | 3407 | ('r', 'removed', None, _('show only removed files')), |
|
3408 | 3408 | ('d', 'deleted', None, _('show only deleted (but tracked) files')), |
|
3409 | 3409 | ('c', 'clean', None, _('show only files without changes')), |
|
3410 | 3410 | ('u', 'unknown', None, _('show only unknown (not tracked) files')), |
|
3411 | 3411 | ('i', 'ignored', None, _('show only ignored files')), |
|
3412 | 3412 | ('n', 'no-status', None, _('hide status prefix')), |
|
3413 | 3413 | ('C', 'copies', None, _('show source of copied files')), |
|
3414 | 3414 | ('0', 'print0', None, |
|
3415 | 3415 | _('end filenames with NUL, for use with xargs')), |
|
3416 | 3416 | ('', 'rev', [], _('show difference from revision')), |
|
3417 | 3417 | ] + walkopts, |
|
3418 | 3418 | _('[OPTION]... [FILE]...')), |
|
3419 | 3419 | "tag": |
|
3420 | 3420 | (tag, |
|
3421 | 3421 | [('f', 'force', None, _('replace existing tag')), |
|
3422 | 3422 | ('l', 'local', None, _('make the tag local')), |
|
3423 | 3423 | ('r', 'rev', '', _('revision to tag')), |
|
3424 | 3424 | ('', 'remove', None, _('remove a tag')), |
|
3425 | 3425 | # -l/--local is already there, commitopts cannot be used |
|
3426 | 3426 | ('m', 'message', '', _('use <text> as commit message')), |
|
3427 | 3427 | ] + commitopts2, |
|
3428 | 3428 | _('[-l] [-m TEXT] [-d DATE] [-u USER] [-r REV] NAME...')), |
|
3429 | 3429 | "tags": (tags, []), |
|
3430 | 3430 | "tip": |
|
3431 | 3431 | (tip, |
|
3432 | 3432 | [('p', 'patch', None, _('show patch')), |
|
3433 | 3433 | ('g', 'git', None, _('use git extended diff format')), |
|
3434 | 3434 | ] + templateopts, |
|
3435 | 3435 | _('[-p]')), |
|
3436 | 3436 | "unbundle": |
|
3437 | 3437 | (unbundle, |
|
3438 | 3438 | [('u', 'update', None, |
|
3439 | 3439 | _('update to new tip if changesets were unbundled'))], |
|
3440 | 3440 | _('[-u] FILE...')), |
|
3441 | 3441 | "^update|up|checkout|co": |
|
3442 | 3442 | (update, |
|
3443 | 3443 | [('C', 'clean', None, _('overwrite locally modified files (no backup)')), |
|
3444 | 3444 | ('d', 'date', '', _('tipmost revision matching date')), |
|
3445 | 3445 | ('r', 'rev', '', _('revision'))], |
|
3446 | 3446 | _('[-C] [-d DATE] [[-r] REV]')), |
|
3447 | 3447 | "verify": (verify, []), |
|
3448 | 3448 | "version": (version_, []), |
|
3449 | 3449 | } |
|
3450 | 3450 | |
|
3451 | 3451 | norepo = ("clone init version help debugcommands debugcomplete debugdata" |
|
3452 | 3452 | " debugindex debugindexdot debugdate debuginstall debugfsinfo") |
|
3453 | 3453 | optionalrepo = ("identify paths serve showconfig debugancestor") |
@@ -1,246 +1,246 b'' | |||
|
1 | 1 | hg convert [OPTION]... SOURCE [DEST [REVMAP]] |
|
2 | 2 | |
|
3 | 3 | convert a foreign SCM repository to a Mercurial one. |
|
4 | 4 | |
|
5 | 5 | Accepted source formats [identifiers]: |
|
6 | 6 | - Mercurial [hg] |
|
7 | 7 | - CVS [cvs] |
|
8 | 8 | - Darcs [darcs] |
|
9 | 9 | - git [git] |
|
10 | 10 | - Subversion [svn] |
|
11 | 11 | - Monotone [mtn] |
|
12 | 12 | - GNU Arch [gnuarch] |
|
13 | 13 | - Bazaar [bzr] |
|
14 | 14 | - Perforce [p4] |
|
15 | 15 | |
|
16 | 16 | Accepted destination formats [identifiers]: |
|
17 | 17 | - Mercurial [hg] |
|
18 | 18 | - Subversion [svn] (history on branches is not preserved) |
|
19 | 19 | |
|
20 | 20 | If no revision is given, all revisions will be converted. |
|
21 | 21 | Otherwise, convert will only import up to the named revision |
|
22 | 22 | (given in a format understood by the source). |
|
23 | 23 | |
|
24 | 24 | If no destination directory name is specified, it defaults to the |
|
25 | 25 | basename of the source with '-hg' appended. If the destination |
|
26 | 26 | repository doesn't exist, it will be created. |
|
27 | 27 | |
|
28 | 28 | If <REVMAP> isn't given, it will be put in a default location |
|
29 | 29 | (<dest>/.hg/shamap by default). The <REVMAP> is a simple text file |
|
30 | 30 | that maps each source commit ID to the destination ID for that |
|
31 | 31 | revision, like so: |
|
32 | 32 | <source ID> <destination ID> |
|
33 | 33 | |
|
34 | 34 | If the file doesn't exist, it's automatically created. It's |
|
35 | 35 | updated on each commit copied, so convert-repo can be interrupted |
|
36 | 36 | and can be run repeatedly to copy new commits. |
|
37 | 37 | |
|
38 | 38 | The [username mapping] file is a simple text file that maps each |
|
39 | 39 | source commit author to a destination commit author. It is handy |
|
40 | 40 | for source SCMs that use unix logins to identify authors (eg: |
|
41 | 41 | CVS). One line per author mapping and the line format is: |
|
42 | 42 | srcauthor=whatever string you want |
|
43 | 43 | |
|
44 | 44 | The filemap is a file that allows filtering and remapping of files |
|
45 | 45 | and directories. Comment lines start with '#'. Each line can |
|
46 | 46 | contain one of the following directives: |
|
47 | 47 | |
|
48 | 48 | include path/to/file |
|
49 | 49 | |
|
50 | 50 | exclude path/to/file |
|
51 | 51 | |
|
52 | 52 | rename from/file to/file |
|
53 | 53 | |
|
54 | 54 | The 'include' directive causes a file, or all files under a |
|
55 | 55 | directory, to be included in the destination repository, and the |
|
56 | exclusion of all other files and dirs not explicitely included. | |
|
56 | exclusion of all other files and directories not explicitely included. | |
|
57 | 57 | The 'exclude' directive causes files or directories to be omitted. |
|
58 | 58 | The 'rename' directive renames a file or directory. To rename from |
|
59 | 59 | a subdirectory into the root of the repository, use '.' as the |
|
60 | 60 | path to rename to. |
|
61 | 61 | |
|
62 | 62 | The splicemap is a file that allows insertion of synthetic |
|
63 | 63 | history, letting you specify the parents of a revision. This is |
|
64 | 64 | useful if you want to e.g. give a Subversion merge two parents, or |
|
65 | 65 | graft two disconnected series of history together. Each entry |
|
66 | 66 | contains a key, followed by a space, followed by one or two |
|
67 | 67 | comma-separated values. The key is the revision ID in the source |
|
68 | 68 | revision control system whose parents should be modified (same |
|
69 | 69 | format as a key in .hg/shamap). The values are the revision IDs |
|
70 | 70 | (in either the source or destination revision control system) that |
|
71 | 71 | should be used as the new parents for that node. |
|
72 | 72 | |
|
73 | 73 | Mercurial Source |
|
74 | 74 | ----------------- |
|
75 | 75 | |
|
76 | 76 | --config convert.hg.ignoreerrors=False (boolean) |
|
77 | 77 | ignore integrity errors when reading. Use it to fix Mercurial |
|
78 | 78 | repositories with missing revlogs, by converting from and to |
|
79 | 79 | Mercurial. |
|
80 | 80 | --config convert.hg.saverev=False (boolean) |
|
81 | 81 | store original revision ID in changeset (forces target IDs to |
|
82 | 82 | change) |
|
83 | 83 | --config convert.hg.startrev=0 (hg revision identifier) |
|
84 | 84 | convert start revision and its descendants |
|
85 | 85 | |
|
86 | 86 | CVS Source |
|
87 | 87 | ---------- |
|
88 | 88 | |
|
89 | 89 | CVS source will use a sandbox (i.e. a checked-out copy) from CVS |
|
90 | 90 | to indicate the starting point of what will be converted. Direct |
|
91 | 91 | access to the repository files is not needed, unless of course the |
|
92 | 92 | repository is :local:. The conversion uses the top level directory |
|
93 | 93 | in the sandbox to find the CVS repository, and then uses CVS rlog |
|
94 | 94 | commands to find files to convert. This means that unless a |
|
95 | 95 | filemap is given, all files under the starting directory will be |
|
96 | 96 | converted, and that any directory reorganisation in the CVS |
|
97 | 97 | sandbox is ignored. |
|
98 | 98 | |
|
99 | 99 | Because CVS does not have changesets, it is necessary to collect |
|
100 | 100 | individual commits to CVS and merge them into changesets. CVS |
|
101 | 101 | source uses its internal changeset merging code by default but can |
|
102 | 102 | be configured to call the external 'cvsps' program by setting: |
|
103 | 103 | --config convert.cvsps='cvsps -A -u --cvs-direct -q' |
|
104 | 104 | This is a legacy option and may be removed in future. |
|
105 | 105 | |
|
106 | 106 | The options shown are the defaults. |
|
107 | 107 | |
|
108 | 108 | Internal cvsps is selected by setting |
|
109 | 109 | --config convert.cvsps=builtin |
|
110 | 110 | and has a few more configurable options: |
|
111 | 111 | --config convert.cvsps.fuzz=60 (integer) |
|
112 | 112 | Specify the maximum time (in seconds) that is allowed |
|
113 | 113 | between commits with identical user and log message in a |
|
114 | 114 | single changeset. When very large files were checked in as |
|
115 | 115 | part of a changeset then the default may not be long |
|
116 | 116 | enough. |
|
117 | 117 | --config convert.cvsps.mergeto='{{mergetobranch ([-\w]+)}}' |
|
118 | 118 | Specify a regular expression to which commit log messages |
|
119 | 119 | are matched. If a match occurs, then the conversion |
|
120 | 120 | process will insert a dummy revision merging the branch on |
|
121 | 121 | which this log message occurs to the branch indicated in |
|
122 | 122 | the regex. |
|
123 | 123 | --config convert.cvsps.mergefrom='{{mergefrombranch ([-\w]+)}}' |
|
124 | 124 | Specify a regular expression to which commit log messages |
|
125 | 125 | are matched. If a match occurs, then the conversion |
|
126 | 126 | process will add the most recent revision on the branch |
|
127 | 127 | indicated in the regex as the second parent of the |
|
128 | 128 | changeset. |
|
129 | 129 | |
|
130 | 130 | The hgext/convert/cvsps wrapper script allows the builtin |
|
131 | 131 | changeset merging code to be run without doing a conversion. Its |
|
132 | 132 | parameters and output are similar to that of cvsps 2.1. |
|
133 | 133 | |
|
134 | 134 | Subversion Source |
|
135 | 135 | ----------------- |
|
136 | 136 | |
|
137 | 137 | Subversion source detects classical trunk/branches/tags layouts. |
|
138 | 138 | By default, the supplied "svn://repo/path/" source URL is |
|
139 | 139 | converted as a single branch. If "svn://repo/path/trunk" exists it |
|
140 | 140 | replaces the default branch. If "svn://repo/path/branches" exists, |
|
141 | 141 | its subdirectories are listed as possible branches. If |
|
142 | 142 | "svn://repo/path/tags" exists, it is looked for tags referencing |
|
143 | 143 | converted branches. Default "trunk", "branches" and "tags" values |
|
144 | 144 | can be overriden with following options. Set them to paths |
|
145 | 145 | relative to the source URL, or leave them blank to disable |
|
146 | 146 | autodetection. |
|
147 | 147 | |
|
148 | 148 | --config convert.svn.branches=branches (directory name) |
|
149 | 149 | specify the directory containing branches |
|
150 | 150 | --config convert.svn.tags=tags (directory name) |
|
151 | 151 | specify the directory containing tags |
|
152 | 152 | --config convert.svn.trunk=trunk (directory name) |
|
153 | 153 | specify the name of the trunk branch |
|
154 | 154 | |
|
155 | 155 | Source history can be retrieved starting at a specific revision, |
|
156 | 156 | instead of being integrally converted. Only single branch |
|
157 | 157 | conversions are supported. |
|
158 | 158 | |
|
159 | 159 | --config convert.svn.startrev=0 (svn revision number) |
|
160 | 160 | specify start Subversion revision. |
|
161 | 161 | |
|
162 | 162 | Perforce Source |
|
163 | 163 | --------------- |
|
164 | 164 | |
|
165 | 165 | The Perforce (P4) importer can be given a p4 depot path or a |
|
166 | 166 | client specification as source. It will convert all files in the |
|
167 | 167 | source to a flat Mercurial repository, ignoring labels, branches |
|
168 | 168 | and integrations. Note that when a depot path is given you then |
|
169 | 169 | usually should specify a target directory, because otherwise the |
|
170 | 170 | target may be named ...-hg. |
|
171 | 171 | |
|
172 | 172 | It is possible to limit the amount of source history to be |
|
173 | 173 | converted by specifying an initial Perforce revision. |
|
174 | 174 | |
|
175 | 175 | --config convert.p4.startrev=0 (perforce changelist number) |
|
176 | 176 | specify initial Perforce revision. |
|
177 | 177 | |
|
178 | 178 | |
|
179 | 179 | Mercurial Destination |
|
180 | 180 | --------------------- |
|
181 | 181 | |
|
182 | 182 | --config convert.hg.clonebranches=False (boolean) |
|
183 | 183 | dispatch source branches in separate clones. |
|
184 | 184 | --config convert.hg.tagsbranch=default (branch name) |
|
185 | 185 | tag revisions branch name |
|
186 | 186 | --config convert.hg.usebranchnames=True (boolean) |
|
187 | 187 | preserve branch names |
|
188 | 188 | |
|
189 | 189 | options: |
|
190 | 190 | |
|
191 | 191 | -A --authors username mapping filename |
|
192 | 192 | -d --dest-type destination repository type |
|
193 | 193 | --filemap remap file names using contents of file |
|
194 | 194 | -r --rev import up to target revision REV |
|
195 | 195 | -s --source-type source repository type |
|
196 | 196 | --splicemap splice synthesized history into place |
|
197 | 197 | --datesort try to sort changesets by date |
|
198 | 198 | |
|
199 | 199 | use "hg -v help convert" to show global options |
|
200 | 200 | adding a |
|
201 | 201 | assuming destination a-hg |
|
202 | 202 | initializing destination a-hg repository |
|
203 | 203 | scanning source... |
|
204 | 204 | sorting... |
|
205 | 205 | converting... |
|
206 | 206 | 4 a |
|
207 | 207 | 3 b |
|
208 | 208 | 2 c |
|
209 | 209 | 1 d |
|
210 | 210 | 0 e |
|
211 | 211 | pulling from ../a |
|
212 | 212 | searching for changes |
|
213 | 213 | no changes found |
|
214 | 214 | % should fail |
|
215 | 215 | initializing destination bogusfile repository |
|
216 | 216 | abort: cannot create new bundle repository |
|
217 | 217 | % should fail |
|
218 | 218 | abort: Permission denied: bogusdir |
|
219 | 219 | % should succeed |
|
220 | 220 | initializing destination bogusdir repository |
|
221 | 221 | scanning source... |
|
222 | 222 | sorting... |
|
223 | 223 | converting... |
|
224 | 224 | 4 a |
|
225 | 225 | 3 b |
|
226 | 226 | 2 c |
|
227 | 227 | 1 d |
|
228 | 228 | 0 e |
|
229 | 229 | % test pre and post conversion actions |
|
230 | 230 | run hg source pre-conversion action |
|
231 | 231 | run hg sink pre-conversion action |
|
232 | 232 | run hg sink post-conversion action |
|
233 | 233 | run hg source post-conversion action |
|
234 | 234 | % converting empty dir should fail nicely |
|
235 | 235 | assuming destination emptydir-hg |
|
236 | 236 | initializing destination emptydir-hg repository |
|
237 | 237 | emptydir does not look like a CVS checkout |
|
238 | 238 | emptydir does not look like a Git repo |
|
239 | 239 | emptydir does not look like a Subversion repo |
|
240 | 240 | emptydir is not a local Mercurial repo |
|
241 | 241 | emptydir does not look like a darcs repo |
|
242 | 242 | emptydir does not look like a monotone repo |
|
243 | 243 | emptydir does not look like a GNU Arch repo |
|
244 | 244 | emptydir does not look like a Bazaar repo |
|
245 | 245 | emptydir does not look like a P4 repo |
|
246 | 246 | abort: emptydir: missing or unsupported repository |
@@ -1,278 +1,278 b'' | |||
|
1 | 1 | adding a |
|
2 | 2 | adding b |
|
3 | 3 | updating working directory |
|
4 | 4 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
5 | 5 | pulling from ../b |
|
6 | 6 | searching for changes |
|
7 | 7 | warning: repository is unrelated |
|
8 | 8 | adding changesets |
|
9 | 9 | adding manifests |
|
10 | 10 | adding file changes |
|
11 | 11 | added 1 changesets with 1 changes to 1 files (+1 heads) |
|
12 | 12 | (run 'hg heads' to see heads, 'hg merge' to merge) |
|
13 | 13 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
14 | 14 | (branch merge, don't forget to commit) |
|
15 | 15 | %% -R/--repository |
|
16 | 16 | changeset: 0:8580ff50825a |
|
17 | 17 | tag: tip |
|
18 | 18 | user: test |
|
19 | 19 | date: Thu Jan 01 00:00:01 1970 +0000 |
|
20 | 20 | summary: a |
|
21 | 21 | |
|
22 | 22 | changeset: 0:b6c483daf290 |
|
23 | 23 | tag: tip |
|
24 | 24 | user: test |
|
25 | 25 | date: Thu Jan 01 00:00:01 1970 +0000 |
|
26 | 26 | summary: b |
|
27 | 27 | |
|
28 | 28 | %% implicit -R |
|
29 | 29 | 0: a |
|
30 | 30 | 0: a |
|
31 | 31 | abort: There is no Mercurial repository here (.hg not found)! |
|
32 | 32 | abort: a/a not under root |
|
33 | 33 | abort: There is no Mercurial repository here (.hg not found)! |
|
34 | 34 | %% abbrev of long option |
|
35 | 35 | changeset: 1:b6c483daf290 |
|
36 | 36 | tag: tip |
|
37 | 37 | parent: -1:000000000000 |
|
38 | 38 | user: test |
|
39 | 39 | date: Thu Jan 01 00:00:01 1970 +0000 |
|
40 | 40 | summary: b |
|
41 | 41 | |
|
42 | 42 | %% earlygetopt with duplicate options (36d23de02da1) |
|
43 | 43 | changeset: 1:b6c483daf290 |
|
44 | 44 | tag: tip |
|
45 | 45 | parent: -1:000000000000 |
|
46 | 46 | user: test |
|
47 | 47 | date: Thu Jan 01 00:00:01 1970 +0000 |
|
48 | 48 | summary: b |
|
49 | 49 | |
|
50 | 50 | changeset: 0:8580ff50825a |
|
51 | 51 | tag: tip |
|
52 | 52 | user: test |
|
53 | 53 | date: Thu Jan 01 00:00:01 1970 +0000 |
|
54 | 54 | summary: a |
|
55 | 55 | |
|
56 | 56 | %% earlygetopt short option without following space |
|
57 | 57 | 0:b6c483daf290 |
|
58 | 58 | %% earlygetopt with illegal abbreviations |
|
59 | 59 | abort: Option --config may not be abbreviated! |
|
60 | 60 | abort: Option --cwd may not be abbreviated! |
|
61 | 61 | abort: Option -R has to be separated from other options (i.e. not -qR) and --repository may only be abbreviated as --repo! |
|
62 | 62 | abort: Option -R has to be separated from other options (i.e. not -qR) and --repository may only be abbreviated as --repo! |
|
63 | 63 | abort: Option -R has to be separated from other options (i.e. not -qR) and --repository may only be abbreviated as --repo! |
|
64 | 64 | abort: Option -R has to be separated from other options (i.e. not -qR) and --repository may only be abbreviated as --repo! |
|
65 | 65 | %% --cwd |
|
66 | 66 | changeset: 0:8580ff50825a |
|
67 | 67 | tag: tip |
|
68 | 68 | user: test |
|
69 | 69 | date: Thu Jan 01 00:00:01 1970 +0000 |
|
70 | 70 | summary: a |
|
71 | 71 | |
|
72 | 72 | %% -y/--noninteractive - just be sure it is parsed |
|
73 | 73 | 0:8580ff50825a |
|
74 | 74 | 0:8580ff50825a |
|
75 | 75 | %% -q/--quiet |
|
76 | 76 | 0:8580ff50825a |
|
77 | 77 | 0:b6c483daf290 |
|
78 | 78 | 0:8580ff50825a |
|
79 | 79 | 1:b6c483daf290 |
|
80 | 80 | %% -v/--verbose |
|
81 | 81 | changeset: 1:b6c483daf290 |
|
82 | 82 | tag: tip |
|
83 | 83 | parent: -1:000000000000 |
|
84 | 84 | user: test |
|
85 | 85 | date: Thu Jan 01 00:00:01 1970 +0000 |
|
86 | 86 | files: b |
|
87 | 87 | description: |
|
88 | 88 | b |
|
89 | 89 | |
|
90 | 90 | |
|
91 | 91 | changeset: 0:8580ff50825a |
|
92 | 92 | user: test |
|
93 | 93 | date: Thu Jan 01 00:00:01 1970 +0000 |
|
94 | 94 | files: a |
|
95 | 95 | description: |
|
96 | 96 | a |
|
97 | 97 | |
|
98 | 98 | |
|
99 | 99 | changeset: 0:b6c483daf290 |
|
100 | 100 | tag: tip |
|
101 | 101 | user: test |
|
102 | 102 | date: Thu Jan 01 00:00:01 1970 +0000 |
|
103 | 103 | files: b |
|
104 | 104 | description: |
|
105 | 105 | b |
|
106 | 106 | |
|
107 | 107 | |
|
108 | 108 | %% --config |
|
109 | 109 | quuxfoo |
|
110 | 110 | abort: malformed --config option: |
|
111 | 111 | abort: malformed --config option: a.b |
|
112 | 112 | abort: malformed --config option: a |
|
113 | 113 | abort: malformed --config option: a.= |
|
114 | 114 | abort: malformed --config option: .b= |
|
115 | 115 | %% --debug |
|
116 | 116 | changeset: 1:b6c483daf2907ce5825c0bb50f5716226281cc1a |
|
117 | 117 | tag: tip |
|
118 | 118 | parent: -1:0000000000000000000000000000000000000000 |
|
119 | 119 | parent: -1:0000000000000000000000000000000000000000 |
|
120 | 120 | manifest: 1:23226e7a252cacdc2d99e4fbdc3653441056de49 |
|
121 | 121 | user: test |
|
122 | 122 | date: Thu Jan 01 00:00:01 1970 +0000 |
|
123 | 123 | files+: b |
|
124 | 124 | extra: branch=default |
|
125 | 125 | description: |
|
126 | 126 | b |
|
127 | 127 | |
|
128 | 128 | |
|
129 | 129 | changeset: 0:8580ff50825a50c8f716709acdf8de0deddcd6ab |
|
130 | 130 | parent: -1:0000000000000000000000000000000000000000 |
|
131 | 131 | parent: -1:0000000000000000000000000000000000000000 |
|
132 | 132 | manifest: 0:a0c8bcbbb45c63b90b70ad007bf38961f64f2af0 |
|
133 | 133 | user: test |
|
134 | 134 | date: Thu Jan 01 00:00:01 1970 +0000 |
|
135 | 135 | files+: a |
|
136 | 136 | extra: branch=default |
|
137 | 137 | description: |
|
138 | 138 | a |
|
139 | 139 | |
|
140 | 140 | |
|
141 | 141 | %% --traceback |
|
142 | 142 | Traceback (most recent call last): |
|
143 | 143 | %% --time |
|
144 | 144 | Time: real x.x secs (user x.x+x.x sys x.x+x.x) |
|
145 | 145 | %% --version |
|
146 | 146 | Mercurial Distributed SCM (version xxx) |
|
147 | 147 | %% -h/--help |
|
148 | 148 | Mercurial Distributed SCM |
|
149 | 149 | |
|
150 | 150 | list of commands: |
|
151 | 151 | |
|
152 | 152 | add add the specified files on the next commit |
|
153 | 153 | addremove add all new files, delete all missing files |
|
154 | 154 | annotate show changeset information per file line |
|
155 | 155 | archive create unversioned archive of a repository revision |
|
156 | 156 | backout reverse effect of earlier changeset |
|
157 | 157 | bisect subdivision search of changesets |
|
158 | 158 | branch set or show the current branch name |
|
159 | 159 | branches list repository named branches |
|
160 | 160 | bundle create a changegroup file |
|
161 | 161 | cat output the current or given revision of files |
|
162 | 162 | clone make a copy of an existing repository |
|
163 | 163 | commit commit the specified files or all outstanding changes |
|
164 | 164 | copy mark files as copied for the next commit |
|
165 | 165 | diff diff repository (or selected files) |
|
166 | 166 | export dump the header and diffs for one or more changesets |
|
167 | 167 | grep search for a pattern in specified files and revisions |
|
168 | 168 | heads show current repository heads or show branch heads |
|
169 | 169 | help show help for a given topic or a help overview |
|
170 | 170 | identify identify the working copy or specified revision |
|
171 | 171 | import import an ordered set of patches |
|
172 | 172 | incoming show new changesets found in source |
|
173 | 173 | init create a new repository in the given directory |
|
174 | 174 | locate locate files matching specific patterns |
|
175 | 175 | log show revision history of entire repository or files |
|
176 | 176 | manifest output the current or given revision of the project manifest |
|
177 | 177 | merge merge working directory with another revision |
|
178 | 178 | outgoing show changesets not found in destination |
|
179 | parents show the parents of the working dir or revision | |
|
179 | parents show the parents of the working directory or revision | |
|
180 | 180 | paths show aliases for remote repositories |
|
181 | 181 | pull pull changes from the specified source |
|
182 | 182 | push push changes to the specified destination |
|
183 | 183 | recover roll back an interrupted transaction |
|
184 | 184 | remove remove the specified files on the next commit |
|
185 | 185 | rename rename files; equivalent of copy + remove |
|
186 | 186 | resolve retry file merges from a merge or update |
|
187 | revert restore individual files or dirs to an earlier state | |
|
187 | revert restore individual files or directories to an earlier state | |
|
188 | 188 | rollback roll back the last transaction |
|
189 | root print the root (top) of the current working dir | |
|
189 | root print the root (top) of the current working directory | |
|
190 | 190 | serve export the repository via HTTP |
|
191 | 191 | showconfig show combined config settings from all hgrc files |
|
192 | 192 | status show changed files in the working directory |
|
193 | 193 | tag add one or more tags for the current or given revision |
|
194 | 194 | tags list repository tags |
|
195 | 195 | tip show the tip revision |
|
196 | 196 | unbundle apply one or more changegroup files |
|
197 | 197 | update update working directory |
|
198 | 198 | verify verify the integrity of the repository |
|
199 | 199 | version output version and copyright information |
|
200 | 200 | |
|
201 | 201 | additional help topics: |
|
202 | 202 | |
|
203 | 203 | dates Date Formats |
|
204 | 204 | patterns File Name Patterns |
|
205 | 205 | environment Environment Variables |
|
206 | 206 | revisions Specifying Single Revisions |
|
207 | 207 | multirevs Specifying Multiple Revisions |
|
208 | 208 | diffs Diff Formats |
|
209 | 209 | templating Template Usage |
|
210 | 210 | urls URL Paths |
|
211 | 211 | |
|
212 | 212 | use "hg -v help" to show aliases and global options |
|
213 | 213 | Mercurial Distributed SCM |
|
214 | 214 | |
|
215 | 215 | list of commands: |
|
216 | 216 | |
|
217 | 217 | add add the specified files on the next commit |
|
218 | 218 | addremove add all new files, delete all missing files |
|
219 | 219 | annotate show changeset information per file line |
|
220 | 220 | archive create unversioned archive of a repository revision |
|
221 | 221 | backout reverse effect of earlier changeset |
|
222 | 222 | bisect subdivision search of changesets |
|
223 | 223 | branch set or show the current branch name |
|
224 | 224 | branches list repository named branches |
|
225 | 225 | bundle create a changegroup file |
|
226 | 226 | cat output the current or given revision of files |
|
227 | 227 | clone make a copy of an existing repository |
|
228 | 228 | commit commit the specified files or all outstanding changes |
|
229 | 229 | copy mark files as copied for the next commit |
|
230 | 230 | diff diff repository (or selected files) |
|
231 | 231 | export dump the header and diffs for one or more changesets |
|
232 | 232 | grep search for a pattern in specified files and revisions |
|
233 | 233 | heads show current repository heads or show branch heads |
|
234 | 234 | help show help for a given topic or a help overview |
|
235 | 235 | identify identify the working copy or specified revision |
|
236 | 236 | import import an ordered set of patches |
|
237 | 237 | incoming show new changesets found in source |
|
238 | 238 | init create a new repository in the given directory |
|
239 | 239 | locate locate files matching specific patterns |
|
240 | 240 | log show revision history of entire repository or files |
|
241 | 241 | manifest output the current or given revision of the project manifest |
|
242 | 242 | merge merge working directory with another revision |
|
243 | 243 | outgoing show changesets not found in destination |
|
244 | parents show the parents of the working dir or revision | |
|
244 | parents show the parents of the working directory or revision | |
|
245 | 245 | paths show aliases for remote repositories |
|
246 | 246 | pull pull changes from the specified source |
|
247 | 247 | push push changes to the specified destination |
|
248 | 248 | recover roll back an interrupted transaction |
|
249 | 249 | remove remove the specified files on the next commit |
|
250 | 250 | rename rename files; equivalent of copy + remove |
|
251 | 251 | resolve retry file merges from a merge or update |
|
252 | revert restore individual files or dirs to an earlier state | |
|
252 | revert restore individual files or directories to an earlier state | |
|
253 | 253 | rollback roll back the last transaction |
|
254 | root print the root (top) of the current working dir | |
|
254 | root print the root (top) of the current working directory | |
|
255 | 255 | serve export the repository via HTTP |
|
256 | 256 | showconfig show combined config settings from all hgrc files |
|
257 | 257 | status show changed files in the working directory |
|
258 | 258 | tag add one or more tags for the current or given revision |
|
259 | 259 | tags list repository tags |
|
260 | 260 | tip show the tip revision |
|
261 | 261 | unbundle apply one or more changegroup files |
|
262 | 262 | update update working directory |
|
263 | 263 | verify verify the integrity of the repository |
|
264 | 264 | version output version and copyright information |
|
265 | 265 | |
|
266 | 266 | additional help topics: |
|
267 | 267 | |
|
268 | 268 | dates Date Formats |
|
269 | 269 | patterns File Name Patterns |
|
270 | 270 | environment Environment Variables |
|
271 | 271 | revisions Specifying Single Revisions |
|
272 | 272 | multirevs Specifying Multiple Revisions |
|
273 | 273 | diffs Diff Formats |
|
274 | 274 | templating Template Usage |
|
275 | 275 | urls URL Paths |
|
276 | 276 | |
|
277 | 277 | use "hg -v help" to show aliases and global options |
|
278 | 278 | %% not tested: --debugger |
@@ -1,342 +1,342 b'' | |||
|
1 | 1 | Mercurial Distributed SCM |
|
2 | 2 | |
|
3 | 3 | basic commands: |
|
4 | 4 | |
|
5 | 5 | add add the specified files on the next commit |
|
6 | 6 | annotate show changeset information per file line |
|
7 | 7 | clone make a copy of an existing repository |
|
8 | 8 | commit commit the specified files or all outstanding changes |
|
9 | 9 | diff diff repository (or selected files) |
|
10 | 10 | export dump the header and diffs for one or more changesets |
|
11 | 11 | init create a new repository in the given directory |
|
12 | 12 | log show revision history of entire repository or files |
|
13 | 13 | merge merge working directory with another revision |
|
14 | parents show the parents of the working dir or revision | |
|
14 | parents show the parents of the working directory or revision | |
|
15 | 15 | pull pull changes from the specified source |
|
16 | 16 | push push changes to the specified destination |
|
17 | 17 | remove remove the specified files on the next commit |
|
18 | 18 | serve export the repository via HTTP |
|
19 | 19 | status show changed files in the working directory |
|
20 | 20 | update update working directory |
|
21 | 21 | |
|
22 | 22 | use "hg help" for the full list of commands or "hg -v" for details |
|
23 | 23 | add add the specified files on the next commit |
|
24 | 24 | annotate show changeset information per file line |
|
25 | 25 | clone make a copy of an existing repository |
|
26 | 26 | commit commit the specified files or all outstanding changes |
|
27 | 27 | diff diff repository (or selected files) |
|
28 | 28 | export dump the header and diffs for one or more changesets |
|
29 | 29 | init create a new repository in the given directory |
|
30 | 30 | log show revision history of entire repository or files |
|
31 | 31 | merge merge working directory with another revision |
|
32 | parents show the parents of the working dir or revision | |
|
32 | parents show the parents of the working directory or revision | |
|
33 | 33 | pull pull changes from the specified source |
|
34 | 34 | push push changes to the specified destination |
|
35 | 35 | remove remove the specified files on the next commit |
|
36 | 36 | serve export the repository via HTTP |
|
37 | 37 | status show changed files in the working directory |
|
38 | 38 | update update working directory |
|
39 | 39 | Mercurial Distributed SCM |
|
40 | 40 | |
|
41 | 41 | list of commands: |
|
42 | 42 | |
|
43 | 43 | add add the specified files on the next commit |
|
44 | 44 | addremove add all new files, delete all missing files |
|
45 | 45 | annotate show changeset information per file line |
|
46 | 46 | archive create unversioned archive of a repository revision |
|
47 | 47 | backout reverse effect of earlier changeset |
|
48 | 48 | bisect subdivision search of changesets |
|
49 | 49 | branch set or show the current branch name |
|
50 | 50 | branches list repository named branches |
|
51 | 51 | bundle create a changegroup file |
|
52 | 52 | cat output the current or given revision of files |
|
53 | 53 | clone make a copy of an existing repository |
|
54 | 54 | commit commit the specified files or all outstanding changes |
|
55 | 55 | copy mark files as copied for the next commit |
|
56 | 56 | diff diff repository (or selected files) |
|
57 | 57 | export dump the header and diffs for one or more changesets |
|
58 | 58 | grep search for a pattern in specified files and revisions |
|
59 | 59 | heads show current repository heads or show branch heads |
|
60 | 60 | help show help for a given topic or a help overview |
|
61 | 61 | identify identify the working copy or specified revision |
|
62 | 62 | import import an ordered set of patches |
|
63 | 63 | incoming show new changesets found in source |
|
64 | 64 | init create a new repository in the given directory |
|
65 | 65 | locate locate files matching specific patterns |
|
66 | 66 | log show revision history of entire repository or files |
|
67 | 67 | manifest output the current or given revision of the project manifest |
|
68 | 68 | merge merge working directory with another revision |
|
69 | 69 | outgoing show changesets not found in destination |
|
70 | parents show the parents of the working dir or revision | |
|
70 | parents show the parents of the working directory or revision | |
|
71 | 71 | paths show aliases for remote repositories |
|
72 | 72 | pull pull changes from the specified source |
|
73 | 73 | push push changes to the specified destination |
|
74 | 74 | recover roll back an interrupted transaction |
|
75 | 75 | remove remove the specified files on the next commit |
|
76 | 76 | rename rename files; equivalent of copy + remove |
|
77 | 77 | resolve retry file merges from a merge or update |
|
78 | revert restore individual files or dirs to an earlier state | |
|
78 | revert restore individual files or directories to an earlier state | |
|
79 | 79 | rollback roll back the last transaction |
|
80 | root print the root (top) of the current working dir | |
|
80 | root print the root (top) of the current working directory | |
|
81 | 81 | serve export the repository via HTTP |
|
82 | 82 | showconfig show combined config settings from all hgrc files |
|
83 | 83 | status show changed files in the working directory |
|
84 | 84 | tag add one or more tags for the current or given revision |
|
85 | 85 | tags list repository tags |
|
86 | 86 | tip show the tip revision |
|
87 | 87 | unbundle apply one or more changegroup files |
|
88 | 88 | update update working directory |
|
89 | 89 | verify verify the integrity of the repository |
|
90 | 90 | version output version and copyright information |
|
91 | 91 | |
|
92 | 92 | additional help topics: |
|
93 | 93 | |
|
94 | 94 | dates Date Formats |
|
95 | 95 | patterns File Name Patterns |
|
96 | 96 | environment Environment Variables |
|
97 | 97 | revisions Specifying Single Revisions |
|
98 | 98 | multirevs Specifying Multiple Revisions |
|
99 | 99 | diffs Diff Formats |
|
100 | 100 | templating Template Usage |
|
101 | 101 | urls URL Paths |
|
102 | 102 | |
|
103 | 103 | use "hg -v help" to show aliases and global options |
|
104 | 104 | add add the specified files on the next commit |
|
105 | 105 | addremove add all new files, delete all missing files |
|
106 | 106 | annotate show changeset information per file line |
|
107 | 107 | archive create unversioned archive of a repository revision |
|
108 | 108 | backout reverse effect of earlier changeset |
|
109 | 109 | bisect subdivision search of changesets |
|
110 | 110 | branch set or show the current branch name |
|
111 | 111 | branches list repository named branches |
|
112 | 112 | bundle create a changegroup file |
|
113 | 113 | cat output the current or given revision of files |
|
114 | 114 | clone make a copy of an existing repository |
|
115 | 115 | commit commit the specified files or all outstanding changes |
|
116 | 116 | copy mark files as copied for the next commit |
|
117 | 117 | diff diff repository (or selected files) |
|
118 | 118 | export dump the header and diffs for one or more changesets |
|
119 | 119 | grep search for a pattern in specified files and revisions |
|
120 | 120 | heads show current repository heads or show branch heads |
|
121 | 121 | help show help for a given topic or a help overview |
|
122 | 122 | identify identify the working copy or specified revision |
|
123 | 123 | import import an ordered set of patches |
|
124 | 124 | incoming show new changesets found in source |
|
125 | 125 | init create a new repository in the given directory |
|
126 | 126 | locate locate files matching specific patterns |
|
127 | 127 | log show revision history of entire repository or files |
|
128 | 128 | manifest output the current or given revision of the project manifest |
|
129 | 129 | merge merge working directory with another revision |
|
130 | 130 | outgoing show changesets not found in destination |
|
131 | parents show the parents of the working dir or revision | |
|
131 | parents show the parents of the working directory or revision | |
|
132 | 132 | paths show aliases for remote repositories |
|
133 | 133 | pull pull changes from the specified source |
|
134 | 134 | push push changes to the specified destination |
|
135 | 135 | recover roll back an interrupted transaction |
|
136 | 136 | remove remove the specified files on the next commit |
|
137 | 137 | rename rename files; equivalent of copy + remove |
|
138 | 138 | resolve retry file merges from a merge or update |
|
139 | revert restore individual files or dirs to an earlier state | |
|
139 | revert restore individual files or directories to an earlier state | |
|
140 | 140 | rollback roll back the last transaction |
|
141 | root print the root (top) of the current working dir | |
|
141 | root print the root (top) of the current working directory | |
|
142 | 142 | serve export the repository via HTTP |
|
143 | 143 | showconfig show combined config settings from all hgrc files |
|
144 | 144 | status show changed files in the working directory |
|
145 | 145 | tag add one or more tags for the current or given revision |
|
146 | 146 | tags list repository tags |
|
147 | 147 | tip show the tip revision |
|
148 | 148 | unbundle apply one or more changegroup files |
|
149 | 149 | update update working directory |
|
150 | 150 | verify verify the integrity of the repository |
|
151 | 151 | version output version and copyright information |
|
152 | 152 | |
|
153 | 153 | additional help topics: |
|
154 | 154 | |
|
155 | 155 | dates Date Formats |
|
156 | 156 | patterns File Name Patterns |
|
157 | 157 | environment Environment Variables |
|
158 | 158 | revisions Specifying Single Revisions |
|
159 | 159 | multirevs Specifying Multiple Revisions |
|
160 | 160 | diffs Diff Formats |
|
161 | 161 | templating Template Usage |
|
162 | 162 | urls URL Paths |
|
163 | 163 | hg add [OPTION]... [FILE]... |
|
164 | 164 | |
|
165 | 165 | add the specified files on the next commit |
|
166 | 166 | |
|
167 | 167 | Schedule files to be version controlled and added to the |
|
168 | 168 | repository. |
|
169 | 169 | |
|
170 | 170 | The files will be added to the repository at the next commit. To |
|
171 | 171 | undo an add before that, see hg revert. |
|
172 | 172 | |
|
173 | 173 | If no names are given, add all files to the repository. |
|
174 | 174 | |
|
175 | 175 | options: |
|
176 | 176 | |
|
177 | 177 | -I --include include names matching the given patterns |
|
178 | 178 | -X --exclude exclude names matching the given patterns |
|
179 | 179 | -n --dry-run do not perform actions, just print output |
|
180 | 180 | |
|
181 | 181 | use "hg -v help add" to show global options |
|
182 | 182 | hg add: option --skjdfks not recognized |
|
183 | 183 | hg add [OPTION]... [FILE]... |
|
184 | 184 | |
|
185 | 185 | add the specified files on the next commit |
|
186 | 186 | |
|
187 | 187 | Schedule files to be version controlled and added to the |
|
188 | 188 | repository. |
|
189 | 189 | |
|
190 | 190 | The files will be added to the repository at the next commit. To |
|
191 | 191 | undo an add before that, see hg revert. |
|
192 | 192 | |
|
193 | 193 | If no names are given, add all files to the repository. |
|
194 | 194 | |
|
195 | 195 | options: |
|
196 | 196 | |
|
197 | 197 | -I --include include names matching the given patterns |
|
198 | 198 | -X --exclude exclude names matching the given patterns |
|
199 | 199 | -n --dry-run do not perform actions, just print output |
|
200 | 200 | |
|
201 | 201 | use "hg -v help add" to show global options |
|
202 | 202 | hg diff [OPTION]... [-r REV1 [-r REV2]] [FILE]... |
|
203 | 203 | |
|
204 | 204 | diff repository (or selected files) |
|
205 | 205 | |
|
206 | 206 | Show differences between revisions for the specified files. |
|
207 | 207 | |
|
208 | 208 | Differences between files are shown using the unified diff format. |
|
209 | 209 | |
|
210 | 210 | NOTE: diff may generate unexpected results for merges, as it will |
|
211 | 211 | default to comparing against the working directory's first parent |
|
212 | 212 | changeset if no revisions are specified. |
|
213 | 213 | |
|
214 | 214 | When two revision arguments are given, then changes are shown |
|
215 | 215 | between those revisions. If only one revision is specified then |
|
216 | 216 | that revision is compared to the working directory, and, when no |
|
217 | 217 | revisions are specified, the working directory files are compared |
|
218 | 218 | to its parent. |
|
219 | 219 | |
|
220 | 220 | Without the -a option, diff will avoid generating diffs of files |
|
221 | 221 | it detects as binary. With -a, diff will generate a diff anyway, |
|
222 | 222 | probably with undesirable results. |
|
223 | 223 | |
|
224 | 224 | Use the --git option to generate diffs in the git extended diff |
|
225 | 225 | format. For more information, read 'hg help diffs'. |
|
226 | 226 | |
|
227 | 227 | options: |
|
228 | 228 | |
|
229 | 229 | -r --rev revision |
|
230 | 230 | -c --change change made by revision |
|
231 | 231 | -a --text treat all files as text |
|
232 | 232 | -g --git use git extended diff format |
|
233 | 233 | --nodates don't include dates in diff headers |
|
234 | 234 | -p --show-function show which function each change is in |
|
235 | 235 | -w --ignore-all-space ignore white space when comparing lines |
|
236 | 236 | -b --ignore-space-change ignore changes in the amount of white space |
|
237 | 237 | -B --ignore-blank-lines ignore changes whose lines are all blank |
|
238 | 238 | -U --unified number of lines of context to show |
|
239 | 239 | -I --include include names matching the given patterns |
|
240 | 240 | -X --exclude exclude names matching the given patterns |
|
241 | 241 | |
|
242 | 242 | use "hg -v help diff" to show global options |
|
243 | 243 | hg status [OPTION]... [FILE]... |
|
244 | 244 | |
|
245 | 245 | aliases: st |
|
246 | 246 | |
|
247 | 247 | show changed files in the working directory |
|
248 | 248 | |
|
249 | 249 | Show status of files in the repository. If names are given, only |
|
250 | 250 | files that match are shown. Files that are clean or ignored or |
|
251 | 251 | source of a copy/move operation, are not listed unless -c (clean), |
|
252 | 252 | -i (ignored), -C (copies) or -A is given. Unless options described |
|
253 | 253 | with "show only ..." are given, the options -mardu are used. |
|
254 | 254 | |
|
255 | 255 | Option -q/--quiet hides untracked (unknown and ignored) files |
|
256 | 256 | unless explicitly requested with -u/--unknown or -i/--ignored. |
|
257 | 257 | |
|
258 | 258 | NOTE: status may appear to disagree with diff if permissions have |
|
259 | 259 | changed or a merge has occurred. The standard diff format does not |
|
260 | 260 | report permission changes and diff only reports changes relative |
|
261 | 261 | to one merge parent. |
|
262 | 262 | |
|
263 | 263 | If one revision is given, it is used as the base revision. |
|
264 | 264 | If two revisions are given, the difference between them is shown. |
|
265 | 265 | |
|
266 | 266 | The codes used to show the status of files are: |
|
267 | 267 | M = modified |
|
268 | 268 | A = added |
|
269 | 269 | R = removed |
|
270 | 270 | C = clean |
|
271 | 271 | ! = missing, but still tracked |
|
272 | 272 | ? = not tracked |
|
273 | 273 | I = ignored |
|
274 | 274 | = the previous added file was copied from here |
|
275 | 275 | |
|
276 | 276 | options: |
|
277 | 277 | |
|
278 | 278 | -A --all show status of all files |
|
279 | 279 | -m --modified show only modified files |
|
280 | 280 | -a --added show only added files |
|
281 | 281 | -r --removed show only removed files |
|
282 | 282 | -d --deleted show only deleted (but tracked) files |
|
283 | 283 | -c --clean show only files without changes |
|
284 | 284 | -u --unknown show only unknown (not tracked) files |
|
285 | 285 | -i --ignored show only ignored files |
|
286 | 286 | -n --no-status hide status prefix |
|
287 | 287 | -C --copies show source of copied files |
|
288 | 288 | -0 --print0 end filenames with NUL, for use with xargs |
|
289 | 289 | --rev show difference from revision |
|
290 | 290 | -I --include include names matching the given patterns |
|
291 | 291 | -X --exclude exclude names matching the given patterns |
|
292 | 292 | |
|
293 | 293 | use "hg -v help status" to show global options |
|
294 | 294 | hg status [OPTION]... [FILE]... |
|
295 | 295 | |
|
296 | 296 | show changed files in the working directory |
|
297 | 297 | hg: unknown command 'foo' |
|
298 | 298 | Mercurial Distributed SCM |
|
299 | 299 | |
|
300 | 300 | basic commands: |
|
301 | 301 | |
|
302 | 302 | add add the specified files on the next commit |
|
303 | 303 | annotate show changeset information per file line |
|
304 | 304 | clone make a copy of an existing repository |
|
305 | 305 | commit commit the specified files or all outstanding changes |
|
306 | 306 | diff diff repository (or selected files) |
|
307 | 307 | export dump the header and diffs for one or more changesets |
|
308 | 308 | init create a new repository in the given directory |
|
309 | 309 | log show revision history of entire repository or files |
|
310 | 310 | merge merge working directory with another revision |
|
311 | parents show the parents of the working dir or revision | |
|
311 | parents show the parents of the working directory or revision | |
|
312 | 312 | pull pull changes from the specified source |
|
313 | 313 | push push changes to the specified destination |
|
314 | 314 | remove remove the specified files on the next commit |
|
315 | 315 | serve export the repository via HTTP |
|
316 | 316 | status show changed files in the working directory |
|
317 | 317 | update update working directory |
|
318 | 318 | |
|
319 | 319 | use "hg help" for the full list of commands or "hg -v" for details |
|
320 | 320 | hg: unknown command 'skjdfks' |
|
321 | 321 | Mercurial Distributed SCM |
|
322 | 322 | |
|
323 | 323 | basic commands: |
|
324 | 324 | |
|
325 | 325 | add add the specified files on the next commit |
|
326 | 326 | annotate show changeset information per file line |
|
327 | 327 | clone make a copy of an existing repository |
|
328 | 328 | commit commit the specified files or all outstanding changes |
|
329 | 329 | diff diff repository (or selected files) |
|
330 | 330 | export dump the header and diffs for one or more changesets |
|
331 | 331 | init create a new repository in the given directory |
|
332 | 332 | log show revision history of entire repository or files |
|
333 | 333 | merge merge working directory with another revision |
|
334 | parents show the parents of the working dir or revision | |
|
334 | parents show the parents of the working directory or revision | |
|
335 | 335 | pull pull changes from the specified source |
|
336 | 336 | push push changes to the specified destination |
|
337 | 337 | remove remove the specified files on the next commit |
|
338 | 338 | serve export the repository via HTTP |
|
339 | 339 | status show changed files in the working directory |
|
340 | 340 | update update working directory |
|
341 | 341 | |
|
342 | 342 | use "hg help" for the full list of commands or "hg -v" for details |
@@ -1,207 +1,207 b'' | |||
|
1 | 1 | % help (no mq, so no qrecord) |
|
2 | 2 | hg: unknown command 'qrecord' |
|
3 | 3 | Mercurial Distributed SCM |
|
4 | 4 | |
|
5 | 5 | basic commands: |
|
6 | 6 | |
|
7 | 7 | add add the specified files on the next commit |
|
8 | 8 | annotate show changeset information per file line |
|
9 | 9 | clone make a copy of an existing repository |
|
10 | 10 | commit commit the specified files or all outstanding changes |
|
11 | 11 | diff diff repository (or selected files) |
|
12 | 12 | export dump the header and diffs for one or more changesets |
|
13 | 13 | init create a new repository in the given directory |
|
14 | 14 | log show revision history of entire repository or files |
|
15 | 15 | merge merge working directory with another revision |
|
16 | parents show the parents of the working dir or revision | |
|
16 | parents show the parents of the working directory or revision | |
|
17 | 17 | pull pull changes from the specified source |
|
18 | 18 | push push changes to the specified destination |
|
19 | 19 | remove remove the specified files on the next commit |
|
20 | 20 | serve export the repository via HTTP |
|
21 | 21 | status show changed files in the working directory |
|
22 | 22 | update update working directory |
|
23 | 23 | |
|
24 | 24 | use "hg help" for the full list of commands or "hg -v" for details |
|
25 | 25 | % help (mq present) |
|
26 | 26 | hg qrecord [OPTION]... PATCH [FILE]... |
|
27 | 27 | |
|
28 | 28 | interactively record a new patch |
|
29 | 29 | |
|
30 | 30 | see 'hg help qnew' & 'hg help record' for more information and usage |
|
31 | 31 | |
|
32 | 32 | options: |
|
33 | 33 | |
|
34 | 34 | -e --edit edit commit message |
|
35 | 35 | -g --git use git extended diff format |
|
36 | 36 | -U --currentuser add "From: <current user>" to patch |
|
37 | 37 | -u --user add "From: <given user>" to patch |
|
38 | 38 | -D --currentdate add "Date: <current date>" to patch |
|
39 | 39 | -d --date add "Date: <given date>" to patch |
|
40 | 40 | -I --include include names matching the given patterns |
|
41 | 41 | -X --exclude exclude names matching the given patterns |
|
42 | 42 | -m --message use <text> as commit message |
|
43 | 43 | -l --logfile read commit message from <file> |
|
44 | 44 | |
|
45 | 45 | use "hg -v help qrecord" to show global options |
|
46 | 46 | % base commit |
|
47 | 47 | % changing files |
|
48 | 48 | % whole diff |
|
49 | 49 | diff -r 1057167b20ef 1.txt |
|
50 | 50 | --- a/1.txt |
|
51 | 51 | +++ b/1.txt |
|
52 | 52 | @@ -1,5 +1,5 @@ |
|
53 | 53 | 1 |
|
54 | 54 | -2 |
|
55 | 55 | +2 2 |
|
56 | 56 | 3 |
|
57 | 57 | -4 |
|
58 | 58 | +4 4 |
|
59 | 59 | 5 |
|
60 | 60 | diff -r 1057167b20ef 2.txt |
|
61 | 61 | --- a/2.txt |
|
62 | 62 | +++ b/2.txt |
|
63 | 63 | @@ -1,5 +1,5 @@ |
|
64 | 64 | a |
|
65 | 65 | -b |
|
66 | 66 | +b b |
|
67 | 67 | c |
|
68 | 68 | d |
|
69 | 69 | e |
|
70 | 70 | diff -r 1057167b20ef dir/a.txt |
|
71 | 71 | --- a/dir/a.txt |
|
72 | 72 | +++ b/dir/a.txt |
|
73 | 73 | @@ -1,4 +1,4 @@ |
|
74 | 74 | -hello world |
|
75 | 75 | +hello world! |
|
76 | 76 | |
|
77 | 77 | someone |
|
78 | 78 | up |
|
79 | 79 | % qrecord a.patch |
|
80 | 80 | diff --git a/1.txt b/1.txt |
|
81 | 81 | 2 hunks, 4 lines changed |
|
82 | 82 | examine changes to '1.txt'? [Ynsfdaq?] @@ -1,3 +1,3 @@ |
|
83 | 83 | 1 |
|
84 | 84 | -2 |
|
85 | 85 | +2 2 |
|
86 | 86 | 3 |
|
87 | 87 | record change 1/6 to '1.txt'? [Ynsfdaq?] @@ -3,3 +3,3 @@ |
|
88 | 88 | 3 |
|
89 | 89 | -4 |
|
90 | 90 | +4 4 |
|
91 | 91 | 5 |
|
92 | 92 | record change 2/6 to '1.txt'? [Ynsfdaq?] diff --git a/2.txt b/2.txt |
|
93 | 93 | 1 hunks, 2 lines changed |
|
94 | 94 | examine changes to '2.txt'? [Ynsfdaq?] @@ -1,5 +1,5 @@ |
|
95 | 95 | a |
|
96 | 96 | -b |
|
97 | 97 | +b b |
|
98 | 98 | c |
|
99 | 99 | d |
|
100 | 100 | e |
|
101 | 101 | record change 4/6 to '2.txt'? [Ynsfdaq?] diff --git a/dir/a.txt b/dir/a.txt |
|
102 | 102 | 1 hunks, 2 lines changed |
|
103 | 103 | examine changes to 'dir/a.txt'? [Ynsfdaq?] |
|
104 | 104 | % after qrecord a.patch 'tip' |
|
105 | 105 | changeset: 1:5d1ca63427ee |
|
106 | 106 | tag: qtip |
|
107 | 107 | tag: tip |
|
108 | 108 | tag: a.patch |
|
109 | 109 | tag: qbase |
|
110 | 110 | user: test |
|
111 | 111 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
112 | 112 | summary: aaa |
|
113 | 113 | |
|
114 | 114 | diff -r 1057167b20ef -r 5d1ca63427ee 1.txt |
|
115 | 115 | --- a/1.txt Thu Jan 01 00:00:00 1970 +0000 |
|
116 | 116 | +++ b/1.txt Thu Jan 01 00:00:00 1970 +0000 |
|
117 | 117 | @@ -1,5 +1,5 @@ |
|
118 | 118 | 1 |
|
119 | 119 | -2 |
|
120 | 120 | +2 2 |
|
121 | 121 | 3 |
|
122 | 122 | 4 |
|
123 | 123 | 5 |
|
124 | 124 | diff -r 1057167b20ef -r 5d1ca63427ee 2.txt |
|
125 | 125 | --- a/2.txt Thu Jan 01 00:00:00 1970 +0000 |
|
126 | 126 | +++ b/2.txt Thu Jan 01 00:00:00 1970 +0000 |
|
127 | 127 | @@ -1,5 +1,5 @@ |
|
128 | 128 | a |
|
129 | 129 | -b |
|
130 | 130 | +b b |
|
131 | 131 | c |
|
132 | 132 | d |
|
133 | 133 | e |
|
134 | 134 | |
|
135 | 135 | |
|
136 | 136 | % after qrecord a.patch 'diff' |
|
137 | 137 | diff -r 5d1ca63427ee 1.txt |
|
138 | 138 | --- a/1.txt |
|
139 | 139 | +++ b/1.txt |
|
140 | 140 | @@ -1,5 +1,5 @@ |
|
141 | 141 | 1 |
|
142 | 142 | 2 2 |
|
143 | 143 | 3 |
|
144 | 144 | -4 |
|
145 | 145 | +4 4 |
|
146 | 146 | 5 |
|
147 | 147 | diff -r 5d1ca63427ee dir/a.txt |
|
148 | 148 | --- a/dir/a.txt |
|
149 | 149 | +++ b/dir/a.txt |
|
150 | 150 | @@ -1,4 +1,4 @@ |
|
151 | 151 | -hello world |
|
152 | 152 | +hello world! |
|
153 | 153 | |
|
154 | 154 | someone |
|
155 | 155 | up |
|
156 | 156 | % qrecord b.patch |
|
157 | 157 | diff --git a/1.txt b/1.txt |
|
158 | 158 | 1 hunks, 2 lines changed |
|
159 | 159 | examine changes to '1.txt'? [Ynsfdaq?] @@ -1,5 +1,5 @@ |
|
160 | 160 | 1 |
|
161 | 161 | 2 2 |
|
162 | 162 | 3 |
|
163 | 163 | -4 |
|
164 | 164 | +4 4 |
|
165 | 165 | 5 |
|
166 | 166 | record change 1/3 to '1.txt'? [Ynsfdaq?] diff --git a/dir/a.txt b/dir/a.txt |
|
167 | 167 | 1 hunks, 2 lines changed |
|
168 | 168 | examine changes to 'dir/a.txt'? [Ynsfdaq?] @@ -1,4 +1,4 @@ |
|
169 | 169 | -hello world |
|
170 | 170 | +hello world! |
|
171 | 171 | |
|
172 | 172 | someone |
|
173 | 173 | up |
|
174 | 174 | record change 3/3 to 'dir/a.txt'? [Ynsfdaq?] |
|
175 | 175 | % after qrecord b.patch 'tip' |
|
176 | 176 | changeset: 2:b056198bf878 |
|
177 | 177 | tag: qtip |
|
178 | 178 | tag: tip |
|
179 | 179 | tag: b.patch |
|
180 | 180 | user: test |
|
181 | 181 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
182 | 182 | summary: bbb |
|
183 | 183 | |
|
184 | 184 | diff -r 5d1ca63427ee -r b056198bf878 1.txt |
|
185 | 185 | --- a/1.txt Thu Jan 01 00:00:00 1970 +0000 |
|
186 | 186 | +++ b/1.txt Thu Jan 01 00:00:00 1970 +0000 |
|
187 | 187 | @@ -1,5 +1,5 @@ |
|
188 | 188 | 1 |
|
189 | 189 | 2 2 |
|
190 | 190 | 3 |
|
191 | 191 | -4 |
|
192 | 192 | +4 4 |
|
193 | 193 | 5 |
|
194 | 194 | diff -r 5d1ca63427ee -r b056198bf878 dir/a.txt |
|
195 | 195 | --- a/dir/a.txt Thu Jan 01 00:00:00 1970 +0000 |
|
196 | 196 | +++ b/dir/a.txt Thu Jan 01 00:00:00 1970 +0000 |
|
197 | 197 | @@ -1,4 +1,4 @@ |
|
198 | 198 | -hello world |
|
199 | 199 | +hello world! |
|
200 | 200 | |
|
201 | 201 | someone |
|
202 | 202 | up |
|
203 | 203 | |
|
204 | 204 | |
|
205 | 205 | % after qrecord b.patch 'diff' |
|
206 | 206 | |
|
207 | 207 | % --- end --- |
@@ -1,28 +1,28 b'' | |||
|
1 | 1 | adding a |
|
2 | 2 | 0: a |
|
3 | 3 | hg: unknown command 'an' |
|
4 | 4 | Mercurial Distributed SCM |
|
5 | 5 | |
|
6 | 6 | basic commands: |
|
7 | 7 | |
|
8 | 8 | add add the specified files on the next commit |
|
9 | 9 | annotate show changeset information per file line |
|
10 | 10 | clone make a copy of an existing repository |
|
11 | 11 | commit commit the specified files or all outstanding changes |
|
12 | 12 | diff diff repository (or selected files) |
|
13 | 13 | export dump the header and diffs for one or more changesets |
|
14 | 14 | init create a new repository in the given directory |
|
15 | 15 | log show revision history of entire repository or files |
|
16 | 16 | merge merge working directory with another revision |
|
17 | parents show the parents of the working dir or revision | |
|
17 | parents show the parents of the working directory or revision | |
|
18 | 18 | pull pull changes from the specified source |
|
19 | 19 | push push changes to the specified destination |
|
20 | 20 | remove remove the specified files on the next commit |
|
21 | 21 | serve export the repository via HTTP |
|
22 | 22 | status show changed files in the working directory |
|
23 | 23 | update update working directory |
|
24 | 24 | |
|
25 | 25 | use "hg help" for the full list of commands or "hg -v" for details |
|
26 | 26 | 0: a |
|
27 | 27 | % should succeed - up is an alias, not an abbreviation |
|
28 | 28 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved |
General Comments 0
You need to be logged in to leave comments.
Login now