mq: teach qpop about symlinks
authorBryan O'Sullivan <bos@serpentine.com>
Thu, 09 Aug 2007 20:16:00 -0700
changeset 5157 f6c520fd70cf
parent 5156 49554ba98951
child 5158 d316124ebbea
mq: teach qpop about symlinks
hgext/mq.py
tests/test-mq-symlinks
tests/test-mq-symlinks.out
--- a/hgext/mq.py	Thu Aug 09 20:03:34 2007 -0700
+++ b/hgext/mq.py	Thu Aug 09 20:16:00 2007 -0700
@@ -810,9 +810,9 @@
             del wlock
 
     def pop(self, repo, patch=None, force=False, update=True, all=False):
-        def getfile(f, rev):
+        def getfile(f, rev, flags):
             t = repo.file(f).read(rev)
-            repo.wfile(f, "w").write(t)
+            repo.wwrite(f, t, flags)
 
         wlock = repo.wlock()
         try:
@@ -870,10 +870,9 @@
                 if d:
                     raise util.Abort("deletions found between repo revs")
                 for f in m:
-                    getfile(f, mmap[f])
+                    getfile(f, mmap[f], mmap.flags(f))
                 for f in r:
-                    getfile(f, mmap[f])
-                    util.set_exec(repo.wjoin(f), mmap.execf(f))
+                    getfile(f, mmap[f], mmap.flags(f))
                 for f in m + r:
                     repo.dirstate.normal(f)
                 for f in a:
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-mq-symlinks	Thu Aug 09 20:16:00 2007 -0700
@@ -0,0 +1,34 @@
+#!/bin/sh
+
+echo "[extensions]" >> $HGRCPATH
+echo "mq=" >> $HGRCPATH
+
+cat >> readlink.py <<EOF
+import errno, os, sys
+
+for f in sys.argv[1:]:
+    try:
+        print f, '->', os.readlink(f)
+    except OSError, err:
+        if err.errno != errno.EINVAL: raise
+        print f, 'not a symlink'
+EOF
+
+hg init
+hg qinit
+hg qnew base.patch
+echo a > a
+echo b > b
+hg add a b
+hg qrefresh
+python readlink.py a
+
+hg qnew symlink.patch
+rm a
+ln -s b a
+hg qrefresh --git
+python readlink.py a
+
+hg qpop
+hg qpush
+python readlink.py a
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-mq-symlinks.out	Thu Aug 09 20:16:00 2007 -0700
@@ -0,0 +1,6 @@
+a -> a not a symlink
+a -> b
+Now at: base.patch
+applying symlink.patch
+Now at: symlink.patch
+a -> b