[PATCH misc largefiles] largefiles: update sould only create a .orig backup of a largefile once

Mads Kiilerich mads at kiilerich.com
Sun Apr 13 11:57:28 CDT 2014


# HG changeset patch
# User Mads Kiilerich <madski at unity3d.com>
# Date 1366304178 -7200
#      Thu Apr 18 18:56:18 2013 +0200
# Node ID 6dc5d7e3d42308b6439b9d5c1471527895db74f5
# Parent  07b55fef14409ca13429e22b55422e7eebc2d79b
largefiles: update sould only create a .orig backup of a largefile once

A .orig of a standin after the update do that a .orig of the actual largefile
is created. The .orig standin was however never removed again and the largefile
.orig was thus overwritten again and again.

The fix: remove the standin .orig when it is used.

diff --git a/hgext/largefiles/lfcommands.py b/hgext/largefiles/lfcommands.py
--- a/hgext/largefiles/lfcommands.py
+++ b/hgext/largefiles/lfcommands.py
@@ -440,6 +440,7 @@ def updatelfiles(ui, repo, filelist=None
                 if (os.path.exists(absstandin + '.orig') and
                     os.path.exists(abslfile)):
                     shutil.copyfile(abslfile, abslfile + '.orig')
+                    util.unlinkpath(absstandin + '.orig')
                 expecthash = lfutil.readstandin(repo, lfile)
                 if (expecthash != '' and
                     (not os.path.exists(abslfile) or
diff --git a/tests/test-largefiles.t b/tests/test-largefiles.t
--- a/tests/test-largefiles.t
+++ b/tests/test-largefiles.t
@@ -1112,6 +1112,12 @@ Rollback on largefiles.
 
   $ echo mistake > sub2/large7
   $ hg revert sub2/large7
+  $ cat sub2/large7
+  large7
+  $ cat sub2/large7.orig
+  mistake
+  $ test ! -f .hglf/sub2/large7.orig
+
   $ hg -q update --clean -r null
   $ hg update --clean
   getting changed largefiles
@@ -1129,18 +1135,16 @@ Rollback on largefiles.
   large7
   $ cat sub2/large7.orig
   mistake
-  $ cat .hglf/sub2/large7.orig
-  9dbfb2c79b1c40981b258c3efa1b10b03f18ad31
+  $ test ! -f .hglf/sub2/large7.orig
 
-demonstrate misfeature: .orig file is overwritten on every update -C,
-also when clean:
+verify that largefile .orig file no longer is overwritten on every update -C:
   $ hg update --clean
   getting changed largefiles
   0 largefiles updated, 0 removed
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ cat sub2/large7.orig
-  large7
-  $ rm sub2/large7.orig .hglf/sub2/large7.orig
+  mistake
+  $ rm sub2/large7.orig
 
 Now "update check" is happy.
   $ hg update --check 8


More information about the Mercurial-devel mailing list