diff hgext/shelve.py @ 19943:4de116871044 stable

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.
author Takumi IINO <trot.thunder@gmail.com>
date Tue, 22 Oct 2013 12:41:05 +0900
parents 1c58e368fbfd
children d51c4d85ec23
line wrap: on
line diff
--- a/hgext/shelve.py	Mon Oct 21 10:50:58 2013 -0700
+++ b/hgext/shelve.py	Tue Oct 22 12:41:05 2013 +0900
@@ -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