Patchwork [5,of,7,V4] shelve: choose where .orig file locations are kept

login
register
mail settings
Submitter Christian Delahousse
Date Nov. 11, 2015, 12:59 a.m.
Message ID <550d3afadfb753e710c7.1447203596@dev4253.prn1.facebook.com>
Download mbox | patch
Permalink /patch/11355/
State Accepted
Commit d55d22840592ee8898f19d0c227be86d9fdfbe94
Headers show

Comments

Christian Delahousse - Nov. 11, 2015, 12:59 a.m.
# HG changeset patch
# User Christian Delahousse <cdelahousse@fb.com>
# Date 1447195274 28800
#      Tue Nov 10 14:41:14 2015 -0800
# Node ID 550d3afadfb753e710c7032f8719cd82f2895b9a
# Parent  478865c9f9d44b5da48d75f9e562c55b22a6d340
shelve: choose where .orig file locations are kept

This patch uses cmdutil.origpath to let the user set the location of the orig
files.

Patch

diff --git a/hgext/shelve.py b/hgext/shelve.py
--- a/hgext/shelve.py
+++ b/hgext/shelve.py
@@ -507,7 +507,7 @@ 
         # revert will overwrite unknown files, so move them out of the way
         for file in repo.status(unknown=True).unknown:
             if file in files:
-                util.rename(file, file + ".orig")
+                util.rename(file, cmdutil.origpath(ui, repo, file))
         ui.pushbuffer(True)
         cmdutil.revert(ui, repo, shelvectx, repo.dirstate.parents(),
                        *pathtofiles(repo, files),
diff --git a/tests/test-shelve.t b/tests/test-shelve.t
--- a/tests/test-shelve.t
+++ b/tests/test-shelve.t
@@ -1135,7 +1135,7 @@ 
 
   $ cd ..
 
-test Abort unshelve always gets user out of the unshelved state
+test .orig files go where the user wants them to
 ---------------------------------------------------------------
   $ hg init salvage
   $ cd salvage
@@ -1144,10 +1144,16 @@ 
   $ echo '' > root
   $ hg shelve -q
   $ echo 'contADDent' > root
-  $ hg unshelve -q
+  $ hg unshelve -q --config 'ui.origbackuppath=.hg/origbackups'
   warning: conflicts while merging root! (edit, then use 'hg resolve --mark')
   unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue')
   [1]
+  $ ls .hg/origbackups
+  root.orig
+  $ rm -rf .hg/origbackups
+
+test Abort unshelve always gets user out of the unshelved state
+---------------------------------------------------------------
 Wreak havoc on the unshelve process
   $ rm .hg/unshelverebasestate
   $ hg unshelve --abort