2222 cont = True |
2222 cont = True |
2223 if revs: |
2223 if revs: |
2224 raise error.Abort(_("can't specify --continue and revisions")) |
2224 raise error.Abort(_("can't specify --continue and revisions")) |
2225 # read in unfinished revisions |
2225 # read in unfinished revisions |
2226 if graftstate.exists(): |
2226 if graftstate.exists(): |
2227 nodes = _readgraftstate(repo)['nodes'] |
2227 nodes = _readgraftstate(repo, graftstate)['nodes'] |
2228 revs = [repo[node].rev() for node in nodes] |
2228 revs = [repo[node].rev() for node in nodes] |
2229 else: |
2229 else: |
2230 cmdutil.wrongtooltocontinue(repo, _('graft')) |
2230 cmdutil.wrongtooltocontinue(repo, _('graft')) |
2231 else: |
2231 else: |
2232 if not revs: |
2232 if not revs: |
2349 finally: |
2349 finally: |
2350 repo.ui.setconfig('ui', 'forcemerge', '', 'graft') |
2350 repo.ui.setconfig('ui', 'forcemerge', '', 'graft') |
2351 # report any conflicts |
2351 # report any conflicts |
2352 if stats.unresolvedcount > 0: |
2352 if stats.unresolvedcount > 0: |
2353 # write out state for --continue |
2353 # write out state for --continue |
2354 nodelines = [repo[rev].hex() + "\n" for rev in revs[pos:]] |
2354 nodes = [repo[rev].hex() for rev in revs[pos:]] |
2355 repo.vfs.write('graftstate', ''.join(nodelines)) |
2355 statedata = {'nodes': nodes} |
|
2356 stateversion = 1 |
|
2357 graftstate.save(stateversion, statedata) |
2356 extra = '' |
2358 extra = '' |
2357 if opts.get('user'): |
2359 if opts.get('user'): |
2358 extra += ' --user %s' % procutil.shellquote(opts['user']) |
2360 extra += ' --user %s' % procutil.shellquote(opts['user']) |
2359 if opts.get('date'): |
2361 if opts.get('date'): |
2360 extra += ' --date %s' % procutil.shellquote(opts['date']) |
2362 extra += ' --date %s' % procutil.shellquote(opts['date']) |
2379 if not opts.get('dry_run'): |
2381 if not opts.get('dry_run'): |
2380 repo.vfs.unlinkpath('graftstate', ignoremissing=True) |
2382 repo.vfs.unlinkpath('graftstate', ignoremissing=True) |
2381 |
2383 |
2382 return 0 |
2384 return 0 |
2383 |
2385 |
2384 def _readgraftstate(repo): |
2386 def _readgraftstate(repo, graftstate): |
2385 """read the graft state file and return a dict of the data stored in it""" |
2387 """read the graft state file and return a dict of the data stored in it""" |
2386 nodes = repo.vfs.read('graftstate').splitlines() |
2388 try: |
2387 return {'nodes': nodes} |
2389 return graftstate.read() |
|
2390 except error.CorruptedState: |
|
2391 nodes = repo.vfs.read('graftstate').splitlines() |
|
2392 return {'nodes': nodes} |
2388 |
2393 |
2389 @command('grep', |
2394 @command('grep', |
2390 [('0', 'print0', None, _('end fields with NUL')), |
2395 [('0', 'print0', None, _('end fields with NUL')), |
2391 ('', 'all', None, _('print all revisions that match')), |
2396 ('', 'all', None, _('print all revisions that match')), |
2392 ('a', 'text', None, _('treat all files as text')), |
2397 ('a', 'text', None, _('treat all files as text')), |