largefiles: specify where .orig files are kept
authorChristian Delahousse <cdelahousse@fb.com>
Tue, 10 Nov 2015 15:08:56 -0800
changeset 26944 ef5bab63af85
parent 26943 263edb591b72
child 26946 3309714ded26
largefiles: specify where .orig files are kept This patch let's the user specify where .orig files are kept using the cmdutil.origpath function
hgext/largefiles/lfcommands.py
tests/test-largefiles-misc.t
--- a/hgext/largefiles/lfcommands.py	Tue Nov 10 14:52:54 2015 -0800
+++ b/hgext/largefiles/lfcommands.py	Tue Nov 10 15:08:56 2015 -0800
@@ -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
--- a/tests/test-largefiles-misc.t	Tue Nov 10 14:52:54 2015 -0800
+++ b/tests/test-largefiles-misc.t	Tue Nov 10 15:08:56 2015 -0800
@@ -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