Show More
@@ -101,6 +101,8 b' class dirstate(object):' | |||
|
101 | 101 | self._parentwriters = 0 |
|
102 | 102 | self._filename = 'dirstate' |
|
103 | 103 | self._pendingfilename = '%s.pending' % self._filename |
|
104 | self._plchangecallbacks = {} | |
|
105 | self._origpl = None | |
|
104 | 106 | |
|
105 | 107 | # for consistent view between _pl() and _read() invocations |
|
106 | 108 | self._pendingmode = None |
@@ -347,6 +349,8 b' class dirstate(object):' | |||
|
347 | 349 | |
|
348 | 350 | self._dirty = self._dirtypl = True |
|
349 | 351 | oldp2 = self._pl[1] |
|
352 | if self._origpl is None: | |
|
353 | self._origpl = self._pl | |
|
350 | 354 | self._pl = p1, p2 |
|
351 | 355 | copies = {} |
|
352 | 356 | if oldp2 != nullid and p2 == nullid: |
@@ -442,6 +446,7 b' class dirstate(object):' | |||
|
442 | 446 | self._lastnormaltime = 0 |
|
443 | 447 | self._dirty = False |
|
444 | 448 | self._parentwriters = 0 |
|
449 | self._origpl = None | |
|
445 | 450 | |
|
446 | 451 | def copy(self, source, dest): |
|
447 | 452 | """Mark dest as a copy of source. Unmark dest if source is None.""" |
@@ -687,6 +692,8 b' class dirstate(object):' | |||
|
687 | 692 | if f in self._nonnormalset: |
|
688 | 693 | self._nonnormalset.remove(f) |
|
689 | 694 | |
|
695 | if self._origpl is None: | |
|
696 | self._origpl = self._pl | |
|
690 | 697 | self._pl = (parent, nullid) |
|
691 | 698 | self._dirty = True |
|
692 | 699 | |
@@ -721,7 +728,23 b' class dirstate(object):' | |||
|
721 | 728 | st = self._opener(filename, "w", atomictemp=True, checkambig=True) |
|
722 | 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 | 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 | 748 | # use the modification time of the newly created temporary file as the |
|
726 | 749 | # filesystem's notion of 'now' |
|
727 | 750 | now = util.fstat(st).st_mtime & _rangemask |
General Comments 0
You need to be logged in to leave comments.
Login now