Show More
@@ -1486,6 +1486,9 b' class dirstate:' | |||||
1486 | """return a filename to backup a data-file or None""" |
|
1486 | """return a filename to backup a data-file or None""" | |
1487 | if not self._use_dirstate_v2: |
|
1487 | if not self._use_dirstate_v2: | |
1488 | return None |
|
1488 | return None | |
|
1489 | if self._map.docket.uuid is None: | |||
|
1490 | # not created yet, nothing to backup | |||
|
1491 | return None | |||
1489 | data_filename = self._map.docket.data_filename() |
|
1492 | data_filename = self._map.docket.data_filename() | |
1490 | return data_filename, self.data_backup_filename(backupname) |
|
1493 | return data_filename, self.data_backup_filename(backupname) | |
1491 |
|
1494 | |||
@@ -1506,7 +1509,7 b' class dirstate:' | |||||
1506 | # use '_writedirstate' instead of 'write' to write changes certainly, |
|
1509 | # use '_writedirstate' instead of 'write' to write changes certainly, | |
1507 | # because the latter omits writing out if transaction is running. |
|
1510 | # because the latter omits writing out if transaction is running. | |
1508 | # output file will be used to create backup of dirstate at this point. |
|
1511 | # output file will be used to create backup of dirstate at this point. | |
1509 | if self._dirty or not self._opener.exists(filename): |
|
1512 | if self._dirty: | |
1510 | self._writedirstate( |
|
1513 | self._writedirstate( | |
1511 | tr, |
|
1514 | tr, | |
1512 | self._opener(filename, b"w", atomictemp=True, checkambig=True), |
|
1515 | self._opener(filename, b"w", atomictemp=True, checkambig=True), | |
@@ -1530,7 +1533,7 b' class dirstate:' | |||||
1530 | tr.registertmp(filename, location=b'plain') |
|
1533 | tr.registertmp(filename, location=b'plain') | |
1531 |
|
1534 | |||
1532 | self._opener.tryunlink(backupname) |
|
1535 | self._opener.tryunlink(backupname) | |
1533 | if True: |
|
1536 | if self._opener.exists(filename): | |
1534 | # hardlink backup is okay because _writedirstate is always called |
|
1537 | # hardlink backup is okay because _writedirstate is always called | |
1535 | # with an "atomictemp=True" file. |
|
1538 | # with an "atomictemp=True" file. | |
1536 | util.copyfile( |
|
1539 | util.copyfile( | |
@@ -1557,10 +1560,23 b' class dirstate:' | |||||
1557 | # this "invalidate()" prevents "wlock.release()" from writing |
|
1560 | # this "invalidate()" prevents "wlock.release()" from writing | |
1558 | # changes of dirstate out after restoring from backup file |
|
1561 | # changes of dirstate out after restoring from backup file | |
1559 | self.invalidate() |
|
1562 | self.invalidate() | |
|
1563 | o = self._opener | |||
|
1564 | if not o.exists(backupname): | |||
|
1565 | # there was no file backup, delete existing files | |||
|
1566 | filename = self._actualfilename(tr) | |||
|
1567 | data_file = None | |||
|
1568 | if self._use_dirstate_v2: | |||
|
1569 | data_file = self._map.docket.data_filename() | |||
|
1570 | if o.exists(filename): | |||
|
1571 | o.unlink(filename) | |||
|
1572 | if data_file is not None and o.exists(data_file): | |||
|
1573 | o.unlink(data_file) | |||
|
1574 | return | |||
1560 | filename = self._actualfilename(tr) |
|
1575 | filename = self._actualfilename(tr) | |
1561 | o = self._opener |
|
|||
1562 | data_pair = self.backup_data_file(backupname) |
|
1576 | data_pair = self.backup_data_file(backupname) | |
1563 | if util.samefile(o.join(backupname), o.join(filename)): |
|
1577 | if o.exists(filename) and util.samefile( | |
|
1578 | o.join(backupname), o.join(filename) | |||
|
1579 | ): | |||
1564 | o.unlink(backupname) |
|
1580 | o.unlink(backupname) | |
1565 | else: |
|
1581 | else: | |
1566 | o.rename(backupname, filename, checkambig=True) |
|
1582 | o.rename(backupname, filename, checkambig=True) | |
@@ -1577,11 +1593,11 b' class dirstate:' | |||||
1577 | def clearbackup(self, tr, backupname): |
|
1593 | def clearbackup(self, tr, backupname): | |
1578 | '''Clear backup file''' |
|
1594 | '''Clear backup file''' | |
1579 | o = self._opener |
|
1595 | o = self._opener | |
1580 | data_backup = self.backup_data_file(backupname) |
|
1596 | if o.exists(backupname): | |
1581 | o.unlink(backupname) |
|
1597 | data_backup = self.backup_data_file(backupname) | |
1582 |
|
1598 | o.unlink(backupname) | ||
1583 | if data_backup is not None: |
|
1599 | if data_backup is not None: | |
1584 | o.unlink(data_backup[0]) |
|
1600 | o.unlink(data_backup[0]) | |
1585 |
|
1601 | |||
1586 | def verify(self, m1, m2, p1, narrow_matcher=None): |
|
1602 | def verify(self, m1, m2, p1, narrow_matcher=None): | |
1587 | """ |
|
1603 | """ |
@@ -36,7 +36,6 b' Poke at a clone:' | |||||
36 | $ ls .hg |
|
36 | $ ls .hg | |
37 | 00changelog.i |
|
37 | 00changelog.i | |
38 | cache |
|
38 | cache | |
39 | dirstate |
|
|||
40 | hgrc |
|
39 | hgrc | |
41 | requires |
|
40 | requires | |
42 | store |
|
41 | store |
@@ -137,7 +137,6 b' group can still write everything' | |||||
137 | 00660 ../push/.hg/cache/branch2-base |
|
137 | 00660 ../push/.hg/cache/branch2-base | |
138 | 00660 ../push/.hg/cache/rbc-names-v1 |
|
138 | 00660 ../push/.hg/cache/rbc-names-v1 | |
139 | 00660 ../push/.hg/cache/rbc-revs-v1 |
|
139 | 00660 ../push/.hg/cache/rbc-revs-v1 | |
140 | 00660 ../push/.hg/dirstate |
|
|||
141 | 00660 ../push/.hg/requires |
|
140 | 00660 ../push/.hg/requires | |
142 | 00770 ../push/.hg/store/ |
|
141 | 00770 ../push/.hg/store/ | |
143 | 00660 ../push/.hg/store/00changelog.i |
|
142 | 00660 ../push/.hg/store/00changelog.i | |
@@ -160,7 +159,6 b' group can still write everything' | |||||
160 | 00660 ../push/.hg/undo.bookmarks |
|
159 | 00660 ../push/.hg/undo.bookmarks | |
161 | 00660 ../push/.hg/undo.branch |
|
160 | 00660 ../push/.hg/undo.branch | |
162 | 00660 ../push/.hg/undo.desc |
|
161 | 00660 ../push/.hg/undo.desc | |
163 | 00660 ../push/.hg/undo.dirstate |
|
|||
164 | 00770 ../push/.hg/wcache/ |
|
162 | 00770 ../push/.hg/wcache/ | |
165 |
|
163 | |||
166 |
|
164 |
General Comments 0
You need to be logged in to leave comments.
Login now