Show More
@@ -7,6 +7,7 b'' | |||||
7 |
|
7 | |||
8 | from __future__ import absolute_import |
|
8 | from __future__ import absolute_import | |
9 |
|
9 | |||
|
10 | import errno | |||
10 | import stat |
|
11 | import stat | |
11 |
|
12 | |||
12 | from ..i18n import _ |
|
13 | from ..i18n import _ | |
@@ -633,16 +634,29 b' def upgrade_dirstate(ui, srcrepo, upgrad' | |||||
633 | util.copyfile( |
|
634 | util.copyfile( | |
634 | srcrepo.vfs.join(b'requires'), backupvfs.join(b'requires') |
|
635 | srcrepo.vfs.join(b'requires'), backupvfs.join(b'requires') | |
635 | ) |
|
636 | ) | |
|
637 | try: | |||
636 | util.copyfile( |
|
638 | util.copyfile( | |
637 | srcrepo.vfs.join(b'dirstate'), backupvfs.join(b'dirstate') |
|
639 | srcrepo.vfs.join(b'dirstate'), backupvfs.join(b'dirstate') | |
638 | ) |
|
640 | ) | |
|
641 | except (IOError, OSError) as e: | |||
|
642 | # The dirstate does not exist on an empty repo or a repo with no | |||
|
643 | # revision checked out | |||
|
644 | if e.errno != errno.ENOENT: | |||
|
645 | raise | |||
639 |
|
646 | |||
640 | assert srcrepo.dirstate._use_dirstate_v2 == (old == b'v2') |
|
647 | assert srcrepo.dirstate._use_dirstate_v2 == (old == b'v2') | |
641 | srcrepo.dirstate._map.preload() |
|
648 | srcrepo.dirstate._map.preload() | |
642 | srcrepo.dirstate._use_dirstate_v2 = new == b'v2' |
|
649 | srcrepo.dirstate._use_dirstate_v2 = new == b'v2' | |
643 | srcrepo.dirstate._map._use_dirstate_v2 = srcrepo.dirstate._use_dirstate_v2 |
|
650 | srcrepo.dirstate._map._use_dirstate_v2 = srcrepo.dirstate._use_dirstate_v2 | |
644 | srcrepo.dirstate._dirty = True |
|
651 | srcrepo.dirstate._dirty = True | |
|
652 | try: | |||
645 | srcrepo.vfs.unlink(b'dirstate') |
|
653 | srcrepo.vfs.unlink(b'dirstate') | |
|
654 | except (IOError, OSError) as e: | |||
|
655 | # The dirstate does not exist on an empty repo or a repo with no | |||
|
656 | # revision checked out | |||
|
657 | if e.errno != errno.ENOENT: | |||
|
658 | raise | |||
|
659 | ||||
646 | srcrepo.dirstate.write(None) |
|
660 | srcrepo.dirstate.write(None) | |
647 |
|
661 | |||
648 | scmutil.writereporequirements(srcrepo, upgrade_op.new_requirements) |
|
662 | scmutil.writereporequirements(srcrepo, upgrade_op.new_requirements) |
@@ -1701,3 +1701,66 b' Downgrade from dirstate-v2' | |||||
1701 | $ hg debugformat -v | grep dirstate-v2 |
|
1701 | $ hg debugformat -v | grep dirstate-v2 | |
1702 | dirstate-v2: no no no |
|
1702 | dirstate-v2: no no no | |
1703 | $ hg status |
|
1703 | $ hg status | |
|
1704 | ||||
|
1705 | $ cd .. | |||
|
1706 | ||||
|
1707 | dirstate-v2: upgrade and downgrade from and empty repository: | |||
|
1708 | ------------------------------------------------------------- | |||
|
1709 | ||||
|
1710 | $ hg init --config format.exp-rc-dirstate-v2=no dirstate-v2-empty | |||
|
1711 | $ cd dirstate-v2-empty | |||
|
1712 | $ hg debugformat | grep dirstate-v2 | |||
|
1713 | dirstate-v2: no | |||
|
1714 | ||||
|
1715 | upgrade | |||
|
1716 | ||||
|
1717 | $ hg debugupgraderepo --run --config format.exp-rc-dirstate-v2=yes | |||
|
1718 | upgrade will perform the following actions: | |||
|
1719 | ||||
|
1720 | requirements | |||
|
1721 | preserved: * (glob) | |||
|
1722 | added: dirstate-v2 | |||
|
1723 | ||||
|
1724 | dirstate-v2 | |||
|
1725 | "hg status" will be faster | |||
|
1726 | ||||
|
1727 | processed revlogs: | |||
|
1728 | - all-filelogs | |||
|
1729 | - changelog | |||
|
1730 | - manifest | |||
|
1731 | ||||
|
1732 | beginning upgrade... | |||
|
1733 | repository locked and read-only | |||
|
1734 | creating temporary repository to stage upgraded data: $TESTTMP/dirstate-v2-empty/.hg/upgrade.* (glob) | |||
|
1735 | (it is safe to interrupt this process any time before data migration completes) | |||
|
1736 | upgrading to dirstate-v2 from v1 | |||
|
1737 | replaced files will be backed up at $TESTTMP/dirstate-v2-empty/.hg/upgradebackup.* (glob) | |||
|
1738 | removing temporary repository $TESTTMP/dirstate-v2-empty/.hg/upgrade.* (glob) | |||
|
1739 | $ hg debugformat | grep dirstate-v2 | |||
|
1740 | dirstate-v2: yes | |||
|
1741 | ||||
|
1742 | downgrade | |||
|
1743 | ||||
|
1744 | $ hg debugupgraderepo --run --config format.exp-rc-dirstate-v2=no | |||
|
1745 | upgrade will perform the following actions: | |||
|
1746 | ||||
|
1747 | requirements | |||
|
1748 | preserved: * (glob) | |||
|
1749 | removed: dirstate-v2 | |||
|
1750 | ||||
|
1751 | processed revlogs: | |||
|
1752 | - all-filelogs | |||
|
1753 | - changelog | |||
|
1754 | - manifest | |||
|
1755 | ||||
|
1756 | beginning upgrade... | |||
|
1757 | repository locked and read-only | |||
|
1758 | creating temporary repository to stage upgraded data: $TESTTMP/dirstate-v2-empty/.hg/upgrade.* (glob) | |||
|
1759 | (it is safe to interrupt this process any time before data migration completes) | |||
|
1760 | downgrading from dirstate-v2 to v1 | |||
|
1761 | replaced files will be backed up at $TESTTMP/dirstate-v2-empty/.hg/upgradebackup.* (glob) | |||
|
1762 | removing temporary repository $TESTTMP/dirstate-v2-empty/.hg/upgrade.* (glob) | |||
|
1763 | $ hg debugformat | grep dirstate-v2 | |||
|
1764 | dirstate-v2: no | |||
|
1765 | ||||
|
1766 | $ cd .. |
General Comments 0
You need to be logged in to leave comments.
Login now