[PATCH] record: do not lose permissions on commit
Steve Borho
steve at borho.org
Sun Jan 25 16:04:12 CST 2009
# HG changeset patch
# User Steve Borho <steve at borho.org>
# Date 1232914729 21600
# Node ID 00975b5bb48518a601e45fb946c564c421b61c2d
# Parent 011e69b96c69ca05463eed8306cfb24348483d5b
record: do not lose permissions on commit
diff --git a/hgext/record.py b/hgext/record.py
--- a/hgext/record.py
+++ b/hgext/record.py
@@ -10,7 +10,7 @@
from mercurial.i18n import gettext, _
from mercurial import cmdutil, commands, extensions, hg, mdiff, patch
from mercurial import util
-import copy, cStringIO, errno, operator, os, re, tempfile
+import copy, cStringIO, errno, operator, os, re, shutil, tempfile
lines_re = re.compile(r'@@ -(\d+),(\d+) \+(\d+),(\d+) @@\s*(.*)')
@@ -469,6 +469,9 @@
# 3a. apply filtered patch to clean repo (clean)
if backups:
hg.revert(repo, repo.dirstate.parents()[0], backups.has_key)
+ # Copy permissions back to cleaned files
+ for realname, tmpname in backups.iteritems():
+ shutil.copymode(tmpname, repo.wjoin(realname))
# 3b. (apply)
if dopatch:
diff --git a/tests/test-record b/tests/test-record
--- a/tests/test-record
+++ b/tests/test-record
@@ -264,3 +264,13 @@
f
EOF
echo; hg tip -p
+
+echo % preserve permission changes
+chmod +x f1
+echo a >> f1
+hg record -d '20 0' -mz <<EOF
+y
+y
+y
+EOF
+echo; hg tip --config diff.git=True -p
diff --git a/tests/test-record.out b/tests/test-record.out
--- a/tests/test-record.out
+++ b/tests/test-record.out
@@ -493,3 +493,29 @@
a
+a
+% preserve permission changes
+diff --git a/subdir/f1 b/subdir/f1
+old mode 100644
+new mode 100755
+1 hunks, 1 lines changed
+examine changes to 'subdir/f1'? [Ynsfdaq?] @@ -1,2 +1,3 @@
+ a
+ a
++a
+record this change to 'subdir/f1'? [Ynsfdaq?]
+changeset: 22:a891589cb933
+tag: tip
+user: test
+date: Thu Jan 01 00:00:20 1970 +0000
+summary: z
+
+diff --git a/subdir/f1 b/subdir/f1
+old mode 100644
+new mode 100755
+--- a/subdir/f1
++++ b/subdir/f1
+@@ -1,2 +1,3 @@
+ a
+ a
++a
+
More information about the Mercurial-devel
mailing list