Re: Add button to conflicts window

2 views
Skip to first unread message

Alexander Belchenko

unread,
Feb 12, 2012, 3:07:02 PM2/12/12
to Gil Idelson, qb...@googlegroups.com
Gil Idelson пишет:
> Hi
>
> I want to add a new button to conflicts window that will enable me to
> take "other" copy of all selected files , instead of manually run merge
> tool on each file. (or a right click option on selcted files)
>
> I know i can go through the qbzr source code and find how to do it it
> myself , but I hope you will give me some pointers.
> Is it easy way to do it , like hooks in bazaar?
>
> Thanks.
>
> P.S i wanted to ask this question on launchpad but its seems not active
> in for few years now (on qbzr part)

I've FW'd your mail to QBzr mailing list / discussion group. I think
it'll be better to keep conversation there. I'm not sure what do you
mean "its seems not active in for few years now (on qbzr part)".

--
All the dude wanted was his rug back

Alexander Belchenko

unread,
Feb 12, 2012, 3:36:46 PM2/12/12
to qb...@googlegroups.com, Gil Idelson
Alexander Belchenko пишет:

> Gil Idelson пишет:
>> Hi
>>
>> I want to add a new button to conflicts window that will enable me to
>> take "other" copy of all selected files , instead of manually run merge
>> tool on each file. (or a right click option on selcted files)
>>
>> I know i can go through the qbzr source code and find how to do it it
>> myself , but I hope you will give me some pointers.
>> Is it easy way to do it , like hooks in bazaar?

I think the right way and the easisest way to accomplish what you want
is: add new entry to context menu and provide corresponding method.
You should look at qbzr/lib/conflicts.py source, method
create_context_menu is dedicated to build context menu. You may use
"Mark as resolved" entry as example:

self.context_menu.addAction(gettext("Mark as &resolved"),
self.mark_item_as_resolved)

The real work happens in mark_item_as_resolved method, which uses
bzrlib method to resolve conflicts. I think it should be possible to
do similar thing with new --take-this / --take-other support in bzr
itself.

I'd recommend you add 2 new entries to context menu:

Use "this" version
Use "other" version

or something like that and implement both variants. I think if you'll
figure out how to implement "use other" it should be pretty
straightforward to implement and complement variant.

Alexander Belchenko

unread,
Feb 12, 2012, 7:24:25 PM2/12/12
to qb...@googlegroups.com, Gil Idelson
Alexander Belchenko пишет:

Yeah, look at bzrlib/conflicts.py. You should be able to use very
similar code to mark_item_as_resolved for new context menu entries,
changing resolve call to:

resolve(self.wt, file_names, action='take_this')
and
resolve(self.wt, file_names, action='take_other')

Idelson, Gil

unread,
Feb 13, 2012, 3:34:59 AM2/13/12
to Alexander Belchenko, qb...@googlegroups.com
Thanks a lot.

I did it and it works!

Do I have a way to do it without copy paste it to any new qbzr version?

P.S by not active for few years , I meant that the "Answers" part on launchpad don’t contains any recent questions (in oppose to bazaar or bazaar explorer)

best regards ,
Gil Idelson
RT/Embedded SW Engineer
Microsemi Corporation - AMSG
1 Hanagar St. P.O.Box 7220
Hod Hasharon, 45421, Israel
Phone:  +972-9-7755100 Ext 271
Fax:        +972-9-7755111

Alexander Belchenko

unread,
Feb 13, 2012, 4:33:54 AM2/13/12
to qb...@googlegroups.com
Idelson, Gil пишет:

> Thanks a lot.
>
> I did it and it works!
>
> Do I have a way to do it without copy paste it to any new qbzr version?

Well, I think the best way is to refactor the common code to helper
method like this:

