changeset 18292:40185df018d7 stable

largefiles: make update with backup files in .hglf slightly less broken Largefiles update would try to copy f to f.orig if there was a .hglf/f.orig . That is in many many ways very very wrong, but it also caused an abort if f didn't exist. Now it only tries to copy f if it exists.
author Mads Kiilerich <madski@unity3d.com>
date Thu, 10 Jan 2013 15:33:14 +0100
parents 0f9013112eba
children 65cec7fa5472 c51d2bc7a5d7
files hgext/largefiles/lfcommands.py tests/test-largefiles.t
diffstat 2 files changed, 23 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/largefiles/lfcommands.py	Fri Jan 04 19:06:42 2013 +0100
+++ b/hgext/largefiles/lfcommands.py	Thu Jan 10 15:33:14 2013 +0100
@@ -483,8 +483,8 @@
     abslfile = repo.wjoin(lfile)
     absstandin = repo.wjoin(lfutil.standin(lfile))
     if os.path.exists(absstandin):
-        if os.path.exists(absstandin+'.orig'):
-            shutil.copyfile(abslfile, abslfile+'.orig')
+        if os.path.exists(absstandin + '.orig') and os.path.exists(abslfile):
+            shutil.copyfile(abslfile, abslfile + '.orig')
         expecthash = lfutil.readstandin(repo, lfile)
         if (expecthash != '' and
             (not os.path.exists(abslfile) or
--- a/tests/test-largefiles.t	Fri Jan 04 19:06:42 2013 +0100
+++ b/tests/test-largefiles.t	Thu Jan 10 15:33:14 2013 +0100
@@ -1005,12 +1005,16 @@
   abort: uncommitted local changes
   [255]
 
-"update --clean" leaves correct largefiles in working copy.
+"update --clean" leaves correct largefiles in working copy, even when there is
+.orig files from revert in .hglf.
 
+  $ echo mistake > sub2/large7
+  $ hg revert sub2/large7
+  $ hg -q update --clean -r null
   $ hg update --clean
-  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  5 files updated, 0 files merged, 0 files removed, 0 files unresolved
   getting changed largefiles
-  1 largefiles updated, 0 removed
+  3 largefiles updated, 0 removed
   $ cat normal3
   normal3-modified
   $ cat sub/normal4
@@ -1021,6 +1025,20 @@
   large6-modified
   $ cat sub2/large7
   large7
+  $ cat sub2/large7.orig
+  mistake
+  $ cat .hglf/sub2/large7.orig
+  9dbfb2c79b1c40981b258c3efa1b10b03f18ad31
+
+demonstrate misfeature: .orig file is overwritten on every update -C,
+also when clean:
+  $ hg update --clean
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  getting changed largefiles
+  0 largefiles updated, 0 removed
+  $ cat sub2/large7.orig
+  large7
+  $ rm sub2/large7.orig .hglf/sub2/large7.orig
 
 Now "update check" is happy.
   $ hg update --check 8