Mercurial > hg
annotate hgext/imerge.py @ 5111:12930b97a729
imerge: gussy up dispatcher to support subcommand opts.
Add -n, --resolved, --unresolved to status.
author | Brendan Cully <brendan@kublai.com> |
---|---|
date | Sat, 04 Aug 2007 12:26:48 -0700 |
parents | 420e1166a876 |
children | d4fa6bafc43a |
rev | line source |
---|---|
5044 | 1 # Copyright (C) 2007 Brendan Cully <brendan@kublai.com> |
2 # Published under the GNU GPL | |
3 | |
4 ''' | |
5 imerge - interactive merge | |
6 ''' | |
7 | |
8 from mercurial.i18n import _ | |
9 from mercurial.node import * | |
5111
12930b97a729
imerge: gussy up dispatcher to support subcommand opts.
Brendan Cully <brendan@kublai.com>
parents:
5110
diff
changeset
|
10 from mercurial import commands, cmdutil, fancyopts, hg, merge, util |
5044 | 11 import os, tarfile |
12 | |
13 class InvalidStateFileException(Exception): pass | |
14 | |
15 class ImergeStateFile(object): | |
16 def __init__(self, im): | |
17 self.im = im | |
18 | |
19 def save(self, dest): | |
20 tf = tarfile.open(dest, 'w:gz') | |
21 | |
22 st = os.path.join(self.im.path, 'status') | |
23 tf.add(st, os.path.join('.hg', 'imerge', 'status')) | |
24 | |
25 for f in self.im.resolved: | |
5109 | 26 (fd, fo) = self.im.conflicts[f] |
27 abssrc = self.im.repo.wjoin(fd) | |
28 tf.add(abssrc, fd) | |
5044 | 29 |
30 tf.close() | |
31 | |
32 def load(self, source): | |
33 wlock = self.im.repo.wlock() | |
34 lock = self.im.repo.lock() | |
35 | |
36 tf = tarfile.open(source, 'r') | |
37 contents = tf.getnames() | |
38 statusfile = os.path.join('.hg', 'imerge', 'status') | |
39 if statusfile not in contents: | |
40 raise InvalidStateFileException('no status file') | |
41 | |
42 tf.extract(statusfile, self.im.repo.root) | |
5109 | 43 p1, p2 = self.im.load() |
44 if self.im.repo.dirstate.parents()[0] != p1.node(): | |
45 hg.clean(self.im.repo, p1.node()) | |
46 self.im.start(p2.node()) | |
5055
56d48aed1f69
imerge: tarfile.extractall is only available in python2.5
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
5054
diff
changeset
|
47 for tarinfo in tf: |
56d48aed1f69
imerge: tarfile.extractall is only available in python2.5
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
5054
diff
changeset
|
48 tf.extract(tarinfo, self.im.repo.root) |
5044 | 49 self.im.load() |
50 | |
51 class Imerge(object): | |
52 def __init__(self, ui, repo): | |
53 self.ui = ui | |
54 self.repo = repo | |
55 | |
56 self.path = repo.join('imerge') | |
57 self.opener = util.opener(self.path) | |
58 | |
5109 | 59 self.wctx = self.repo.workingctx() |
5044 | 60 self.conflicts = {} |
61 self.resolved = [] | |
62 | |
63 def merging(self): | |
5109 | 64 return len(self.wctx.parents()) > 1 |
5044 | 65 |
66 def load(self): | |
67 # status format. \0-delimited file, fields are | |
68 # p1, p2, conflict count, conflict filenames, resolved filenames | |
5054
ec70fd08e16c
Update imerge for new filemerge interface
Brendan Cully <brendan@kublai.com>
parents:
5044
diff
changeset
|
69 # conflict filenames are tuples of localname, remoteorig, remotenew |
5044 | 70 |
71 statusfile = self.opener('status') | |
72 | |
73 status = statusfile.read().split('\0') | |
74 if len(status) < 3: | |
75 raise util.Abort('invalid imerge status file') | |
76 | |
77 try: | |
5109 | 78 parents = [self.repo.changectx(n) for n in status[:2]] |
5044 | 79 except LookupError: |
80 raise util.Abort('merge parent %s not in repository' % short(p)) | |
81 | |
82 status = status[2:] | |
5054
ec70fd08e16c
Update imerge for new filemerge interface
Brendan Cully <brendan@kublai.com>
parents:
5044
diff
changeset
|
83 conflicts = int(status.pop(0)) * 3 |
5044 | 84 self.resolved = status[conflicts:] |
5054
ec70fd08e16c
Update imerge for new filemerge interface
Brendan Cully <brendan@kublai.com>
parents:
5044
diff
changeset
|
85 for i in xrange(0, conflicts, 3): |
ec70fd08e16c
Update imerge for new filemerge interface
Brendan Cully <brendan@kublai.com>
parents:
5044
diff
changeset
|
86 self.conflicts[status[i]] = (status[i+1], status[i+2]) |
5044 | 87 |
5109 | 88 return parents |
89 | |
5044 | 90 def save(self): |
91 lock = self.repo.lock() | |
92 | |
93 if not os.path.isdir(self.path): | |
94 os.mkdir(self.path) | |
5056
34a54cc5df1b
imerge: sorted() is only available in python2.4 and above
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5055
diff
changeset
|
95 statusfile = self.opener('status', 'wb') |
5044 | 96 |
5109 | 97 out = [hex(n.node()) for n in self.wctx.parents()] |
5044 | 98 out.append(str(len(self.conflicts))) |
5056
34a54cc5df1b
imerge: sorted() is only available in python2.4 and above
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5055
diff
changeset
|
99 conflicts = self.conflicts.items() |
34a54cc5df1b
imerge: sorted() is only available in python2.4 and above
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5055
diff
changeset
|
100 conflicts.sort() |
34a54cc5df1b
imerge: sorted() is only available in python2.4 and above
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5055
diff
changeset
|
101 for fw, fd_fo in conflicts: |
34a54cc5df1b
imerge: sorted() is only available in python2.4 and above
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5055
diff
changeset
|
102 out.append(fw) |
34a54cc5df1b
imerge: sorted() is only available in python2.4 and above
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5055
diff
changeset
|
103 out.extend(fd_fo) |
5044 | 104 out.extend(self.resolved) |
105 | |
5056
34a54cc5df1b
imerge: sorted() is only available in python2.4 and above
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5055
diff
changeset
|
106 statusfile.write('\0'.join(out)) |
5044 | 107 |
108 def remaining(self): | |
109 return [f for f in self.conflicts if f not in self.resolved] | |
110 | |
111 def filemerge(self, fn): | |
112 wlock = self.repo.wlock() | |
113 | |
5054
ec70fd08e16c
Update imerge for new filemerge interface
Brendan Cully <brendan@kublai.com>
parents:
5044
diff
changeset
|
114 (fd, fo) = self.conflicts[fn] |
5109 | 115 p2 = self.wctx.parents()[1] |
116 return merge.filemerge(self.repo, fn, fd, fo, self.wctx, p2) | |
5044 | 117 |
118 def start(self, rev=None): | |
119 _filemerge = merge.filemerge | |
5054
ec70fd08e16c
Update imerge for new filemerge interface
Brendan Cully <brendan@kublai.com>
parents:
5044
diff
changeset
|
120 def filemerge(repo, fw, fd, fo, wctx, mctx): |
ec70fd08e16c
Update imerge for new filemerge interface
Brendan Cully <brendan@kublai.com>
parents:
5044
diff
changeset
|
121 self.conflicts[fw] = (fd, fo) |
5044 | 122 |
123 merge.filemerge = filemerge | |
124 commands.merge(self.ui, self.repo, rev=rev) | |
125 merge.filemerge = _filemerge | |
126 | |
5109 | 127 self.wctx = self.repo.workingctx() |
5044 | 128 self.save() |
129 | |
130 def resume(self): | |
131 self.load() | |
132 | |
133 dp = self.repo.dirstate.parents() | |
5109 | 134 p1, p2 = self.wctx.parents() |
135 if p1.node() != dp[0] or p2.node() != dp[1]: | |
5044 | 136 raise util.Abort('imerge state does not match working directory') |
137 | |
138 def next(self): | |
139 remaining = self.remaining() | |
140 return remaining and remaining[0] | |
141 | |
142 def resolve(self, files): | |
143 resolved = dict.fromkeys(self.resolved) | |
144 for fn in files: | |
145 if fn not in self.conflicts: | |
146 raise util.Abort('%s is not in the merge set' % fn) | |
147 resolved[fn] = True | |
5056
34a54cc5df1b
imerge: sorted() is only available in python2.4 and above
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5055
diff
changeset
|
148 self.resolved = resolved.keys() |
34a54cc5df1b
imerge: sorted() is only available in python2.4 and above
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5055
diff
changeset
|
149 self.resolved.sort() |
5044 | 150 self.save() |
151 return 0 | |
152 | |
153 def unresolve(self, files): | |
154 resolved = dict.fromkeys(self.resolved) | |
155 for fn in files: | |
156 if fn not in resolved: | |
157 raise util.Abort('%s is not resolved' % fn) | |
158 del resolved[fn] | |
5056
34a54cc5df1b
imerge: sorted() is only available in python2.4 and above
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5055
diff
changeset
|
159 self.resolved = resolved.keys() |
34a54cc5df1b
imerge: sorted() is only available in python2.4 and above
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5055
diff
changeset
|
160 self.resolved.sort() |
5044 | 161 self.save() |
162 return 0 | |
163 | |
164 def pickle(self, dest): | |
165 '''write current merge state to file to be resumed elsewhere''' | |
166 state = ImergeStateFile(self) | |
167 return state.save(dest) | |
168 | |
169 def unpickle(self, source): | |
170 '''read merge state from file''' | |
171 state = ImergeStateFile(self) | |
172 return state.load(source) | |
173 | |
174 def load(im, source): | |
175 if im.merging(): | |
176 raise util.Abort('there is already a merge in progress ' | |
177 '(update -C <rev> to abort it)' ) | |
178 m, a, r, d = im.repo.status()[:4] | |
179 if m or a or r or d: | |
180 raise util.Abort('working directory has uncommitted changes') | |
181 | |
182 rc = im.unpickle(source) | |
183 if not rc: | |
5111
12930b97a729
imerge: gussy up dispatcher to support subcommand opts.
Brendan Cully <brendan@kublai.com>
parents:
5110
diff
changeset
|
184 status(im) |
5044 | 185 return rc |
186 | |
187 def merge_(im, filename=None): | |
188 if not filename: | |
189 filename = im.next() | |
190 if not filename: | |
191 im.ui.write('all conflicts resolved\n') | |
192 return 0 | |
193 | |
194 rc = im.filemerge(filename) | |
195 if not rc: | |
196 im.resolve([filename]) | |
197 if not im.next(): | |
198 im.ui.write('all conflicts resolved\n') | |
199 return 0 | |
200 return rc | |
201 | |
202 def next(im): | |
203 n = im.next() | |
204 if n: | |
205 im.ui.write('%s\n' % n) | |
206 else: | |
207 im.ui.write('all conflicts resolved\n') | |
208 return 0 | |
209 | |
210 def resolve(im, *files): | |
211 if not files: | |
212 raise util.Abort('resolve requires at least one filename') | |
213 return im.resolve(files) | |
214 | |
215 def save(im, dest): | |
216 return im.pickle(dest) | |
217 | |
5111
12930b97a729
imerge: gussy up dispatcher to support subcommand opts.
Brendan Cully <brendan@kublai.com>
parents:
5110
diff
changeset
|
218 def status(im, **opts): |
12930b97a729
imerge: gussy up dispatcher to support subcommand opts.
Brendan Cully <brendan@kublai.com>
parents:
5110
diff
changeset
|
219 if not opts.get('resolved') and not opts.get('unresolved'): |
12930b97a729
imerge: gussy up dispatcher to support subcommand opts.
Brendan Cully <brendan@kublai.com>
parents:
5110
diff
changeset
|
220 opts['resolved'] = True |
12930b97a729
imerge: gussy up dispatcher to support subcommand opts.
Brendan Cully <brendan@kublai.com>
parents:
5110
diff
changeset
|
221 opts['unresolved'] = True |
12930b97a729
imerge: gussy up dispatcher to support subcommand opts.
Brendan Cully <brendan@kublai.com>
parents:
5110
diff
changeset
|
222 |
12930b97a729
imerge: gussy up dispatcher to support subcommand opts.
Brendan Cully <brendan@kublai.com>
parents:
5110
diff
changeset
|
223 if im.ui.verbose: |
12930b97a729
imerge: gussy up dispatcher to support subcommand opts.
Brendan Cully <brendan@kublai.com>
parents:
5110
diff
changeset
|
224 p1, p2 = [short(p.node()) for p in im.wctx.parents()] |
12930b97a729
imerge: gussy up dispatcher to support subcommand opts.
Brendan Cully <brendan@kublai.com>
parents:
5110
diff
changeset
|
225 im.ui.note(_('merging %s and %s\n') % (p1, p2)) |
12930b97a729
imerge: gussy up dispatcher to support subcommand opts.
Brendan Cully <brendan@kublai.com>
parents:
5110
diff
changeset
|
226 |
12930b97a729
imerge: gussy up dispatcher to support subcommand opts.
Brendan Cully <brendan@kublai.com>
parents:
5110
diff
changeset
|
227 conflicts = im.conflicts.keys() |
12930b97a729
imerge: gussy up dispatcher to support subcommand opts.
Brendan Cully <brendan@kublai.com>
parents:
5110
diff
changeset
|
228 conflicts.sort() |
12930b97a729
imerge: gussy up dispatcher to support subcommand opts.
Brendan Cully <brendan@kublai.com>
parents:
5110
diff
changeset
|
229 remaining = dict.fromkeys(im.remaining()) |
12930b97a729
imerge: gussy up dispatcher to support subcommand opts.
Brendan Cully <brendan@kublai.com>
parents:
5110
diff
changeset
|
230 st = [] |
12930b97a729
imerge: gussy up dispatcher to support subcommand opts.
Brendan Cully <brendan@kublai.com>
parents:
5110
diff
changeset
|
231 for fn in conflicts: |
12930b97a729
imerge: gussy up dispatcher to support subcommand opts.
Brendan Cully <brendan@kublai.com>
parents:
5110
diff
changeset
|
232 if opts.get('no_status'): |
12930b97a729
imerge: gussy up dispatcher to support subcommand opts.
Brendan Cully <brendan@kublai.com>
parents:
5110
diff
changeset
|
233 mode = '' |
12930b97a729
imerge: gussy up dispatcher to support subcommand opts.
Brendan Cully <brendan@kublai.com>
parents:
5110
diff
changeset
|
234 elif fn in remaining: |
12930b97a729
imerge: gussy up dispatcher to support subcommand opts.
Brendan Cully <brendan@kublai.com>
parents:
5110
diff
changeset
|
235 mode = 'U ' |
12930b97a729
imerge: gussy up dispatcher to support subcommand opts.
Brendan Cully <brendan@kublai.com>
parents:
5110
diff
changeset
|
236 else: |
12930b97a729
imerge: gussy up dispatcher to support subcommand opts.
Brendan Cully <brendan@kublai.com>
parents:
5110
diff
changeset
|
237 mode = 'R ' |
12930b97a729
imerge: gussy up dispatcher to support subcommand opts.
Brendan Cully <brendan@kublai.com>
parents:
5110
diff
changeset
|
238 if ((opts.get('resolved') and fn not in remaining) |
12930b97a729
imerge: gussy up dispatcher to support subcommand opts.
Brendan Cully <brendan@kublai.com>
parents:
5110
diff
changeset
|
239 or (opts.get('unresolved') and fn in remaining)): |
12930b97a729
imerge: gussy up dispatcher to support subcommand opts.
Brendan Cully <brendan@kublai.com>
parents:
5110
diff
changeset
|
240 st.append((mode, fn)) |
12930b97a729
imerge: gussy up dispatcher to support subcommand opts.
Brendan Cully <brendan@kublai.com>
parents:
5110
diff
changeset
|
241 st.sort() |
12930b97a729
imerge: gussy up dispatcher to support subcommand opts.
Brendan Cully <brendan@kublai.com>
parents:
5110
diff
changeset
|
242 for (mode, fn) in st: |
12930b97a729
imerge: gussy up dispatcher to support subcommand opts.
Brendan Cully <brendan@kublai.com>
parents:
5110
diff
changeset
|
243 if im.ui.verbose: |
12930b97a729
imerge: gussy up dispatcher to support subcommand opts.
Brendan Cully <brendan@kublai.com>
parents:
5110
diff
changeset
|
244 fo, fd = im.conflicts[fn] |
12930b97a729
imerge: gussy up dispatcher to support subcommand opts.
Brendan Cully <brendan@kublai.com>
parents:
5110
diff
changeset
|
245 if fd != fn: |
12930b97a729
imerge: gussy up dispatcher to support subcommand opts.
Brendan Cully <brendan@kublai.com>
parents:
5110
diff
changeset
|
246 fn = '%s (%s)' % (fn, fd) |
12930b97a729
imerge: gussy up dispatcher to support subcommand opts.
Brendan Cully <brendan@kublai.com>
parents:
5110
diff
changeset
|
247 im.ui.write('%s%s\n' % (mode, fn)) |
12930b97a729
imerge: gussy up dispatcher to support subcommand opts.
Brendan Cully <brendan@kublai.com>
parents:
5110
diff
changeset
|
248 if opts.get('unresolved') and not remaining: |
12930b97a729
imerge: gussy up dispatcher to support subcommand opts.
Brendan Cully <brendan@kublai.com>
parents:
5110
diff
changeset
|
249 im.ui.write(_('all conflicts resolved\n')) |
12930b97a729
imerge: gussy up dispatcher to support subcommand opts.
Brendan Cully <brendan@kublai.com>
parents:
5110
diff
changeset
|
250 |
5044 | 251 return 0 |
252 | |
253 def unresolve(im, *files): | |
254 if not files: | |
255 raise util.Abort('unresolve requires at least one filename') | |
256 return im.unresolve(files) | |
257 | |
258 subcmdtable = { | |
5111
12930b97a729
imerge: gussy up dispatcher to support subcommand opts.
Brendan Cully <brendan@kublai.com>
parents:
5110
diff
changeset
|
259 'load': (load, []), |
12930b97a729
imerge: gussy up dispatcher to support subcommand opts.
Brendan Cully <brendan@kublai.com>
parents:
5110
diff
changeset
|
260 'merge': (merge_, []), |
12930b97a729
imerge: gussy up dispatcher to support subcommand opts.
Brendan Cully <brendan@kublai.com>
parents:
5110
diff
changeset
|
261 'next': (next, []), |
12930b97a729
imerge: gussy up dispatcher to support subcommand opts.
Brendan Cully <brendan@kublai.com>
parents:
5110
diff
changeset
|
262 'resolve': (resolve, []), |
12930b97a729
imerge: gussy up dispatcher to support subcommand opts.
Brendan Cully <brendan@kublai.com>
parents:
5110
diff
changeset
|
263 'save': (save, []), |
12930b97a729
imerge: gussy up dispatcher to support subcommand opts.
Brendan Cully <brendan@kublai.com>
parents:
5110
diff
changeset
|
264 'status': (status, |
12930b97a729
imerge: gussy up dispatcher to support subcommand opts.
Brendan Cully <brendan@kublai.com>
parents:
5110
diff
changeset
|
265 [('n', 'no-status', None, _('hide status prefix')), |
12930b97a729
imerge: gussy up dispatcher to support subcommand opts.
Brendan Cully <brendan@kublai.com>
parents:
5110
diff
changeset
|
266 ('', 'resolved', None, _('only show resolved conflicts')), |
12930b97a729
imerge: gussy up dispatcher to support subcommand opts.
Brendan Cully <brendan@kublai.com>
parents:
5110
diff
changeset
|
267 ('', 'unresolved', None, _('only show unresolved conflicts'))]), |
12930b97a729
imerge: gussy up dispatcher to support subcommand opts.
Brendan Cully <brendan@kublai.com>
parents:
5110
diff
changeset
|
268 'unresolve': (unresolve, []) |
5044 | 269 } |
270 | |
271 def dispatch(im, args, opts): | |
272 def complete(s, choices): | |
273 candidates = [] | |
274 for choice in choices: | |
275 if choice.startswith(s): | |
276 candidates.append(choice) | |
277 return candidates | |
278 | |
5111
12930b97a729
imerge: gussy up dispatcher to support subcommand opts.
Brendan Cully <brendan@kublai.com>
parents:
5110
diff
changeset
|
279 c, args = args[0], list(args[1:]) |
5044 | 280 cmd = complete(c, subcmdtable.keys()) |
281 if not cmd: | |
282 raise cmdutil.UnknownCommand('imerge ' + c) | |
283 if len(cmd) > 1: | |
5056
34a54cc5df1b
imerge: sorted() is only available in python2.4 and above
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5055
diff
changeset
|
284 cmd.sort() |
34a54cc5df1b
imerge: sorted() is only available in python2.4 and above
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5055
diff
changeset
|
285 raise cmdutil.AmbiguousCommand('imerge ' + c, cmd) |
5044 | 286 cmd = cmd[0] |
287 | |
5111
12930b97a729
imerge: gussy up dispatcher to support subcommand opts.
Brendan Cully <brendan@kublai.com>
parents:
5110
diff
changeset
|
288 func, optlist = subcmdtable[cmd] |
12930b97a729
imerge: gussy up dispatcher to support subcommand opts.
Brendan Cully <brendan@kublai.com>
parents:
5110
diff
changeset
|
289 opts = {} |
5044 | 290 try: |
5111
12930b97a729
imerge: gussy up dispatcher to support subcommand opts.
Brendan Cully <brendan@kublai.com>
parents:
5110
diff
changeset
|
291 args = fancyopts.fancyopts(args, optlist, opts) |
12930b97a729
imerge: gussy up dispatcher to support subcommand opts.
Brendan Cully <brendan@kublai.com>
parents:
5110
diff
changeset
|
292 return func(im, *args, **opts) |
12930b97a729
imerge: gussy up dispatcher to support subcommand opts.
Brendan Cully <brendan@kublai.com>
parents:
5110
diff
changeset
|
293 except fancyopts.getopt.GetoptError, inst: |
12930b97a729
imerge: gussy up dispatcher to support subcommand opts.
Brendan Cully <brendan@kublai.com>
parents:
5110
diff
changeset
|
294 raise cmdutil.ParseError('imerge', '%s: %s' % (cmd, inst)) |
5044 | 295 except TypeError: |
5111
12930b97a729
imerge: gussy up dispatcher to support subcommand opts.
Brendan Cully <brendan@kublai.com>
parents:
5110
diff
changeset
|
296 raise cmdutil.ParseError('imerge', _('%s: invalid arguments') % cmd) |
5044 | 297 |
298 def imerge(ui, repo, *args, **opts): | |
299 '''interactive merge | |
300 | |
301 imerge lets you split a merge into pieces. When you start a merge | |
302 with imerge, the names of all files with conflicts are recorded. | |
303 You can then merge any of these files, and if the merge is | |
304 successful, they will be marked as resolved. When all files are | |
305 resolved, the merge is complete. | |
306 | |
307 If no merge is in progress, hg imerge [rev] will merge the working | |
308 directory with rev (defaulting to the other head if the repository | |
309 only has two heads). You may also resume a saved merge with | |
310 hg imerge load <file>. | |
311 | |
312 If a merge is in progress, hg imerge will default to merging the | |
313 next unresolved file. | |
314 | |
315 The following subcommands are available: | |
316 | |
317 status: | |
318 show the current state of the merge | |
319 next: | |
320 show the next unresolved file merge | |
321 merge [<file>]: | |
322 merge <file>. If the file merge is successful, the file will be | |
323 recorded as resolved. If no file is given, the next unresolved | |
324 file will be merged. | |
325 resolve <file>...: | |
326 mark files as successfully merged | |
327 unresolve <file>...: | |
328 mark files as requiring merging. | |
329 save <file>: | |
330 save the state of the merge to a file to be resumed elsewhere | |
331 load <file>: | |
332 load the state of the merge from a file created by save | |
333 ''' | |
334 | |
335 im = Imerge(ui, repo) | |
336 | |
337 if im.merging(): | |
338 im.resume() | |
339 else: | |
340 rev = opts.get('rev') | |
341 if rev and args: | |
342 raise util.Abort('please specify just one revision') | |
343 | |
344 if len(args) == 2 and args[0] == 'load': | |
345 pass | |
346 else: | |
347 if args: | |
348 rev = args[0] | |
349 im.start(rev=rev) | |
350 args = ['status'] | |
351 | |
352 if not args: | |
353 args = ['merge'] | |
354 | |
355 return dispatch(im, args, opts) | |
356 | |
357 cmdtable = { | |
358 '^imerge': | |
359 (imerge, | |
360 [('r', 'rev', '', _('revision to merge'))], 'hg imerge [command]') | |
361 } |