Show More
@@ -55,10 +55,16 b' def _getfsnow(vfs):' | |||
|
55 | 55 | def nonnormalentries(dmap): |
|
56 | 56 | '''Compute the nonnormal dirstate entries from the dmap''' |
|
57 | 57 | try: |
|
58 | return parsers.nonnormalentries(dmap) | |
|
58 | return parsers.nonnormalotherparententries(dmap) | |
|
59 | 59 | except AttributeError: |
|
60 | return set(fname for fname, e in dmap.iteritems() | |
|
61 | if e[0] != 'n' or e[3] == -1) | |
|
60 | nonnorm = set() | |
|
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 | 69 | class dirstate(object): |
|
64 | 70 | |
@@ -131,7 +137,15 b' class dirstate(object):' | |||
|
131 | 137 | |
|
132 | 138 | @propertycache |
|
133 | 139 | def _nonnormalset(self): |
|
134 |
|
|
|
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 | 150 | @propertycache |
|
137 | 151 | def _filefoldmap(self): |
@@ -341,7 +355,12 b' class dirstate(object):' | |||
|
341 | 355 | self._pl = p1, p2 |
|
342 | 356 | copies = {} |
|
343 | 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 | 364 | # Discard 'm' markers when moving away from a merge state |
|
346 | 365 | if s[0] == 'm': |
|
347 | 366 | if f in self._copymap: |
@@ -427,7 +446,8 b' class dirstate(object):' | |||
|
427 | 446 | |
|
428 | 447 | def invalidate(self): |
|
429 | 448 | for a in ("_map", "_copymap", "_filefoldmap", "_dirfoldmap", "_branch", |
|
430 |
"_pl", "_dirs", "_ignore", "_nonnormalset" |
|
|
449 | "_pl", "_dirs", "_ignore", "_nonnormalset", | |
|
450 | "_otherparentset"): | |
|
431 | 451 | if a in self.__dict__: |
|
432 | 452 | delattr(self, a) |
|
433 | 453 | self._lastnormaltime = 0 |
@@ -486,6 +506,8 b' class dirstate(object):' | |||
|
486 | 506 | self._map[f] = dirstatetuple(state, mode, size, mtime) |
|
487 | 507 | if state != 'n' or mtime == -1: |
|
488 | 508 | self._nonnormalset.add(f) |
|
509 | if size == -2: | |
|
510 | self._otherparentset.add(f) | |
|
489 | 511 | |
|
490 | 512 | def normal(self, f): |
|
491 | 513 | '''Mark a file normal and clean.''' |
@@ -560,6 +582,7 b' class dirstate(object):' | |||
|
560 | 582 | size = -1 |
|
561 | 583 | elif entry[0] == 'n' and entry[2] == -2: # other parent |
|
562 | 584 | size = -2 |
|
585 | self._otherparentset.add(f) | |
|
563 | 586 | self._map[f] = dirstatetuple('r', 0, size, 0) |
|
564 | 587 | self._nonnormalset.add(f) |
|
565 | 588 | if size == 0 and f in self._copymap: |
@@ -659,6 +682,7 b' class dirstate(object):' | |||
|
659 | 682 | def clear(self): |
|
660 | 683 | self._map = {} |
|
661 | 684 | self._nonnormalset = set() |
|
685 | self._otherparentset = set() | |
|
662 | 686 | if "_dirs" in self.__dict__: |
|
663 | 687 | delattr(self, "_dirs") |
|
664 | 688 | self._copymap = {} |
@@ -758,7 +782,7 b' class dirstate(object):' | |||
|
758 | 782 | break |
|
759 | 783 | |
|
760 | 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 | 786 | st.close() |
|
763 | 787 | self._lastnormaltime = 0 |
|
764 | 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) | |
|
566 | { | |
|
567 |
PyObject |
|
|
565 | static PyObject *nonnormalotherparententries(PyObject *self, PyObject *args) { | |
|
566 | PyObject *dmap, *fname, *v; | |
|
567 | PyObject *nonnset = NULL, *otherpset = NULL, *result = NULL; | |
|
568 | 568 | Py_ssize_t pos; |
|
569 | 569 | |
|
570 | 570 | if (!PyArg_ParseTuple(args, "O!:nonnormalentries", |
@@ -575,6 +575,10 b' static PyObject *nonnormalentries(PyObje' | |||
|
575 | 575 | if (nonnset == NULL) |
|
576 | 576 | goto bail; |
|
577 | 577 | |
|
578 | otherpset = PySet_New(NULL); | |
|
579 | if (otherpset == NULL) | |
|
580 | goto bail; | |
|
581 | ||
|
578 | 582 | pos = 0; |
|
579 | 583 | while (PyDict_Next(dmap, &pos, &fname, &v)) { |
|
580 | 584 | dirstateTupleObject *t; |
@@ -585,19 +589,53 b' static PyObject *nonnormalentries(PyObje' | |||
|
585 | 589 | } |
|
586 | 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 | 598 | if (t->state == 'n' && t->mtime != -1) |
|
589 | 599 | continue; |
|
590 | 600 | if (PySet_Add(nonnset, fname) == -1) |
|
591 | 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 | 608 | bail: |
|
596 | 609 | Py_XDECREF(nonnset); |
|
610 | Py_XDECREF(otherpset); | |
|
611 | Py_XDECREF(result); | |
|
597 | 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 | 639 | * Efficiently pack a dirstate object into its on-disk format. |
|
602 | 640 | */ |
|
603 | 641 | static PyObject *pack_dirstate(PyObject *self, PyObject *args) |
@@ -2816,6 +2854,9 b' static PyMethodDef methods[] = {' | |||
|
2816 | 2854 | {"pack_dirstate", pack_dirstate, METH_VARARGS, "pack a dirstate\n"}, |
|
2817 | 2855 | {"nonnormalentries", nonnormalentries, METH_VARARGS, |
|
2818 | 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 | 2860 | {"parse_manifest", parse_manifest, METH_VARARGS, "parse a manifest\n"}, |
|
2820 | 2861 | {"parse_dirstate", parse_dirstate, METH_VARARGS, "parse a dirstate\n"}, |
|
2821 | 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