[PATCH 7 of 7 V4] largefiles: specify where .orig files are kept

cdelahousse at fb.com cdelahousse at fb.com
Tue Nov 10 18:59:58 CST 2015


# HG changeset patch
# User Christian Delahousse <cdelahousse at fb.com>
# Date 1447196936 28800
#      Tue Nov 10 15:08:56 2015 -0800
# Node ID 5052089b7b19268b4c644257090506f46b7a9cfe
# Parent  1ea4093ba6f2303e968b6d25716a6b2116ecbb95
largefiles: specify where .orig files are kept

This patch let's the user specify where .orig files are kept using the
cmdutil.origpath function

diff --git a/hgext/largefiles/lfcommands.py b/hgext/largefiles/lfcommands.py
--- a/hgext/largefiles/lfcommands.py
+++ b/hgext/largefiles/lfcommands.py
@@ -444,12 +444,14 @@
         updated, removed = 0, 0
         for lfile in lfiles:
             abslfile = repo.wjoin(lfile)
+            abslfileorig = cmdutil.origpath(ui, repo, abslfile)
             absstandin = repo.wjoin(lfutil.standin(lfile))
+            absstandinorig = cmdutil.origpath(ui, repo, absstandin)
             if os.path.exists(absstandin):
-                if (os.path.exists(absstandin + '.orig') and
+                if (os.path.exists(absstandinorig) and
                     os.path.exists(abslfile)):
-                    shutil.copyfile(abslfile, abslfile + '.orig')
-                    util.unlinkpath(absstandin + '.orig')
+                    shutil.copyfile(abslfile, abslfileorig)
+                    util.unlinkpath(absstandinorig)
                 expecthash = lfutil.readstandin(repo, lfile)
                 if expecthash != '':
                     if lfile not in repo[None]: # not switched to normal file
diff --git a/tests/test-largefiles-misc.t b/tests/test-largefiles-misc.t
--- a/tests/test-largefiles-misc.t
+++ b/tests/test-largefiles-misc.t
@@ -509,6 +509,18 @@
   $ hg revert anotherlarge
   $ hg st
   ? sub/anotherlarge.orig
+
+Test orig files go where we want them
+  $ echo moremore >> anotherlarge
+  $ hg revert anotherlarge -v --config 'ui.origbackuppath=.hg/origbackups'
+  creating directory: $TESTTMP/addrm2/.hg/origbackups/.hglf/sub
+  saving current version of ../.hglf/sub/anotherlarge as $TESTTMP/addrm2/.hg/origbackups/.hglf/sub/anotherlarge.orig
+  reverting ../.hglf/sub/anotherlarge (glob)
+  creating directory: $TESTTMP/addrm2/.hg/origbackups/sub
+  found 90c622cf65cebe75c5842f9136c459333faf392e in store
+  found 90c622cf65cebe75c5842f9136c459333faf392e in store
+  $ ls ../.hg/origbackups/sub
+  anotherlarge.orig
   $ cd ..
 
 Test glob logging from the root dir


More information about the Mercurial-devel mailing list