mercurial/narrowspec.py
branchstable
changeset 41298 88a7c211b21e
parent 41238 8c366af085f4
child 41687 0531dff73d0b
--- a/mercurial/narrowspec.py	Fri Jan 18 14:21:47 2019 +0100
+++ b/mercurial/narrowspec.py	Fri Jan 18 23:32:26 2019 -0800
@@ -190,12 +190,14 @@
 def restorewcbackup(repo, backupname):
     if repository.NARROW_REQUIREMENT not in repo.requirements:
         return
-    util.rename(repo.vfs.join(backupname), repo.vfs.join(DIRSTATE_FILENAME))
+    # It may not exist in old repos
+    if repo.vfs.exists(backupname):
+        util.rename(repo.vfs.join(backupname), repo.vfs.join(DIRSTATE_FILENAME))
 
 def clearwcbackup(repo, backupname):
     if repository.NARROW_REQUIREMENT not in repo.requirements:
         return
-    repo.vfs.unlink(backupname)
+    repo.vfs.tryunlink(backupname)
 
 def restrictpatterns(req_includes, req_excludes, repo_includes, repo_excludes):
     r""" Restricts the patterns according to repo settings,