Mercurial > hg
comparison hgext/histedit.py @ 43662:4323a32c7afe
histeditrule: split __bytes__ property into prefix and desc
In order to be able to colourise the description of the rule, we need
to have it as a separate bytestring. Curses doesn't make it easy to
take existing text on the screen and give it different properties; we
can only add new text with new properties.
author | Jordi Gutiérrez Hermoso <jordigh@octave.org> |
---|---|
date | Wed, 30 Oct 2019 19:27:09 -0400 |
parents | 43e722fc2909 |
children | 1d29da62af76 |
comparison
equal
deleted
inserted
replaced
43661:32048206e7be | 43662:4323a32c7afe |
---|---|
1117 self.origpos = pos | 1117 self.origpos = pos |
1118 self.pos = pos | 1118 self.pos = pos |
1119 self.conflicts = [] | 1119 self.conflicts = [] |
1120 | 1120 |
1121 def __bytes__(self): | 1121 def __bytes__(self): |
1122 # Some actions ('fold' and 'roll') combine a patch with a previous one. | 1122 # Example display of several histeditrules: |
1123 # Add a marker showing which patch they apply to, and also omit the | |
1124 # description for 'roll' (since it will get discarded). Example display: | |
1125 # | 1123 # |
1126 # #10 pick 316392:06a16c25c053 add option to skip tests | 1124 # #10 pick 316392:06a16c25c053 add option to skip tests |
1127 # #11 ^roll 316393:71313c964cc5 | 1125 # #11 ^roll 316393:71313c964cc5 <RED>oops a fixup commit</RED> |
1128 # #12 pick 316394:ab31f3973b0d include mfbt for mozilla-config.h | 1126 # #12 pick 316394:ab31f3973b0d include mfbt for mozilla-config.h |
1129 # #13 ^fold 316395:14ce5803f4c3 fix warnings | 1127 # #13 ^fold 316395:14ce5803f4c3 fix warnings |
1130 # | 1128 # |
1131 # The carets point to the changeset being folded into ("roll this | 1129 # The carets point to the changeset being folded into ("roll this |
1132 # changeset into the changeset above"). | 1130 # changeset into the changeset above"). |
1131 return b'%s%s' % (self.prefix, self.desc) | |
1132 | |
1133 __str__ = encoding.strmethod(__bytes__) | |
1134 | |
1135 @property | |
1136 def prefix(self): | |
1137 # Some actions ('fold' and 'roll') combine a patch with a | |
1138 # previous one. Add a marker showing which patch they apply | |
1139 # to. | |
1133 action = ACTION_LABELS.get(self.action, self.action) | 1140 action = ACTION_LABELS.get(self.action, self.action) |
1141 | |
1134 h = self.ctx.hex()[0:12] | 1142 h = self.ctx.hex()[0:12] |
1135 r = self.ctx.rev() | 1143 r = self.ctx.rev() |
1136 desc = self.ctx.description().splitlines()[0].strip() | 1144 |
1137 if self.action == b'roll': | 1145 return b"#%s %s %d:%s " % ( |
1138 desc = b'' | |
1139 return b"#%s %s %d:%s %s" % ( | |
1140 (b'%d' % self.origpos).ljust(2), | 1146 (b'%d' % self.origpos).ljust(2), |
1141 action.ljust(6), | 1147 action.ljust(6), |
1142 r, | 1148 r, |
1143 h, | 1149 h, |
1144 desc, | |
1145 ) | 1150 ) |
1146 | 1151 |
1147 __str__ = encoding.strmethod(__bytes__) | 1152 @property |
1153 def desc(self): | |
1154 # This is split off from the prefix property so that we can | |
1155 # separately make the description for 'roll' red (since it | |
1156 # will get discarded). | |
1157 return self.ctx.description().splitlines()[0].strip() | |
1148 | 1158 |
1149 def checkconflicts(self, other): | 1159 def checkconflicts(self, other): |
1150 if other.pos > self.pos and other.origpos <= self.origpos: | 1160 if other.pos > self.pos and other.origpos <= self.origpos: |
1151 if set(other.ctx.files()) & set(self.ctx.files()) != set(): | 1161 if set(other.ctx.files()) & set(self.ctx.files()) != set(): |
1152 self.conflicts.append(other) | 1162 self.conflicts.append(other) |