[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

[PATCH] svn up with externals

From: Vladimir Prus <ghost_at_cs.msu.su>
Date: 2002-11-04 09:07:56 CET

The problem I'm trying to solve is that if I
have "svn:externals" on some directory, change to
that directory and run "svn up", then externals are
not updated. The patch below fixes that, and passes
"make check". I've also added appropriate test to
module_tests.py.

The problem was in libsvn_wc/adm_crawler.c/report_revisions().
According to comment, it should "... record this directory's
value of svn:externals in ...". However, it recorded svn:external
value of children directories. So, when "svn up" is called,
svn:externals for "." are not recorded in that function.

Log messages:
Make "svn up" traverse externals on update targets, not only
on chilren of update targets.

     * subversion/libsvn_wc/adm_crawler.c (report_revision):
        Store "svn:externals" for current dir, not for children.

     * subversion/tests/clients/cmdline/module_tests.py
        (update_receive_change_under_external): New test.

Patch:
Index: subversion/libsvn_wc/adm_crawler.c
===================================================================
--- subversion/libsvn_wc/adm_crawler.c (revision 3607)
+++ subversion/libsvn_wc/adm_crawler.c (working copy)
@@ -101,7 +101,7 @@
     DIR_REV. If so, report this fact to REPORTER. If an entry is
     missing from disk, report its absence to REPORTER.

- If RECURSE, and TRAVERSAL_INFO is non-null, record this directory's
+ If TRAVERSAL_INFO is non-null, record this directory's
     value of svn:externals in both TRAVERSAL_INFO->externals_old and
     TRAVERSAL_INFO->externals_new, using wc_path + dir_path as the key,
     and the raw (unparsed) value of the property as the value. NOTE:
@@ -152,6 +152,32 @@
    this_path = apr_pstrdup (subpool, dir_path);
    this_full_path = apr_pstrdup (subpool, full_path);

+
+ /* If "this dir" has "svn:externals" property set on it, store its name
+ in traversal_info. */
+ if (traversal_info)
+ {
+ const svn_string_t *val_s;
+ SVN_ERR (svn_wc_prop_get
+ (&val_s, SVN_PROP_EXTERNALS, this_full_path, pool));
+
+ if (val_s)
+ {
+ const char *dup_path = apr_pstrdup (traversal_info->pool,
+ this_full_path);
+ const char *dup_val = apr_pstrmemdup (traversal_info->pool,
+ val_s->data,
+ val_s->len);
+
+ apr_hash_set (traversal_info->externals_old,
+ dup_path, APR_HASH_KEY_STRING, dup_val);
+
+ apr_hash_set (traversal_info->externals_new,
+ dup_path, APR_HASH_KEY_STRING, dup_val);
+ }
+ }
+
+
    /* Looping over current directory's SVN entries: */
    for (hi = apr_hash_first (subpool, entries); hi; hi = apr_hash_next (hi))
      {
@@ -313,29 +339,6 @@
              SVN_ERR (reporter->set_path (report_baton,
                                           this_path,
                                           subdir_entry->revision));
-
- if (traversal_info)
- {
- const svn_string_t *val_s;
- const char *dup_path = apr_pstrdup (traversal_info->pool,
- this_full_path);
-
- SVN_ERR (svn_wc_prop_get
- (&val_s, SVN_PROP_EXTERNALS, this_full_path, pool));
-
- if (val_s)
- {
- const char *dup_val = apr_pstrmemdup (traversal_info->pool,
- val_s->data,
- val_s->len);
-
- apr_hash_set (traversal_info->externals_old,
- dup_path, APR_HASH_KEY_STRING, dup_val);
-
- apr_hash_set (traversal_info->externals_new,
- dup_path, APR_HASH_KEY_STRING, dup_val);
- }
- }

            /* Recurse. */
            SVN_ERR (report_revisions (adm_access, this_path,
Index: subversion/tests/clients/cmdline/module_tests.py
===================================================================
--- subversion/tests/clients/cmdline/module_tests.py (revision 3607)
+++ subversion/tests/clients/cmdline/module_tests.py (working copy)
@@ -615,6 +615,41 @@
      return 1
    fp.close()

+ # Commit more modifications
+ other_rho_path = os.path.join(other_wc_dir, 'A', 'D', 'G', 'rho')
+ svntest.main.file_append(other_rho_path, "\nNew text in other rho.")
+
+ expected_output = svntest.wc.State(other_wc_dir, {
+ 'A/D/G/rho' : Item(verb='Sending'),
+ })
+ expected_status = svntest.actions.get_virginal_state(other_wc_dir, 5)
+ expected_status.tweak(repos_rev=7)
+ expected_status.tweak('A/D/gamma', wc_rev=6)
+ expected_status.tweak('A/D/G/rho', wc_rev=7)
+ if svntest.actions.run_and_verify_commit(other_wc_dir,
+ expected_output,
+ expected_status,
+ None, None, None, None, None,
+ other_wc_dir):
+ print "commit from other working copy failed"
+ return 1
+
+ out_lines, err_lines = svntest.main.run_svn (None, 'up', os.path.join(wc_dir, "A", "B"))
+ if err_lines: return 1
+
+ external_rho_path = os.path.join(wc_dir, 'A', 'B', 'exdir_G', 'rho')
+ fp = open(external_rho_path, 'r')
+ lines = fp.readlines()
+ if not ((len(lines) == 2)
+ and (lines[0] == "This is the file 'rho'.\n")
+ and (lines[1] == "New text in other rho.")):
+ print "Unexpected contents for externally modified ", external_rho_path
+ return 1
+ fp.close()
+
+
+
+
    return 0

  ########################################################################

- Volodya

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Mon Nov 4 09:07:28 2002

This is an archived mail posted to the Subversion Dev mailing list.