为什么 subversion 在提交时会切换到父目录

发布于 2025-01-06 13:14:34 字数 847 浏览 0 评论 0 原文

当我从 unix 命令行执行 svn commit 时,它会在打开编辑器之前切换到父目录。当我进行 shell escape 时,这会引起很大的混乱,因为我不在我认为的地方。

这种行为的原因是什么?

(编辑)下面的屏幕截图显示这种情况发生在最低目录中,而没有发生在最顶层目录

svn --version svn, version 1.5.5 (r34862)

test: svn checkout file:///export/home/svn/xxx/a
A    a/b
A    a/b/c
A    a/b/c/new
Checked out revision 8882.

test: cd a/b/c
test: pwd
/home/geretz/test/a/b/c
test: echo changed > new
test: svn commit

--This line, and those below, will be ignored--

M    c/new
~
~
:!pwd
/home/geretz/test/a/b

Hit ENTER or type command to continue

中止编辑会话,尝试从顶级目录提交

test: pwd
/home/geretz/test/a/b/c
test: cd ../..
test: pwd
/home/geretz/test/a
test: svn commit

--This line, and those below, will be ignored--

M    b/c/new
~
~
:!pwd
/home/geretz/test/a

Hit ENTER or type command to continue

When I do a svn commit from the unix command line it switches to the parent directory before opening up the editor. This caues great confusion when I do a shell escape since I'm not where I think I am.

What is the reason for this behavior ?

(Edit) Below screen captures show this happening in the lowest directory and not happening in the topmost one

svn --version svn, version 1.5.5 (r34862)

test: svn checkout file:///export/home/svn/xxx/a
A    a/b
A    a/b/c
A    a/b/c/new
Checked out revision 8882.

test: cd a/b/c
test: pwd
/home/geretz/test/a/b/c
test: echo changed > new
test: svn commit

--This line, and those below, will be ignored--

M    c/new
~
~
:!pwd
/home/geretz/test/a/b

Hit ENTER or type command to continue

abort the editing session, try to commit from top level directory

test: pwd
/home/geretz/test/a/b/c
test: cd ../..
test: pwd
/home/geretz/test/a
test: svn commit

--This line, and those below, will be ignored--

M    b/c/new
~
~
:!pwd
/home/geretz/test/a

Hit ENTER or type command to continue

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

耳根太软 2025-01-13 13:14:34

如果您浏览 svn 源代码,您会发现 svn commit 是由 http://svn.apache.org/repos/asf/subversion/branches/1.5.x/subversion/svn/commit-cmd.c。负责将路径拆分为“basename”和“dirname”的实际函数是svn_wc_get_actual_target。该函数在 http:// 中声明svn.apache.org/repos/asf/subversion/branches/1.5.x/subversion/include/svn_wc.h 并有以下评论:

/** Conditionally split @a path into an @a anchor and @a target for the
 * purpose of updating and committing.
 *
 * @a anchor is the directory at which the update or commit editor
 * should be rooted.
 *
 * @a target is the actual subject (relative to the @a anchor) of the
 * update/commit, or "" if the @a anchor itself is the subject.
 *
 * Allocate @a anchor and @a target in @a pool.
 */

最后在文件 http://svn.apache.org/repos /asf/subversion/branches/1.5.x/subversion/libsvn_wc/update_editor.c 我们可以看到以下评论:

Updates are accomplished by driving an editor, and an editor is
"rooted" on a directory.  So, in order to update a file, we need to
break off the basename of the file, rooting the editor in that
file's parent directory, and then updating only that file, not the
other stuff in its parent directory.

Secondly, we look at the case where we wish to update a directory.
This is typically trivial.  However, one problematic case, exists
when we wish to update a directory that has been removed from the
repository and replaced with a file of the same name.  If we root
our edit at the initial directory, there is no editor mechanism for
deleting that directory and replacing it with a file (this would be
like having an editor now anchored on a file, which is disallowed).

All that remains is to have a function with the knowledge required
to properly decide where to root our editor, and what to act upon
with that now-rooted editor.  Given a path to be updated, this
function should conditionally split that path into an "anchor" and
a "target", where the "anchor" is the directory at which the update
editor is rooted (meaning, editor->open_root() is called with
this directory in mind), and the "target" is the actual intended
subject of the update.

svn_wc_get_actual_target() is that function.

...

As it turns out, commits need to have a similar check in place,
too, specifically for the case where a single directory is being
committed (we have to anchor at that directory's parent in case the
directory itself needs to be modified)

If you browse svn sources, you find that svn commit is handled by svn_cl__commit function in http://svn.apache.org/repos/asf/subversion/branches/1.5.x/subversion/svn/commit-cmd.c. Actual function which takes care about splitting pathes to 'basename' and 'dirname' is svn_wc_get_actual_target. This function is declared in http://svn.apache.org/repos/asf/subversion/branches/1.5.x/subversion/include/svn_wc.h and has following comment:

/** Conditionally split @a path into an @a anchor and @a target for the
 * purpose of updating and committing.
 *
 * @a anchor is the directory at which the update or commit editor
 * should be rooted.
 *
 * @a target is the actual subject (relative to the @a anchor) of the
 * update/commit, or "" if the @a anchor itself is the subject.
 *
 * Allocate @a anchor and @a target in @a pool.
 */

And finally in file http://svn.apache.org/repos/asf/subversion/branches/1.5.x/subversion/libsvn_wc/update_editor.c we can see following comment:

Updates are accomplished by driving an editor, and an editor is
"rooted" on a directory.  So, in order to update a file, we need to
break off the basename of the file, rooting the editor in that
file's parent directory, and then updating only that file, not the
other stuff in its parent directory.

Secondly, we look at the case where we wish to update a directory.
This is typically trivial.  However, one problematic case, exists
when we wish to update a directory that has been removed from the
repository and replaced with a file of the same name.  If we root
our edit at the initial directory, there is no editor mechanism for
deleting that directory and replacing it with a file (this would be
like having an editor now anchored on a file, which is disallowed).

All that remains is to have a function with the knowledge required
to properly decide where to root our editor, and what to act upon
with that now-rooted editor.  Given a path to be updated, this
function should conditionally split that path into an "anchor" and
a "target", where the "anchor" is the directory at which the update
editor is rooted (meaning, editor->open_root() is called with
this directory in mind), and the "target" is the actual intended
subject of the update.

svn_wc_get_actual_target() is that function.

...

As it turns out, commits need to have a similar check in place,
too, specifically for the case where a single directory is being
committed (we have to anchor at that directory's parent in case the
directory itself needs to be modified)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文