Show More
@@ -7,6 +7,7 b'' | |||||
7 |
|
7 | |||
8 | from __future__ import absolute_import |
|
8 | from __future__ import absolute_import | |
9 |
|
9 | |||
|
10 | import collections | |||
10 | import errno |
|
11 | import errno | |
11 | import stat |
|
12 | import stat | |
12 | import struct |
|
13 | import struct | |
@@ -564,11 +565,14 b' class mergeresult(object):' | |||||
564 | deleted on one side and renamed on other. |
|
565 | deleted on one side and renamed on other. | |
565 | commitinfo: dict containing data which should be used on commit |
|
566 | commitinfo: dict containing data which should be used on commit | |
566 | contains a filename -> info mapping |
|
567 | contains a filename -> info mapping | |
|
568 | actionmapping: dict of action names as keys and list of files and | |||
|
569 | related data as values | |||
567 | """ |
|
570 | """ | |
568 | self._filemapping = {} |
|
571 | self._filemapping = {} | |
569 | self._diverge = {} |
|
572 | self._diverge = {} | |
570 | self._renamedelete = {} |
|
573 | self._renamedelete = {} | |
571 | self._commitinfo = {} |
|
574 | self._commitinfo = {} | |
|
575 | self._actionmapping = collections.defaultdict(list) | |||
572 |
|
576 | |||
573 | def updatevalues(self, diverge, renamedelete, commitinfo): |
|
577 | def updatevalues(self, diverge, renamedelete, commitinfo): | |
574 | self._diverge = diverge |
|
578 | self._diverge = diverge | |
@@ -583,12 +587,33 b' class mergeresult(object):' | |||||
583 | data: a tuple of information like fctx and ctx related to this merge |
|
587 | data: a tuple of information like fctx and ctx related to this merge | |
584 | message: a message about the merge |
|
588 | message: a message about the merge | |
585 | """ |
|
589 | """ | |
|
590 | # if the file already existed, we need to delete it's old | |||
|
591 | # entry form _actionmapping too | |||
|
592 | if filename in self._filemapping: | |||
|
593 | # TODO: this is inefficient | |||
|
594 | a, d, m = self._filemapping[filename] | |||
|
595 | self._actionmapping[a].remove((filename, d, m)) | |||
|
596 | ||||
586 | self._filemapping[filename] = (action, data, message) |
|
597 | self._filemapping[filename] = (action, data, message) | |
|
598 | self._actionmapping[action].append((filename, data, message)) | |||
587 |
|
599 | |||
588 | def removefile(self, filename): |
|
600 | def removefile(self, filename): | |
589 | """ removes a file from the mergeresult object as the file might |
|
601 | """ removes a file from the mergeresult object as the file might | |
590 | not merging anymore """ |
|
602 | not merging anymore """ | |
|
603 | action, data, message = self._filemapping[filename] | |||
591 | del self._filemapping[filename] |
|
604 | del self._filemapping[filename] | |
|
605 | # TODO: this is inefficient | |||
|
606 | self._actionmapping[action].remove((filename, data, message)) | |||
|
607 | ||||
|
608 | def getactions(self, actions): | |||
|
609 | """ get list of files which are marked with these actions | |||
|
610 | ||||
|
611 | Returns a list of tuple of form (filename, data, message) | |||
|
612 | """ | |||
|
613 | res = [] | |||
|
614 | for a in actions: | |||
|
615 | res.extend(self._actionmapping[a]) | |||
|
616 | return res | |||
592 |
|
617 | |||
593 | @property |
|
618 | @property | |
594 | def actions(self): |
|
619 | def actions(self): | |
@@ -610,20 +635,17 b' class mergeresult(object):' | |||||
610 | def actionsdict(self): |
|
635 | def actionsdict(self): | |
611 | """ returns a dictionary of actions to be perfomed with action as key |
|
636 | """ returns a dictionary of actions to be perfomed with action as key | |
612 | and a list of files and related arguments as values """ |
|
637 | and a list of files and related arguments as values """ | |
613 | # Convert to dictionary-of-lists format |
|
638 | return self._actionmapping | |
614 | actions = emptyactions() |
|
|||
615 | for f, (m, args, msg) in pycompat.iteritems(self._filemapping): |
|
|||
616 | if m not in actions: |
|
|||
617 | actions[m] = [] |
|
|||
618 | actions[m].append((f, args, msg)) |
|
|||
619 |
|
||||
620 | return actions |
|
|||
621 |
|
639 | |||
622 | def setactions(self, actions): |
|
640 | def setactions(self, actions): | |
623 | self._filemapping = actions |
|
641 | self._filemapping = actions | |
|
642 | self._actionmapping = collections.defaultdict(list) | |||
|
643 | for f, (act, data, msg) in pycompat.iteritems(self._filemapping): | |||
|
644 | self._actionmapping[act].append((f, data, msg)) | |||
624 |
|
645 | |||
625 | def updateactions(self, updates): |
|
646 | def updateactions(self, updates): | |
626 | self._filemapping.update(updates) |
|
647 | for f, (a, data, msg) in pycompat.iteritems(updates): | |
|
648 | self.addfile(f, a, data, msg) | |||
627 |
|
649 | |||
628 | def hasconflicts(self): |
|
650 | def hasconflicts(self): | |
629 | """ tells whether this merge resulted in some actions which can |
|
651 | """ tells whether this merge resulted in some actions which can |
General Comments 0
You need to be logged in to leave comments.
Login now