Patchwork D5505: narrow: include working copy narrowspec in transaction journal

login
register
mail settings
Submitter phabricator
Date Jan. 7, 2019, 7:03 p.m.
Message ID <583180b832354984ed73cf9288ddd611@localhost.localdomain>
Download mbox | patch
Permalink /patch/37535/
State Not Applicable
Headers show

Comments

phabricator - Jan. 7, 2019, 7:03 p.m.
martinvonz updated this revision to Diff 13054.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5505?vs=13027&id=13054

REVISION DETAIL
  https://phab.mercurial-scm.org/D5505

AFFECTED FILES
  mercurial/localrepo.py
  mercurial/narrowspec.py

CHANGE DETAILS




To: martinvonz, #hg-reviewers
Cc: mjpieters, mercurial-devel

Patch

diff --git a/mercurial/narrowspec.py b/mercurial/narrowspec.py
--- a/mercurial/narrowspec.py
+++ b/mercurial/narrowspec.py
@@ -190,8 +190,10 @@ 
         return
     vfs = repo.vfs
     vfs.tryunlink(backupname)
-    util.copyfile(vfs.join(DIRSTATE_FILENAME), vfs.join(backupname),
-                  hardlink=True)
+    # It may not exist in old repos
+    if vfs.exists(DIRSTATE_FILENAME):
+        util.copyfile(vfs.join(DIRSTATE_FILENAME), vfs.join(backupname),
+                      hardlink=True)
 
 def restorewcbackup(repo, backupname):
     if repository.NARROW_REQUIREMENT not in repo.requirements:
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1837,6 +1837,7 @@ 
                 # discard all changes (including ones already written
                 # out) in this transaction
                 narrowspec.restorebackup(self, 'journal.narrowspec')
+                narrowspec.restorewcbackup(self, 'journal.narrowspec')
                 repo.dirstate.restorebackup(None, 'journal.dirstate')
 
                 repo.invalidate(clearfilecache=True)
@@ -1925,6 +1926,7 @@ 
     @unfilteredmethod
     def _writejournal(self, desc):
         self.dirstate.savebackup(None, 'journal.dirstate')
+        narrowspec.savewcbackup(self, 'journal.narrowspec')
         narrowspec.savebackup(self, 'journal.narrowspec')
         self.vfs.write("journal.branch",
                           encoding.fromlocal(self.dirstate.branch()))
@@ -2014,6 +2016,7 @@ 
             dsguard.close()
 
             narrowspec.restorebackup(self, 'undo.narrowspec')
+            narrowspec.restorewcbackup(self, 'undo.narrowspec')
             self.dirstate.restorebackup(None, 'undo.dirstate')
             try:
                 branch = self.vfs.read('undo.branch')