You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@subversion.apache.org by "Entner, Jonathan T." <Jo...@jhuapl.edu> on 2004/10/22 19:45:40 UTC
followup question to FAQ
This is from the FAQ:
> Why doesn't the $Revision$ keyword do what I want? It expands to the
> file's last-changed revision, but I want something that will expand
> to the file's current revision.
The answer, in summary, is that every check-in would then have to check
every file in the repository to update the $Revision$ (and other)
keywords. The suggested workaround is to add a step to the build
process to update a file with the version info from svnversion or using
SubWCRev from TortoiseSVN.
I would like to put the current version into a file in my project,
however, I do not have a build process as it is an interpretted
language -- users check it out using subversion and they run it.
So if I'm going to automate the process, it has to be within
subversion. I would like to automatically update this file with
the version information at some point in either the commit or in
the update/checkout/export processes. I like the keyword mechanism,
and given the problems with a $CurrentRevision$ type of keyword
(as described above), staying with it would require getting subversion
to commit the file every time so that it gets updated. However, the
only mechanism that I've seen thus far (I'm new to subversion) of
customizing the commit process is that of the commit hook scripts.
But I don't think that these will do it: start-commit does not have
access to the working copy to touch the file (mark as modified, in
whatever fashion), pre-commit doesn't allow changes to the transaction,
and post-commit is too late (unless one works around by immediately
checking out the file, touching it, and commiting it; I think this
could be done via a script, but leaves two commit actions for every
actual commit performed -- not very clean). Is there a way to force
a commit of a particular file for every commit transaction? Are there
any ways to customize the update, checkout, and export actions? Is
there some other way to do what I'd like to do that I've completely
overlooked?
---
Jonathan Entner
jonathan.entner@jhuapl.edu
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Re: followup question to FAQ
Posted by "C. Michael Pilato" <cm...@collab.net>.
"C. Michael Pilato" <cm...@collab.net> writes:
> So, I actually gave this idea a shot, and to my surprise, it doesn't
> work. But it doesn't work for non-obvious reasons. I might have
> uncovered a bug here. Watch this space for more.
Yep. It's a bug.
Say two users, Harry and Sally, each checkout working copies of the
HEAD of a project. Harry sets a new property on a file in that
project, and commits. He then decides that Sally's gonna beat him up
for doing that, so he removes the property from the file, and commits
again. Later, Sally updates her working copy, and sees no changes
come down from the server.
None at all.
Not even a no-op change to the file.
In fact, the file's $Rev$ keyword doesn't even change. It's as if
Harry had never touched that file at all.
And that, my fair Subversion users, is what we call a bug.
I have confirmed that the server is doing the right thing. The client
code must be swallowing up the change incorrectly.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Re: followup question to FAQ
Posted by "C. Michael Pilato" <cm...@collab.net>.
"C. Michael Pilato" <cm...@collab.net> writes:
> "Entner, Jonathan T." <Jo...@jhuapl.edu> writes:
>
> > Is there a way to force a commit of a particular file for every
> > commit transaction?
>
> DISCLAIMER: THE FOLLOWING HAS NOT BEEN ATTEMPTED. I'M NOT RESPONSIBLE
> FOR ANY NEGATIVE RESULTS THAT OCCUR FROM IT BEING ATTEMPTED.
> UNDERSTAND THAT SUBVERSION BEHAVIOR MAY CHANGE SUCH THAT THIS NO
> LONGER WORKS, IN WHICH CASE -- TOUGH LUCK, BUCK-O.
>
> So, the problem with modifying files in the pre-commit phase is the
> danger of the working copy claiming to have something that it does
> not. I wonder, though, if you could write a pre-commit hook that
> "touches" a particular file in such a way that a new revision of that
> file would be generated, but that the working copy wouldn't really
> care. For example, your script could set some property on the file
> that it doesn't already have, and then immediately remove that
> property, and then allow the commit to proceed. I think that would
> sufficiently fool the Subversion filesystem into generating a new
> revision of that file without completely horking your working copy.
So, I actually gave this idea a shot, and to my surprise, it doesn't
work. But it doesn't work for non-obvious reasons. I might have
uncovered a bug here. Watch this space for more.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Re: followup question to FAQ
Posted by "C. Michael Pilato" <cm...@collab.net>.
"C. Michael Pilato" <cm...@collab.net> writes:
> "Entner, Jonathan T." <Jo...@jhuapl.edu> writes:
>
> > Is there a way to force a commit of a particular file for every
> > commit transaction?
>
> DISCLAIMER: THE FOLLOWING HAS NOT BEEN ATTEMPTED. I'M NOT RESPONSIBLE
> FOR ANY NEGATIVE RESULTS THAT OCCUR FROM IT BEING ATTEMPTED.
> UNDERSTAND THAT SUBVERSION BEHAVIOR MAY CHANGE SUCH THAT THIS NO
> LONGER WORKS, IN WHICH CASE -- TOUGH LUCK, BUCK-O.
>
> So, the problem with modifying files in the pre-commit phase is the
> danger of the working copy claiming to have something that it does
> not. I wonder, though, if you could write a pre-commit hook that
> "touches" a particular file in such a way that a new revision of that
> file would be generated, but that the working copy wouldn't really
> care. For example, your script could set some property on the file
> that it doesn't already have, and then immediately remove that
> property, and then allow the commit to proceed. I think that would
> sufficiently fool the Subversion filesystem into generating a new
> revision of that file without completely horking your working copy.
So, putting my monkeying where my mouth is, attached is the little
pre-commit hook script I wrote for doing just this.
Note, however, that until issue #2107 is fixed, this won't behave in
the expected manner.
--------------------------------------------------------------------------
#!/usr/bin/env python
# touchit.py REPOS-PATH TXN-NAME PATH
#
# Call this script from your pre-commit hook, specifying the path in
# the repository of a version file that you'd like "touched" after
# every commit.
#
# E.g.:
#
# /path/to/touchit.py $1 $2 trunk/version.txt
#
import sys
from svn import core, repos, fs
if len(sys.argv) < 4:
sys.stderr.write("Usage: touchit.py REPOS-PATH TXN-NAME PATH\n")
sys.exit(1)
repos_path = sys.argv[1]
txn = sys.argv[2]
path = sys.argv[3]
core.apr_initialize()
pool = None
try:
pool = core.svn_pool_create(None)
reposobj = repos.svn_repos_open(repos_path, pool)
fsobj = repos.svn_repos_fs(reposobj)
txnobj = fs.open_txn(fsobj, txn, pool)
root = fs.txn_root(txnobj, pool)
pname = None
for i in range(100000):
pname = "touchit-%d" % i
pval = fs.node_prop(root, path, pname, pool)
if pval is None:
break
fs.change_node_prop(root, path, pname, "FOO", pool)
fs.change_node_prop(root, path, pname, None, pool)
finally:
if pool is not None:
core.svn_pool_destroy(pool)
core.apr_terminate()
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Re: followup question to FAQ
Posted by "C. Michael Pilato" <cm...@collab.net>.
"Entner, Jonathan T." <Jo...@jhuapl.edu> writes:
> Is there a way to force a commit of a particular file for every
> commit transaction?
DISCLAIMER: THE FOLLOWING HAS NOT BEEN ATTEMPTED. I'M NOT RESPONSIBLE
FOR ANY NEGATIVE RESULTS THAT OCCUR FROM IT BEING ATTEMPTED.
UNDERSTAND THAT SUBVERSION BEHAVIOR MAY CHANGE SUCH THAT THIS NO
LONGER WORKS, IN WHICH CASE -- TOUGH LUCK, BUCK-O.
So, the problem with modifying files in the pre-commit phase is the
danger of the working copy claiming to have something that it does
not. I wonder, though, if you could write a pre-commit hook that
"touches" a particular file in such a way that a new revision of that
file would be generated, but that the working copy wouldn't really
care. For example, your script could set some property on the file
that it doesn't already have, and then immediately remove that
property, and then allow the commit to proceed. I think that would
sufficiently fool the Subversion filesystem into generating a new
revision of that file without completely horking your working copy.
> Are there any ways to customize the update, checkout, and export
> actions?
Well, you have access to the same source code we do, but .... :-)
"No," is probably the realistic answer, though.
> Is there some other way to do what I'd like to do that I've
> completely overlooked?
That depends on what you want to do, really.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org