Patchwork [STABLE,V2] shelve: make unshelve work even if it don't run in repository root

login
register
mail settings
Submitter Takumi IINO
Date Oct. 22, 2013, 3:24 p.m.
Message ID <4de11687104461f816da.1382455442@iino-no-MacBook-Air.local>
Download mbox | patch
Permalink /patch/2804/
State Accepted
Commit 4de11687104461f816dab51958a406823242b85b
Headers show

Comments

Takumi IINO - Oct. 22, 2013, 3:24 p.m.
# HG changeset patch
# User Takumi IINO <trot.thunder@gmail.com>
# Date 1382413265 -32400
#      Tue Oct 22 12:41:05 2013 +0900
# Branch stable
# Node ID 4de11687104461f816dab51958a406823242b85b
# Parent  2c886dedd9021598b6290d95ea0f068731ea4e2b
shelve: make unshelve work even if it don't run in repository root

revertfiles are relative to the repository root. not paths relative to the cwd.
Augie Fackler - Oct. 22, 2013, 6:28 p.m.
On Wed, Oct 23, 2013 at 12:24:02AM +0900, Takumi IINO wrote:
> # HG changeset patch
> # User Takumi IINO <trot.thunder@gmail.com>
> # Date 1382413265 -32400
> #      Tue Oct 22 12:41:05 2013 +0900
> # Branch stable
> # Node ID 4de11687104461f816dab51958a406823242b85b
> # Parent  2c886dedd9021598b6290d95ea0f068731ea4e2b
> shelve: make unshelve work even if it don't run in repository root

queued for stable, thanks

>
> revertfiles are relative to the repository root. not paths relative to the cwd.
>
> diff --git a/hgext/shelve.py b/hgext/shelve.py
> --- a/hgext/shelve.py
> +++ b/hgext/shelve.py
> @@ -358,6 +358,10 @@
>          raise util.Abort(_('working directory parents do not match unshelve '
>                             'state'))
>
> +def pathtofiles(repo, files):
> +    cwd = repo.getcwd()
> +    return [repo.pathto(f, cwd) for f in files]
> +
>  def unshelveabort(ui, repo, state, opts):
>      """subcommand that abort an in-progress unshelve"""
>      wlock = repo.wlock()
> @@ -372,7 +376,8 @@
>              revertfiles = readshelvedfiles(repo, state.name)
>              wctx = repo.parents()[0]
>              cmdutil.revert(ui, repo, wctx, [wctx.node(), nullid],
> -                           *revertfiles, **{'no_backup': True})
> +                           *pathtofiles(repo, revertfiles),
> +                           **{'no_backup': True})
>              # fix up the weird dirstate states the merge left behind
>              mf = wctx.manifest()
>              dirstate = repo.dirstate
> @@ -532,7 +537,8 @@
>                  revertfiles = set(parents[1].files()).difference(ms)
>                  cmdutil.revert(ui, repo, parents[1],
>                                 (parents[0].node(), nullid),
> -                               *revertfiles, **{'no_backup': True})
> +                               *pathtofiles(repo, revertfiles),
> +                               **{'no_backup': True})
>                  raise error.InterventionRequired(
>                      _("unresolved conflicts (see 'hg resolve', then "
>                        "'hg unshelve --continue')"))
> @@ -540,7 +546,8 @@
>          else:
>              parent = tip.parents()[0]
>              hg.update(repo, parent.node())
> -            cmdutil.revert(ui, repo, tip, repo.dirstate.parents(), *tip.files(),
> +            cmdutil.revert(ui, repo, tip, repo.dirstate.parents(),
> +                           *pathtofiles(repo, tip.files()),
>                             **{'no_backup': True})
>
>          prevquiet = ui.quiet
> diff --git a/tests/test-shelve.t b/tests/test-shelve.t
> --- a/tests/test-shelve.t
> +++ b/tests/test-shelve.t
> @@ -165,7 +165,9 @@
>
>  and now "a/a" should reappear
>
> +  $ cd a
>    $ hg unshelve -q wibble
> +  $ cd ..
>    $ hg status -C
>    M a/a
>    A b.rename/b
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel

Patch

diff --git a/hgext/shelve.py b/hgext/shelve.py
--- a/hgext/shelve.py
+++ b/hgext/shelve.py
@@ -358,6 +358,10 @@ 
         raise util.Abort(_('working directory parents do not match unshelve '
                            'state'))
 
+def pathtofiles(repo, files):
+    cwd = repo.getcwd()
+    return [repo.pathto(f, cwd) for f in files]
+
 def unshelveabort(ui, repo, state, opts):
     """subcommand that abort an in-progress unshelve"""
     wlock = repo.wlock()
@@ -372,7 +376,8 @@ 
             revertfiles = readshelvedfiles(repo, state.name)
             wctx = repo.parents()[0]
             cmdutil.revert(ui, repo, wctx, [wctx.node(), nullid],
-                           *revertfiles, **{'no_backup': True})
+                           *pathtofiles(repo, revertfiles),
+                           **{'no_backup': True})
             # fix up the weird dirstate states the merge left behind
             mf = wctx.manifest()
             dirstate = repo.dirstate
@@ -532,7 +537,8 @@ 
                 revertfiles = set(parents[1].files()).difference(ms)
                 cmdutil.revert(ui, repo, parents[1],
                                (parents[0].node(), nullid),
-                               *revertfiles, **{'no_backup': True})
+                               *pathtofiles(repo, revertfiles),
+                               **{'no_backup': True})
                 raise error.InterventionRequired(
                     _("unresolved conflicts (see 'hg resolve', then "
                       "'hg unshelve --continue')"))
@@ -540,7 +546,8 @@ 
         else:
             parent = tip.parents()[0]
             hg.update(repo, parent.node())
-            cmdutil.revert(ui, repo, tip, repo.dirstate.parents(), *tip.files(),
+            cmdutil.revert(ui, repo, tip, repo.dirstate.parents(),
+                           *pathtofiles(repo, tip.files()),
                            **{'no_backup': True})
 
         prevquiet = ui.quiet
diff --git a/tests/test-shelve.t b/tests/test-shelve.t
--- a/tests/test-shelve.t
+++ b/tests/test-shelve.t
@@ -165,7 +165,9 @@ 
 
 and now "a/a" should reappear
 
+  $ cd a
   $ hg unshelve -q wibble
+  $ cd ..
   $ hg status -C
   M a/a
   A b.rename/b