commands: graft uses a transaction (issue3628)

Alexander Becher alexander.becher at rud-steuerungstechnik.de
Fri Aug 12 04:21:05 EDT 2016


* Pierre-Yves David [11.08.2016 18:08]
> On 08/10/2016 12:39 PM, Alexander Becher wrote:
>> diff -r db0095c83344 -r 7aa594597cb3 mercurial/commands.py
>> --- a/mercurial/commands.py     Mon Jul 18 22:22:38 2016 +0200
>> +++ b/mercurial/commands.py     Fri Jul 29 11:02:45 2016 +0200
>> @@ -4085,7 +4085,7 @@
>>
>>      Returns 0 on successful completion.
>>      '''
>> -    with repo.wlock():
>> +    with repo.wlock(), repo.lock(), repo.transaction('graft'):
>>          return _dograft(ui, repo, *revs, **opts)
>>
>>  def _dograft(ui, repo, *revs, **opts):
> 
> This won't do. If you do this, the failure of one graft will rollback
> all the previous (successful one). We need much more advance transaction
> mechanisme to solve this issue. (sorry)

Well, that's what I want, isn't it? Say, I graft a number of changesets,
then realise that I've been grafting them to the wrong branch, then I'd
like to remove all changesets that were newly created by the graft, like
this:

  $ hg par
  4710:ba420e33
  $ hg graft 'branch(issue3628)'
  grafting changeset 4711
  grafting changeset 4712
  grafting changeset 4713
  $ hg branch
  wrong_branch
  $ hg rollback
  undo graft (remove changeset 4714, 4715, 4716)
  working directory now based on 4710
  $ hg up correct_branch
  $ hg graft 'branch(issue3628)'
  grafting changeset 4711
  grafting changeset 4712
  grafting changeset 4713
  $ hg par
  4716 (grafted from 4713)

Reasoning: I did a command, hg graft, then realised it was a mistake,
and want to undo all the changes it made to my repository.

>> Also, do I need both repo.wlock() and repo.lock()? Without repo.lock(),
>> repo.transaction('graft') raises a RuntimeError('programming error:
>> transaction requires locking').
> 
> Then you probably needs the repo.lock ;-)

Yes, but do I still need the repo.wlock? Or does repo.lock imply repo.wlock?

-- 
Alexander Becher


More information about the Mercurial-devel mailing list