##// END OF EJS Templates
dirstate: add callback to notify extensions about wd parent change...
Mateusz Kwapich -
r29772:2ebd507e default
parent child Browse files
Show More
@@ -101,6 +101,8 b' class dirstate(object):'
101 self._parentwriters = 0
101 self._parentwriters = 0
102 self._filename = 'dirstate'
102 self._filename = 'dirstate'
103 self._pendingfilename = '%s.pending' % self._filename
103 self._pendingfilename = '%s.pending' % self._filename
104 self._plchangecallbacks = {}
105 self._origpl = None
104
106
105 # for consistent view between _pl() and _read() invocations
107 # for consistent view between _pl() and _read() invocations
106 self._pendingmode = None
108 self._pendingmode = None
@@ -347,6 +349,8 b' class dirstate(object):'
347
349
348 self._dirty = self._dirtypl = True
350 self._dirty = self._dirtypl = True
349 oldp2 = self._pl[1]
351 oldp2 = self._pl[1]
352 if self._origpl is None:
353 self._origpl = self._pl
350 self._pl = p1, p2
354 self._pl = p1, p2
351 copies = {}
355 copies = {}
352 if oldp2 != nullid and p2 == nullid:
356 if oldp2 != nullid and p2 == nullid:
@@ -442,6 +446,7 b' class dirstate(object):'
442 self._lastnormaltime = 0
446 self._lastnormaltime = 0
443 self._dirty = False
447 self._dirty = False
444 self._parentwriters = 0
448 self._parentwriters = 0
449 self._origpl = None
445
450
446 def copy(self, source, dest):
451 def copy(self, source, dest):
447 """Mark dest as a copy of source. Unmark dest if source is None."""
452 """Mark dest as a copy of source. Unmark dest if source is None."""
@@ -687,6 +692,8 b' class dirstate(object):'
687 if f in self._nonnormalset:
692 if f in self._nonnormalset:
688 self._nonnormalset.remove(f)
693 self._nonnormalset.remove(f)
689
694
695 if self._origpl is None:
696 self._origpl = self._pl
690 self._pl = (parent, nullid)
697 self._pl = (parent, nullid)
691 self._dirty = True
698 self._dirty = True
692
699
@@ -721,7 +728,23 b' class dirstate(object):'
721 st = self._opener(filename, "w", atomictemp=True, checkambig=True)
728 st = self._opener(filename, "w", atomictemp=True, checkambig=True)
722 self._writedirstate(st)
729 self._writedirstate(st)
723
730
731 def addparentchangecallback(self, category, callback):
732 """add a callback to be called when the wd parents are changed
733
734 Callback will be called with the following arguments:
735 dirstate, (oldp1, oldp2), (newp1, newp2)
736
737 Category is a unique identifier to allow overwriting an old callback
738 with a newer callback.
739 """
740 self._plchangecallbacks[category] = callback
741
724 def _writedirstate(self, st):
742 def _writedirstate(self, st):
743 # notify callbacks about parents change
744 if self._origpl is not None and self._origpl != self._pl:
745 for c, callback in sorted(self._plchangecallbacks.iteritems()):
746 callback(self, self._origpl, self._pl)
747 self._origpl = None
725 # use the modification time of the newly created temporary file as the
748 # use the modification time of the newly created temporary file as the
726 # filesystem's notion of 'now'
749 # filesystem's notion of 'now'
727 now = util.fstat(st).st_mtime & _rangemask
750 now = util.fstat(st).st_mtime & _rangemask
General Comments 0
You need to be logged in to leave comments. Login now