##// END OF EJS Templates
dirstate: track otherparent files same as nonnormal...
Durham Goode -
r31278:1c97a91a default
parent child Browse files
Show More
@@ -55,10 +55,16 b' def _getfsnow(vfs):'
55 def nonnormalentries(dmap):
55 def nonnormalentries(dmap):
56 '''Compute the nonnormal dirstate entries from the dmap'''
56 '''Compute the nonnormal dirstate entries from the dmap'''
57 try:
57 try:
58 return parsers.nonnormalentries(dmap)
58 return parsers.nonnormalotherparententries(dmap)
59 except AttributeError:
59 except AttributeError:
60 return set(fname for fname, e in dmap.iteritems()
60 nonnorm = set()
61 if e[0] != 'n' or e[3] == -1)
61 otherparent = set()
62 for fname, e in dmap.iteritems():
63 if e[0] != 'n' or e[3] == -1:
64 nonnorm.add(fname)
65 if e[0] == 'n' and e[2] == -2:
66 otherparent.add(fname)
67 return nonnorm, otherparent
62
68
63 class dirstate(object):
69 class dirstate(object):
64
70
@@ -131,7 +137,15 b' class dirstate(object):'
131
137
132 @propertycache
138 @propertycache
133 def _nonnormalset(self):
139 def _nonnormalset(self):
134 return nonnormalentries(self._map)
140 nonnorm, otherparents = nonnormalentries(self._map)
141 self._otherparentset = otherparents
142 return nonnorm
143
144 @propertycache
145 def _otherparentset(self):
146 nonnorm, otherparents = nonnormalentries(self._map)
147 self._nonnormalset = nonnorm
148 return otherparents
135
149
136 @propertycache
150 @propertycache
137 def _filefoldmap(self):
151 def _filefoldmap(self):
@@ -341,7 +355,12 b' class dirstate(object):'
341 self._pl = p1, p2
355 self._pl = p1, p2
342 copies = {}
356 copies = {}
343 if oldp2 != nullid and p2 == nullid:
357 if oldp2 != nullid and p2 == nullid:
344 for f, s in self._map.iteritems():
358 candidatefiles = self._nonnormalset.union(self._otherparentset)
359 for f in candidatefiles:
360 s = self._map.get(f)
361 if s is None:
362 continue
363
345 # Discard 'm' markers when moving away from a merge state
364 # Discard 'm' markers when moving away from a merge state
346 if s[0] == 'm':
365 if s[0] == 'm':
347 if f in self._copymap:
366 if f in self._copymap:
@@ -427,7 +446,8 b' class dirstate(object):'
427
446
428 def invalidate(self):
447 def invalidate(self):
429 for a in ("_map", "_copymap", "_filefoldmap", "_dirfoldmap", "_branch",
448 for a in ("_map", "_copymap", "_filefoldmap", "_dirfoldmap", "_branch",
430 "_pl", "_dirs", "_ignore", "_nonnormalset"):
449 "_pl", "_dirs", "_ignore", "_nonnormalset",
450 "_otherparentset"):
431 if a in self.__dict__:
451 if a in self.__dict__:
432 delattr(self, a)
452 delattr(self, a)
433 self._lastnormaltime = 0
453 self._lastnormaltime = 0
@@ -486,6 +506,8 b' class dirstate(object):'
486 self._map[f] = dirstatetuple(state, mode, size, mtime)
506 self._map[f] = dirstatetuple(state, mode, size, mtime)
487 if state != 'n' or mtime == -1:
507 if state != 'n' or mtime == -1:
488 self._nonnormalset.add(f)
508 self._nonnormalset.add(f)
509 if size == -2:
510 self._otherparentset.add(f)
489
511
490 def normal(self, f):
512 def normal(self, f):
491 '''Mark a file normal and clean.'''
513 '''Mark a file normal and clean.'''
@@ -560,6 +582,7 b' class dirstate(object):'
560 size = -1
582 size = -1
561 elif entry[0] == 'n' and entry[2] == -2: # other parent
583 elif entry[0] == 'n' and entry[2] == -2: # other parent
562 size = -2
584 size = -2
585 self._otherparentset.add(f)
563 self._map[f] = dirstatetuple('r', 0, size, 0)
586 self._map[f] = dirstatetuple('r', 0, size, 0)
564 self._nonnormalset.add(f)
587 self._nonnormalset.add(f)
565 if size == 0 and f in self._copymap:
588 if size == 0 and f in self._copymap:
@@ -659,6 +682,7 b' class dirstate(object):'
659 def clear(self):
682 def clear(self):
660 self._map = {}
683 self._map = {}
661 self._nonnormalset = set()
684 self._nonnormalset = set()
685 self._otherparentset = set()
662 if "_dirs" in self.__dict__:
686 if "_dirs" in self.__dict__:
663 delattr(self, "_dirs")
687 delattr(self, "_dirs")
664 self._copymap = {}
688 self._copymap = {}
@@ -758,7 +782,7 b' class dirstate(object):'
758 break
782 break
759
783
760 st.write(parsers.pack_dirstate(self._map, self._copymap, self._pl, now))
784 st.write(parsers.pack_dirstate(self._map, self._copymap, self._pl, now))
761 self._nonnormalset = nonnormalentries(self._map)
785 self._nonnormalset, self._otherparentset = nonnormalentries(self._map)
762 st.close()
786 st.close()
763 self._lastnormaltime = 0
787 self._lastnormaltime = 0
764 self._dirty = self._dirtypl = False
788 self._dirty = self._dirtypl = False
@@ -560,11 +560,11 b' quit:'
560 }
560 }
561
561
562 /*
562 /*
563 * Build a set of non-normal entries from the dirstate dmap
563 * Build a set of non-normal and other parent entries from the dirstate dmap
564 */
564 */
565 static PyObject *nonnormalentries(PyObject *self, PyObject *args)
565 static PyObject *nonnormalotherparententries(PyObject *self, PyObject *args) {
566 {
566 PyObject *dmap, *fname, *v;
567 PyObject *dmap, *nonnset = NULL, *fname, *v;
567 PyObject *nonnset = NULL, *otherpset = NULL, *result = NULL;
568 Py_ssize_t pos;
568 Py_ssize_t pos;
569
569
570 if (!PyArg_ParseTuple(args, "O!:nonnormalentries",
570 if (!PyArg_ParseTuple(args, "O!:nonnormalentries",
@@ -575,6 +575,10 b' static PyObject *nonnormalentries(PyObje'
575 if (nonnset == NULL)
575 if (nonnset == NULL)
576 goto bail;
576 goto bail;
577
577
578 otherpset = PySet_New(NULL);
579 if (otherpset == NULL)
580 goto bail;
581
578 pos = 0;
582 pos = 0;
579 while (PyDict_Next(dmap, &pos, &fname, &v)) {
583 while (PyDict_Next(dmap, &pos, &fname, &v)) {
580 dirstateTupleObject *t;
584 dirstateTupleObject *t;
@@ -585,19 +589,53 b' static PyObject *nonnormalentries(PyObje'
585 }
589 }
586 t = (dirstateTupleObject *)v;
590 t = (dirstateTupleObject *)v;
587
591
592 if (t->state == 'n' && t->size == -2) {
593 if (PySet_Add(otherpset, fname) == -1) {
594 goto bail;
595 }
596 }
597
588 if (t->state == 'n' && t->mtime != -1)
598 if (t->state == 'n' && t->mtime != -1)
589 continue;
599 continue;
590 if (PySet_Add(nonnset, fname) == -1)
600 if (PySet_Add(nonnset, fname) == -1)
591 goto bail;
601 goto bail;
592 }
602 }
593
603
594 return nonnset;
604 result = Py_BuildValue("(OO)", nonnset, otherpset);
605 if (result == NULL)
606 goto bail;
607 return result;
595 bail:
608 bail:
596 Py_XDECREF(nonnset);
609 Py_XDECREF(nonnset);
610 Py_XDECREF(otherpset);
611 Py_XDECREF(result);
597 return NULL;
612 return NULL;
598 }
613 }
599
614
600 /*
615 /*
616 * Build a set of non-normal entries from the dirstate dmap
617 */
618 static PyObject *nonnormalentries(PyObject *self, PyObject *args)
619 {
620 PyObject *nonnset = NULL, *combined = NULL;
621
622 combined = nonnormalotherparententries(self, args);
623 if (!combined) {
624 return NULL;
625 }
626
627 nonnset = PyTuple_GetItem(combined, 0);
628 if (!nonnset) {
629 Py_DECREF(combined);
630 return NULL;
631 }
632
633 Py_INCREF(nonnset);
634 Py_DECREF(combined);
635 return nonnset;
636 }
637
638 /*
601 * Efficiently pack a dirstate object into its on-disk format.
639 * Efficiently pack a dirstate object into its on-disk format.
602 */
640 */
603 static PyObject *pack_dirstate(PyObject *self, PyObject *args)
641 static PyObject *pack_dirstate(PyObject *self, PyObject *args)
@@ -2816,6 +2854,9 b' static PyMethodDef methods[] = {'
2816 {"pack_dirstate", pack_dirstate, METH_VARARGS, "pack a dirstate\n"},
2854 {"pack_dirstate", pack_dirstate, METH_VARARGS, "pack a dirstate\n"},
2817 {"nonnormalentries", nonnormalentries, METH_VARARGS,
2855 {"nonnormalentries", nonnormalentries, METH_VARARGS,
2818 "create a set containing non-normal entries of given dirstate\n"},
2856 "create a set containing non-normal entries of given dirstate\n"},
2857 {"nonnormalotherparententries", nonnormalotherparententries, METH_VARARGS,
2858 "create a set containing non-normal and other parent entries of given "
2859 "dirstate\n"},
2819 {"parse_manifest", parse_manifest, METH_VARARGS, "parse a manifest\n"},
2860 {"parse_manifest", parse_manifest, METH_VARARGS, "parse a manifest\n"},
2820 {"parse_dirstate", parse_dirstate, METH_VARARGS, "parse a dirstate\n"},
2861 {"parse_dirstate", parse_dirstate, METH_VARARGS, "parse a dirstate\n"},
2821 {"parse_index2", parse_index2, METH_VARARGS, "parse a revlog index\n"},
2862 {"parse_index2", parse_index2, METH_VARARGS, "parse a revlog index\n"},
General Comments 0
You need to be logged in to leave comments. Login now