Hi all.
Here is an updated patch that implements `cvs diff -N` style functionality for
subversion. The old post that explains this can be found here:
http://subversion.tigris.org/servlets/ReadMsg?msgId=37437&listName=dev
cheers
Mo
2001-10-03 Mo DeJong <supermo@bayarea.net>
* subversion/clients/cmdline/diff.c: If a new file has been
added, display it in the diff output. Implement this by
creating an empty file in the admin directory before
running diff.
Index: subversion/clients/cmdline/diff.c
===================================================================
--- subversion/clients/cmdline/.svn/text-base/diff.c Wed Oct 3 13:29:27 2001
+++ subversion/clients/cmdline/diff.c Wed Oct 3 17:41:06 2001
@@ -109,6 +109,7 @@
svn_boolean_t text_is_modified = FALSE;
apr_wait_t proc_status;
const char **args;
+ svn_boolean_t pristine_existed;
int i = 0;
apr_file_t *outhandle = NULL;
@@ -127,6 +128,29 @@
/* Get a PRISTINE_COPY_PATH to compare against. */
SVN_ERR (svn_client_file_diff (path, &pristine_copy_path, pool));
+ /* If the PRISTINE_COPY_PATH file does not exist the diff will fail.
+ Create an empty file so the generated patch will add the new file. */
+
+ status = apr_file_open (&outhandle, pristine_copy_path->data, APR_READ,
+ APR_OS_DEFAULT, pool);
+ if (!status)
+ {
+ apr_file_close (outhandle);
+ pristine_existed = TRUE;
+ }
+ else
+ {
+ pristine_existed = FALSE;
+ status = apr_file_open (&outhandle, pristine_copy_path->data,
+ APR_READ | APR_CREATE,
+ APR_OS_DEFAULT, pool);
+ if (status)
+ return svn_error_create (status, 0, NULL, pool,
+ "error: can't touch pristine copy");
+ else
+ apr_file_close (outhandle);
+ }
+
/* Get an apr_file_t representing stdout, which is where we'll have
the diff program print to. */
status = apr_file_open_stdout (&outhandle, pool);
@@ -174,6 +198,14 @@
makes use of the two paths, instead of just blindly running
SVN_CLIENT_DIFF.
*/
+
+ if (!pristine_existed)
+ {
+ apr_file_remove (pristine_copy_path->data, pool);
+ if (status)
+ return svn_error_create (status, 0, NULL, pool,
+ "error: can't delete tmp pristine copy");
+ }
return SVN_NO_ERROR;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sat Oct 21 14:36:44 2006