def _resolve_action(self, action):
items = self.conflicts_list.selectedItems()
file_names = []
for item in items:
# XXX why we need to use file_id -> path conversion if we
already have filename???
# this conversion fails in the case when user removed file
or directory
# which marked as conflicted (e.g. in missing parent
conflict case).
#~file_id = str(item.data(0, QtCore.Qt.UserRole).toString())
#~file_names.append(self.wt.id2path(file_id))
file_names.append(unicode(item.text(0)))
resolve(self.wt, file_names, action=action)
self.refresh()

And then call it from all menu entries callbacks as

def mark_item_as_resolved(self):
self._resolve_action("done")

def take_this(self):
self._resolve_action("take_this")

def take_other(self):
self._resolve_action("take_other")

I think that would do the job. I'll be happy to accept your patch soon :-)

Alexander Belchenko

unread,
Feb 13, 2012, 4:39:23 AM2/13/12
to Idelson, Gil, qb...@googlegroups.com
Idelson, Gil пишет:
> Hi
> I have another question :
> Now that I have 'take-this' and 'take-other' options on my conflicts window , what is the use of 'auto-resolve' ?
>
> If I want , I take this file and ignore the 'other' changes
> OR take 'other' file and ignore my ('this') changes
> Or merge both 'this' and 'other' by choosing 'merge' that activate external tool. When I finish I click 'mark as resolved'
>
> All this options can be done on multiple file by selection of multiple file and choose the wanted option.
>
> So what is the use of auto-resolve?

It matches bzr CLI: one can run `bzr resolve` without arguments and bzr
will try to do its best to find the files with properly resolved
conflicts without need to explicitly specify them. I found it very handy.

>
> best regards ,
> Gil Idelson
> RT/Embedded SW Engineer

Excuse me for being curious: what does it mean "RT" in your title?

Idelson, Gil

unread,
Feb 13, 2012, 4:28:21 AM2/13/12
to Alexander Belchenko, qb...@googlegroups.com
Hi
I have another question :
Now that I have 'take-this' and 'take-other' options on my conflicts window , what is the use of 'auto-resolve' ?

If I want , I take this file and ignore the 'other' changes
OR take 'other' file and ignore my ('this') changes
Or merge both 'this' and 'other' by choosing 'merge' that activate external tool. When I finish I click 'mark as resolved'

All this options can be done on multiple file by selection of multiple file and choose the wanted option.

So what is the use of auto-resolve?

best regards ,
Gil Idelson
RT/Embedded SW Engineer
Microsemi Corporation - AMSG
1 Hanagar St. P.O.Box 7220
Hod Hasharon, 45421, Israel
Phone:  +972-9-7755100 Ext 271
Fax:        +972-9-7755111


-----Original Message-----
From: Idelson, Gil
Sent: Monday, February 13, 2012 10:35 AM
To: 'Alexander Belchenko'; qb...@googlegroups.com
Subject: RE: [qbzr] Re: Add button to conflicts window

Thanks a lot.

I did it and it works!

Do I have a way to do it without copy paste it to any new qbzr version?

P.S by not active for few years , I meant that the "Answers" part on launchpad don’t contains any recent questions (in oppose to bazaar or bazaar explorer)

best regards ,
Gil Idelson
RT/Embedded SW Engineer
Microsemi Corporation - AMSG
1 Hanagar St. P.O.Box 7220
Hod Hasharon, 45421, Israel
Phone:  +972-9-7755100 Ext 271
Fax:        +972-9-7755111


-----Original Message-----
From: Alexander Belchenko [mailto:alexander...@gmail.com] On Behalf Of Alexander Belchenko
Sent: Monday, February 13, 2012 2:24 AM
To: qb...@googlegroups.com
Cc: Idelson, Gil
Subject: Re: [qbzr] Re: Add button to conflicts window

Alexander Belchenko

unread,
Feb 27, 2012, 11:23:57 AM2/27/12
to qb...@googlegroups.com
I've implemented suggested changes to qconflicts. Available in trunk r1466.

Alexander Belchenko пишет:

Reply all
Reply to author
Forward
0 new messages