Patchwork [2,of,5] transaction: backup file in a dedicated "namespace"

login
register
mail settings
Submitter Pierre-Yves David
Date Aug. 7, 2014, 10:52 p.m.
Message ID <4470369895a36e9603de.1407451920@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/5325/
State Accepted
Headers show

Comments

Pierre-Yves David - Aug. 7, 2014, 10:52 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1407434057 25200
#      Thu Aug 07 10:54:17 2014 -0700
# Node ID 4470369895a36e9603de8850335df283e664394c
# Parent  ee1123db6db51c45c3ea2205a0e17273c6a87930
transaction: backup file in a dedicated "namespace"

File backup may conflict with other "journal.*" file. We add a fixed part in the
backup name file to prevent it.

Patch

diff --git a/mercurial/transaction.py b/mercurial/transaction.py
--- a/mercurial/transaction.py
+++ b/mercurial/transaction.py
@@ -152,11 +152,11 @@  class transaction(object):
         * `hardlink`: use a hardlink to quickly create the backup
         """
 
         if file in self.map or file in self.backupmap:
             return
-        backupfile = "%s.%s" % (self.journal, file)
+        backupfile = "%s.backup.%s" % (self.journal, file)
         if self.opener.exists(file):
             filepath = self.opener.join(file)
             backuppath = self.opener.join(backupfile)
             util.copyfiles(filepath, backuppath, hardlink=hardlink)
         else: