Patchwork [3,of,7,V4] git-subrepos: revert respects specified location to save .orig files

login
register
mail settings
Submitter Christian Delahousse
Date Nov. 11, 2015, 12:59 a.m.
Message ID <5b514003a1afb3e9823a.1447203594@dev4253.prn1.facebook.com>
Download mbox | patch
Permalink /patch/11358/
State Accepted
Commit 91786f20db83bf5cecdc82ecebf99a597c4335b5
Headers show

Comments

Christian Delahousse - Nov. 11, 2015, 12:59 a.m.
# HG changeset patch
# User Christian Delahousse <cdelahousse@fb.com>
# Date 1447194553 28800
#      Tue Nov 10 14:29:13 2015 -0800
# Node ID 5b514003a1afb3e9823a6849f11a77fe98b6f5d0
# Parent  1ecc53f8ab6aaed2731343b5a3fac18ad4243f04
git-subrepos: revert respects specified location to save .orig files

This patch makes revert in git subrepos save .orig files where the user wants
them by using the cmdutil.origpath function.

Patch

diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
--- a/mercurial/subrepo.py
+++ b/mercurial/subrepo.py
@@ -1910,7 +1910,7 @@ 
             status = self.status(None)
             names = status.modified
             for name in names:
-                bakname = "%s.orig" % name
+                bakname = cmdutil.origpath(self.ui, self._subparent, name)
                 self.ui.note(_('saving current version of %s as %s\n') %
                         (name, bakname))
                 self.wvfs.rename(name, bakname)
diff --git a/tests/test-subrepo-git.t b/tests/test-subrepo-git.t
--- a/tests/test-subrepo-git.t
+++ b/tests/test-subrepo-git.t
@@ -875,6 +875,16 @@ 
   $ hg status --subrepos
   ? s/barfoo
 
+revert moves orig files to the right place
+  $ echo 'bloop' > s/foobar
+  $ hg revert --all --verbose --config 'ui.origbackuppath=.hg/origbackups'
+  reverting subrepo ../gitroot
+  creating directory: $TESTTMP/tc/.hg/origbackups
+  saving current version of foobar as $TESTTMP/tc/.hg/origbackups/foobar.orig
+  $ ls .hg/origbackups
+  foobar.orig
+  $ rm -rf .hg/origbackups
+
 show file at specific revision
   $ cat > s/foobar << EOF
   > woop    woop