@@ -2712,7 +2712,8 @@
# run editor in the repository root
olddir = os.getcwd()
os.chdir(repo.root)
- text = repo.ui.edit(committext, ctx.user(), ctx.extra(), editform=editform)
+ text = repo.ui.edit(committext, ctx.user(), ctx.extra(),
+ editform=editform, repo=repo)
text = re.sub("(?m)^HG:.*(\n|$)", "", text)
os.chdir(olddir)
@@ -835,7 +835,8 @@
if self.debugflag:
opts['label'] = opts.get('label', '') + ' ui.debug'
self.write(*msg, **opts)
- def edit(self, text, user, extra=None, editform=None):
+
+ def edit(self, text, user, extra=None, editform=None, repo=None):
if extra is None:
extra = {}
(fd, name) = tempfile.mkstemp(prefix="hg-editor-", suffix=".txt",
@@ -859,7 +860,8 @@
self.system("%s \"%s\"" % (editor, name),
environ=environ,
- onerr=error.Abort, errprefix=_("edit failed"))
+ onerr=error.Abort, errprefix=_("edit failed"),
+ repo=repo)
f = open(name)
t = f.read()
@@ -19,7 +19,7 @@
Nothing to amend:
- $ hg ci --amend
+ $ hg ci --amend -m 'base1'
nothing changed
[1]
@@ -447,6 +447,92 @@
$ hg --cwd b parents --template 'parent: {rev}\n'
parent: 1
+ $ hg --cwd b update -q -C 0
+ $ hg --cwd b --config extensions.strip= strip -q 1
+
+Test visibility of in-memory distate changes inside transaction to
+external process
+
+ $ echo foo > a/foo
+ $ hg --cwd a commit -A -m 'adding foo' foo
+ $ hg --cwd a export -o '../patch%R' 3
+
+ $ cat > $TESTTMP/checkvisibility.sh <<EOF
+ > echo "===="
+ > hg parents --template "VISIBLE {rev}:{node|short}\n"
+ > hg status -amr
+ > # test that pending changes are hidden
+ > unset HG_PENDING
+ > hg parents --template "ACTUAL {rev}:{node|short}\n"
+ > hg status -amr
+ > echo "===="
+ > EOF
+
+== test visibility to external editor
+
+ $ (cd b && sh "$TESTTMP/checkvisibility.sh")
+ ====
+ VISIBLE 0:80971e65b431
+ ACTUAL 0:80971e65b431
+ ====
+
+ $ HGEDITOR="sh $TESTTMP/checkvisibility.sh" hg --cwd b import -v --edit ../patch1 ../patch2 ../patch3
+ applying ../patch1
+ patching file a
+ ====
+ VISIBLE 0:80971e65b431
+ M a
+ ACTUAL 0:80971e65b431
+ M a
+ ====
+ committing files:
+ a
+ committing manifest
+ committing changelog
+ created 1d4bd90af0e4
+ applying ../patch2
+ patching file a
+ ====
+ VISIBLE 1:1d4bd90af0e4
+ M a
+ ACTUAL 0:80971e65b431
+ M a
+ ====
+ committing files:
+ a
+ committing manifest
+ committing changelog
+ created 6d019af21222
+ applying ../patch3
+ patching file foo
+ adding foo
+ ====
+ VISIBLE 2:6d019af21222
+ A foo
+ ACTUAL 0:80971e65b431
+ M a
+ ====
+ committing files:
+ foo
+ committing manifest
+ committing changelog
+ created 55e3f75b2378
+
+ $ hg --cwd b rollback -q
+
+(content of file "a" is already changed and it should be recognized as
+"M", even though dirstate is restored to one before "hg import")
+
+ $ (cd b && sh "$TESTTMP/checkvisibility.sh")
+ ====
+ VISIBLE 0:80971e65b431
+ M a
+ ACTUAL 0:80971e65b431
+ M a
+ ====
+ $ hg --cwd b revert --no-backup a
+ $ rm -f b/foo
+
$ rm -r b
@@ -2,6 +2,13 @@
$ echo "[extensions]" >> $HGRCPATH
$ echo "mq=" >> $HGRCPATH
+ $ cat >> $HGRCPATH <<EOF
+ > [defaults]
+ > # explicit date to commit with fixed hashid
+ > qnew = -d "0 0"
+ > qrefresh = -d "0 0"
+ > qfold = -d "0 0"
+ > EOF
$ hg init
$ hg qinit
@@ -191,3 +198,47 @@
test saving last-message.txt
+
+Test visibility of in-memory distate changes outside transaction to
+external process
+
+ $ cat > $TESTTMP/checkvisibility.sh <<EOF
+ > echo "===="
+ > hg parents --template "{rev}:{node|short}\n"
+ > hg status -arm
+ > echo "===="
+ > EOF
+
+== test visibility to external editor
+
+ $ hg update -C -q first-patch
+ $ rm -f file2
+ $ hg qpush -q second-patch --config hooks.pretxncommit.unexpectedabort=
+ now at: second-patch
+ $ echo bbbb >> file2
+
+ $ sh "$TESTTMP/checkvisibility.sh"
+ ====
+ 1:e30108269082
+ M file2
+ ====
+
+ $ HGEDITOR='sh "$TESTTMP/checkvisibility.sh"' hg qrefresh -e
+ ====
+ 0:25e397dabed2
+ A file2
+ ====
+ transaction abort!
+ rollback completed
+ note: commit message saved in .hg/last-message.txt
+ refresh interrupted while patch was popped! (revert --all, qpush to recover)
+ abort: pretxncommit.unexpectedabort hook exited with status 1
+ [255]
+
+(rebuilding at failure of qrefresh bases on rev #0, and it causes
+dropping status of "file2")
+
+ $ sh "$TESTTMP/checkvisibility.sh"
+ ====
+ 0:25e397dabed2
+ ====