##// END OF EJS Templates
dirstate-entry: add a `merged` property...
marmoute -
r48302:10e74029 default
parent child Browse files
Show More
@@ -155,8 +155,18 static PyObject *dirstatetuple_get_state
155 return PyBytes_FromStringAndSize(&self->state, 1);
155 return PyBytes_FromStringAndSize(&self->state, 1);
156 };
156 };
157
157
158 static PyObject *dirstatetuple_get_merged(dirstateTupleObject *self)
159 {
160 if (self->state == 'm') {
161 Py_RETURN_TRUE;
162 } else {
163 Py_RETURN_FALSE;
164 }
165 };
166
158 static PyGetSetDef dirstatetuple_getset[] = {
167 static PyGetSetDef dirstatetuple_getset[] = {
159 {"state", (getter)dirstatetuple_get_state, NULL, "state", NULL},
168 {"state", (getter)dirstatetuple_get_state, NULL, "state", NULL},
169 {"merged", (getter)dirstatetuple_get_merged, NULL, "merged", NULL},
160 {NULL} /* Sentinel */
170 {NULL} /* Sentinel */
161 };
171 };
162
172
@@ -355,7 +355,7 class dirstate(object):
355 def setparents(self, p1, p2=None):
355 def setparents(self, p1, p2=None):
356 """Set dirstate parents to p1 and p2.
356 """Set dirstate parents to p1 and p2.
357
357
358 When moving from two parents to one, 'm' merged entries a
358 When moving from two parents to one, "merged" entries a
359 adjusted to normal and previous copy records discarded and
359 adjusted to normal and previous copy records discarded and
360 returned by the call.
360 returned by the call.
361
361
@@ -386,8 +386,8 class dirstate(object):
386 if s is None:
386 if s is None:
387 continue
387 continue
388
388
389 # Discard 'm' markers when moving away from a merge state
389 # Discard "merged" markers when moving away from a merge state
390 if s.state == b'm':
390 if s.merged:
391 source = self._map.copymap.get(f)
391 source = self._map.copymap.get(f)
392 if source:
392 if source:
393 copies[f] = source
393 copies[f] = source
@@ -527,7 +527,7 class dirstate(object):
527 '''Mark a file normal, but possibly dirty.'''
527 '''Mark a file normal, but possibly dirty.'''
528 if self.in_merge:
528 if self.in_merge:
529 # if there is a merge going on and the file was either
529 # if there is a merge going on and the file was either
530 # in state 'm' (-1) or coming from other parent (-2) before
530 # "merged" or coming from other parent (-2) before
531 # being removed, restore that state.
531 # being removed, restore that state.
532 entry = self._map.get(f)
532 entry = self._map.get(f)
533 if entry is not None:
533 if entry is not None:
@@ -540,11 +540,7 class dirstate(object):
540 if source:
540 if source:
541 self.copy(source, f)
541 self.copy(source, f)
542 return
542 return
543 if (
543 if entry.merged or entry.state == b'n' and entry[2] == FROM_P2:
544 entry.state == b'm'
545 or entry.state == b'n'
546 and entry[2] == FROM_P2
547 ):
548 return
544 return
549 self._addpath(f, b'n', 0, possibly_dirty=True)
545 self._addpath(f, b'n', 0, possibly_dirty=True)
550 self._map.copymap.pop(f, None)
546 self._map.copymap.pop(f, None)
@@ -1362,7 +1358,7 class dirstate(object):
1362 ladd(fn)
1358 ladd(fn)
1363 elif listclean:
1359 elif listclean:
1364 cadd(fn)
1360 cadd(fn)
1365 elif state == b'm':
1361 elif t.merged:
1366 madd(fn)
1362 madd(fn)
1367 elif state == b'a':
1363 elif state == b'a':
1368 aadd(fn)
1364 aadd(fn)
@@ -171,7 +171,7 class dirstatemap(object):
171 # would be nice.
171 # would be nice.
172 if entry is not None:
172 if entry is not None:
173 # backup the previous state
173 # backup the previous state
174 if entry[0] == b'm': # merge
174 if entry.merged: # merge
175 size = NONNORMAL
175 size = NONNORMAL
176 elif entry[0] == b'n' and entry[2] == FROM_P2: # other parent
176 elif entry[0] == b'n' and entry[2] == FROM_P2: # other parent
177 size = FROM_P2
177 size = FROM_P2
@@ -79,6 +79,14 class dirstatetuple(object):
79 """
79 """
80 return self._state
80 return self._state
81
81
82 @property
83 def merged(self):
84 """True if the file has been merged
85
86 Should only be set if a merge is in progress in the dirstate
87 """
88 return self._state == b'm'
89
82 def v1_state(self):
90 def v1_state(self):
83 """return a "state" suitable for v1 serialization"""
91 """return a "state" suitable for v1 serialization"""
84 return self._state
92 return self._state
General Comments 0
You need to be logged in to leave comments. Login now