[PATCH stable] largefiles: make update with backup files in .hglf slightly less broken

Mads Kiilerich mads at kiilerich.com
Tue Jan 8 11:12:57 CST 2013


# HG changeset patch
# User Mads Kiilerich <madski at unity3d.com>
# Date 1357665132 -3600
# Branch stable
# Node ID e7ee3a7511d935ecb38e28a7246176e63d8441fa
# Parent  0f9013112ebae38ae07ad58501b64a38757aeea9
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.

diff --git a/hgext/largefiles/lfcommands.py b/hgext/largefiles/lfcommands.py
--- a/hgext/largefiles/lfcommands.py
+++ b/hgext/largefiles/lfcommands.py
@@ -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
diff --git a/tests/test-largefiles.t b/tests/test-largefiles.t
--- a/tests/test-largefiles.t
+++ b/tests/test-largefiles.t
@@ -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


More information about the Mercurial-devel mailing list