You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Stefan Sperling <st...@elego.de> on 2007/12/12 21:03:52 UTC

question about the update editor (essentially)

Dear working copy gods and other svn-hacking fellows,

To create a user-visible tree conflicts report file,
I call a function called "svn_wc__write_tree_conflict_report()".

This function gets a log accumulator and an adm_access.

It fetches the entry out of the adm_access, reads tree-conflict
data from it (if any), transforms that into a human readable description
(the "report") and writes that to a temp file.

Then it uses the log to schedule a move of the temp file to the
user-visible file tree_conflicts.txt, which resides in the tree-conflicted
directory in the working copy. See below for the current implementation of
this function.

When calling this function in libsvn_wc/update_editor.c:close_directory(),
tree-conflict data about files that are deleted by the update
make it into the entry retrieved from the adm_access.

But files that the update merely edits do not appear in that entry
object at the time this function is called. They end up on disk though
when the whole update is done. It seems that changes to files are somehow
processed later than changes to directories, is that correct?

I'm now trying to find the proper place in libsvn_wc/update_editor.c
to call this function so that tree conflict data for files that are
modified by the update is present in the entry retrieved from the
adm_access when this function is run. 

Any idea where to put this function call?
Maybe I need to call it multiple times?

Both close_file() and complete_directory() seem likely candidates,
but to be honest, with my limited understanding of how the update
editor, the log and the entries files on disk interact with one
another, it's a bit hard for me to find the correct spot just by RTFS.

I thought before going into trial and error I might get an expert's
opinion on this. Thanks for helpìng me out :)

Oh, and if this whole idea is moot for some reason, tell me! Thanks.

As promised, the code for the function I want to call:

svn_error_t *
svn_wc__write_tree_conflict_report(svn_stringbuf_t *log_accum,
                                   svn_wc_adm_access_t *adm_access,
                                   apr_pool_t *pool)
{
  const char *dir_path, *native_text;
  svn_stringbuf_t *report_path_buf;
  const char *report_tmp_path, *report_path;
  apr_file_t *report_tmp_fp;
  apr_size_t written;
  const svn_wc_entry_t *entry;
  svn_wc_entry_t tmp_entry;
  apr_array_header_t *conflicts;
  svn_wc_conflict_description_t *conflict;
  svn_stringbuf_t *report;
  int i;

  /* Make sure the node is a directory.
   * Otherwise we should not have been called. */
  dir_path = svn_wc_adm_access_path(adm_access);
  SVN_ERR(svn_wc_entry(&entry, dir_path, adm_access, TRUE, pool));
  assert(entry->kind == svn_node_dir);

  conflicts = apr_array_make(pool, 0,
                             sizeof(svn_wc_conflict_description_t *));
  SVN_ERR(svn_wc__read_tree_conflicts_from_entry(conflicts, entry, pool));

  if (apr_is_empty_array(conflicts))
    return SVN_NO_ERROR;

  report = svn_stringbuf_create("", pool);
  /* Should we print dir_path and timestamp in the conflict report? */
  for (i = 0; i < conflicts->nelts; i++)
    {
      conflict = APR_ARRAY_IDX(conflicts, i,
                               svn_wc_conflict_description_t *);
      SVN_ERR(svn_wc__append_tree_conflict_to_report(report, conflict, pool));
      svn_stringbuf_appendcstr(report, "\n");
    }
  native_text = svn_utf_cstring_from_utf8_fuzzy(report->data, pool);

  /* Write the report to a temp file. */
  SVN_ERR(svn_wc_create_tmp_file2(&report_tmp_fp,
                                  &report_tmp_path,
                                  dir_path,
                                  svn_io_file_del_none,
                                  pool));
  SVN_ERR(svn_io_file_write_full(report_tmp_fp,
                                 native_text,
                                 strlen(native_text),
                                 &written,
                                 pool));
  SVN_ERR(svn_io_file_close(report_tmp_fp, pool));

  /* Loggy move the temp file to the user-visible file.
   * Assumes that the move will succeed even if another application
   * has locked the file.  Is that a safe assumption?
   */
  report_path_buf = svn_stringbuf_create(SVN_WC__TREE_CONFLICT_REPORT, pool);
  svn_stringbuf_appendcstr(report_path_buf, SVN_WC__TREE_CONFLICT_REPORT_EXT);
  report_path = svn_path_join(dir_path, report_path_buf->data, pool);
  SVN_ERR(svn_wc__loggy_move(&log_accum,
                             NULL,
                             adm_access,
                             report_tmp_path,
                             report_path,
                             FALSE,
                             pool));

  /* Update the entry with the path (relative to DIR_PATH) of the
   * user-visible report file. */
  tmp_entry.tree_conflict_report = svn_path_is_child(dir_path,
                                                     report_path, pool);
  SVN_ERR(svn_wc__loggy_entry_modify(&log_accum,
                                     adm_access,
                                     dir_path,
                                     &tmp_entry,
                                     SVN_WC__ENTRY_MODIFY_TREE_CONFLICT_REPORT,
                                     pool));
  return SVN_NO_ERROR;
}



-- 
Stefan Sperling <st...@elego.de>                 Software Developer
elego Software Solutions GmbH                            HRB 77719
Gustav-Meyer-Allee 25, Gebaeude 12        Tel:  +49 30 23 45 86 96 
13355 Berlin                              Fax:  +49 30 23 45 86 95
http://www.elego.de                 Geschaeftsfuehrer: Olaf Wagner

Re: [tree conflicts] Dropping user-visible files from the design

Posted by Stefan Sperling <st...@elego.de>.
On Wed, Dec 19, 2007 at 12:27:33AM +0100, Stefan Sperling wrote:
> Also, there is a little catch we haven't fully figured out yet:
> 
>       case 't':
>         opt_state.show_tree_conflicts = TRUE;
>         /* '-t' implies '-v', otherwise svn_wc_client3() won't return
>            the entries we need. This hack isn't user-visible. */
>         opt_state.verbose = TRUE;
>         break;
> 
> It's not user-visible because we modified the print function
> to only be verbose if -v is set and -t is not.

Sorry, that was a bit too brief to make it easy for people
to follow me :)

The "print function" is print_status() in subversion/svn/status.c,
and the code snippet above was added to subversion/svn/main.c.

-- 
Stefan Sperling <st...@elego.de>                 Software Developer
elego Software Solutions GmbH                            HRB 77719
Gustav-Meyer-Allee 25, Gebaeude 12        Tel:  +49 30 23 45 86 96 
13355 Berlin                              Fax:  +49 30 23 45 86 95
http://www.elego.de                 Geschaeftsfuehrer: Olaf Wagner

Re: [tree conflicts] Dropping user-visible files from the design

Posted by Stefan Sperling <st...@elego.de>.
On Tue, Dec 18, 2007 at 10:15:33PM +0000, Julian Foad wrote:
>> Any suggestions about what colour the exact command
>> should be?
> 
> Natural extensions of the existing commands, I should hope:
> 
> To get a brief indication
> -------------------------
> 
> $ svn status
> !      file-locally-missing-or-wrong-type
> C      file-with-text-conflict
>  C     file-with-property-conflict
> CC     file-with-text-and-property-conflict
> CC     file-with-tree-conflict
> # This last line is my suggestion for "status".

The current plan is to just show C in the first coloumn for a directory
containing one or more tree conflicts. AFAIK only the second column is
used for directories so far (to indicate property conflicts on directories).

 $ svn status
 !      file-locally-missing-or-wrong-type
 C      file-with-text-conflict
  C     file-with-property-conflict
 CC     file-with-text-and-property-conflict
 C      directory-with-tree-conflict(s)
 # This last line is my suggestion for "status".

I haven't yet thought much about what to print for a tree conflict victim,
but I don't think it's necessary to print something special because
commits from tree-conflicted directories will fail anyway, no matter what
the status of files inside it is.

> $ svn commit
> svn: Commit failed (details follow):
> svn: Aborting commit: 
> '/home/julianfoad/tmp/sandbox/file-with-tree-conflict' remains in conflict
> # I think this same message is (and should be) produced for any type of 
> conflict.

Yes.

> To get more detail
> ------------------
> 
> $ svn info file-with-property-conflict
> [...]
> Schedule: normal
> [...]
> Conflict Properties File: dir_conflicts.prej
> 
> $ svn info file-with-text-conflict
> [...]
> Schedule: normal
> [...]
> Conflict Previous Base File: f.r1000
> Conflict Previous Working File: f.mine
> Conflict Current Base File: f.r1368
> 
> $ svn info file-with-tree-conflict
> [...]
> Schedule: normal
> [...]
> Conflict Schedule: delete
> # This last line is the sort of thing I'd expect in "info".

Oh, we haven't looked at those Schedule fields 'info' prints yet.
Nice hint, thanks.
 
> $ svn status -v
> # Could possibly print more info on conflicts than plain "svn status" does.

Currently we have this (I'll try to commit this tomorrow):

stsp@ted [update_tests-44.2] $ pwd
/home/stsp/elego/svn-tree-conflicts-elego-trunk/subversion/tests/cmdline/svn-test-work/working_copies/update_tests-44.2
stsp@ted [update_tests-44.2] $ export PATH=/tmp/svn-tree-conflicts-elego-trunk-prefix/bin:$PATH
stsp@ted [update_tests-44.2] $ svn st
A  +   A/D/G/pig
D      A/D/G/pi
M      A/D/G/rho
D      A/D/G/tau
A  +   A/D/G/tiger
stsp@ted [update_tests-44.2] $ svn up
D    A/D/G/rho
D    A/D/G/tau
A    A/D/G/rhino
A    A/D/G/tapir
U    A/D/G/pi
C    A/D/G             <--- note the 'C'
Updated to revision 2.
stsp@ted [update_tests-44.2] $ svn help st | grep tree
  -t [--show-tree-conflicts] : show tree conflicts in directories, if any.
stsp@ted [update_tests-44.2] $ svn st -t A/D/G
==== Tree conflicts in 'A/D/G' ===
The update wants to delete the file 'rho'
(possibly as part of a rename operation).
You have edited 'rho' locally.

The update wants to delete the file 'tau'
(possibly as part of a rename operation).
You have deleted 'tau' locally.
Maybe you renamed it?

The update wants to edit the file 'pi'.
You have deleted 'pi' locally.
Maybe you renamed it?

stsp@ted [update_tests-44.2] $


Does this look OK?

We still need to add support for xml output.

Also, there is a little catch we haven't fully figured out yet:

      case 't':
        opt_state.show_tree_conflicts = TRUE;
        /* '-t' implies '-v', otherwise svn_wc_client3() won't return
           the entries we need. This hack isn't user-visible. */
        opt_state.verbose = TRUE;
        break;

It's not user-visible because we modified the print function
to only be verbose if -v is set and -t is not.

This is not ideal, but having the tree conflict info output in-between
lines produced by svn status -v does not look very pretty either :-/

Note that we print this from a callback that is called once per file,
so delaying the tree conflict info output to the very end is hard...

> $ svn resolve
> Conflict discovered in 'file-with-tree-conflict'.
> M    file-with-tree-conflict (mine)
> DD   file-with-tree-conflict (theirs)
> Select: (p)ostpone, (d)iff, (e)dit, (h)elp for more options : d
> [... some sort of diff ...]
> Select: (p)ostpone, (d)iff, (e)dit, (h)elp for more options : mine
> M    file-with-tree-conflict
> # it's resolved as "mine"
>
> Of course, we don't yet have a "resolve" command, only "resolved"... but we 
> could have one. (I've been thinking we need one anyway, to be able to 
> re-visit the resolutions that were postponed during an interactive merge or 
> update.)

Interactive resolution will have to come later, I don't think this is
within the scope of our current branch. Very nice idea though.
 
>> We could also add an libsvn_wc API to query the working copy about
>> tree conflict data, so 3rd party tools like tortoiseSVN could easily
>> implement their own tree conflict information display, instead of
>> having to redirect the user to a text file.
> 
> Definitely.

The API was comitted today, and it is used by "svn st --show-tree-conflicts"
which as already said I plan to commit tomorrow.

>(And if we can define an API to report all types of conflict, 
> not just tree conflicts, in a consistent way, so much the better.)

For text conflicts, it's safe to assume that the presence of text files
used by the user for resolving (e.g. file.mine) because there is only
ever one text conflict per file. The same applies to property conflicts.

This is different for tree conflicts, because they are rooted at a directory,
and there may happen more than one tree conflict in a single update/merge
operation. Hence the need to track them in the entries file, hence the need
for an API to get at that information.

-- 
Stefan Sperling <st...@elego.de>                 Software Developer
elego Software Solutions GmbH                            HRB 77719
Gustav-Meyer-Allee 25, Gebaeude 12        Tel:  +49 30 23 45 86 96 
13355 Berlin                              Fax:  +49 30 23 45 86 95
http://www.elego.de                 Geschaeftsfuehrer: Olaf Wagner

Re: [tree conflicts] Dropping user-visible files from the design

Posted by Julian Foad <ju...@btopenworld.com>.
Stefan Sperling wrote:
[...]
> When an update that caused tree conflicts has completed,
> tree conflict information is stored in the entries file.
> (This is no change of plan).
> 
> Now, instead of having a text file that mirrors that state of the data
> in the entries file lying around in the working copy, we could have either
> a separate svn command (unlikely) or an option to an existing svn command
> such as "svn status" or "svn info" display the human readable tree conflict
> description to the user.

You already know I'm in favour of this approach.

> Any suggestions about what colour the exact command
> should be?

Natural extensions of the existing commands, I should hope:

To get a brief indication
-------------------------

$ svn status
!      file-locally-missing-or-wrong-type
C      file-with-text-conflict
  C     file-with-property-conflict
CC     file-with-text-and-property-conflict
CC     file-with-tree-conflict
# This last line is my suggestion for "status".

$ svn commit
svn: Commit failed (details follow):
svn: Aborting commit: '/home/julianfoad/tmp/sandbox/file-with-tree-conflict' 
remains in conflict
# I think this same message is (and should be) produced for any type of conflict.


To get more detail
------------------

$ svn info file-with-property-conflict
[...]
Schedule: normal
[...]
Conflict Properties File: dir_conflicts.prej

$ svn info file-with-text-conflict
[...]
Schedule: normal
[...]
Conflict Previous Base File: f.r1000
Conflict Previous Working File: f.mine
Conflict Current Base File: f.r1368

$ svn info file-with-tree-conflict
[...]
Schedule: normal
[...]
Conflict Schedule: delete
# This last line is the sort of thing I'd expect in "info".


$ svn status -v
# Could possibly print more info on conflicts than plain "svn status" does.


$ svn resolve
Conflict discovered in 'file-with-tree-conflict'.
M    file-with-tree-conflict (mine)
DD   file-with-tree-conflict (theirs)
Select: (p)ostpone, (d)iff, (e)dit, (h)elp for more options : d
[... some sort of diff ...]
Select: (p)ostpone, (d)iff, (e)dit, (h)elp for more options : mine
M    file-with-tree-conflict
# it's resolved as "mine"

Of course, we don't yet have a "resolve" command, only "resolved"... but we 
could have one. (I've been thinking we need one anyway, to be able to re-visit 
the resolutions that were postponed during an interactive merge or update.)

For now, would you consider the "info" command a sufficient way to see the 
detailed description of the conflict?


> We could also add an libsvn_wc API to query the working copy about
> tree conflict data, so 3rd party tools like tortoiseSVN could easily
> implement their own tree conflict information display, instead of
> having to redirect the user to a text file.

Definitely. (And if we can define an API to report all types of conflict, not 
just tree conflicts, in a consistent way, so much the better.)

> "svn resolved <tree-conflict victim path>" would clear data about
> the tree conflict victim from the entries file, instead of removing
> the user visible file.
> 
> Oh, and if the temporary file really is desirable, we can still
> re-add it to the design later. But keeping it in sync with the
> entries file may turn out to be a bit of a burden in the long run...
> 
> Does this change sound reasonable?

Absolutely.

- Julian

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: [tree conflicts] Dropping user-visible files from the design (was: Re: question about the update editor (essentially))

Posted by Stephen Butler <sb...@elego.de>.
Quoting Stefan Sperling <st...@elego.de>:

> I propose the following:
>
> When an update that caused tree conflicts has completed,
> tree conflict information is stored in the entries file.
> (This is no change of plan).
>
> Now, instead of having a text file that mirrors that state of the data
> in the entries file lying around in the working copy, we could have either
> a separate svn command (unlikely) or an option to an existing svn command
> such as "svn status" or "svn info" display the human readable tree conflict
> description to the user. Any suggestions about what colour the exact command
> should be?
>
> We could also add an libsvn_wc API to query the working copy about
> tree conflict data, so 3rd party tools like tortoiseSVN could easily
> implement their own tree conflict information display, instead of
> having to redirect the user to a text file.
>
> "svn resolved <tree-conflict victim path>" would clear data about
> the tree conflict victim from the entries file, instead of removing
> the user visible file.
>
> Oh, and if the temporary file really is desirable, we can still
> re-add it to the design later. But keeping it in sync with the
> entries file may turn out to be a bit of a burden in the long run...
>
> Does this change sound reasonable?

Yes!  And here are two extra reasons to be shy of this temporary file.

Regards,
Steve

1. The temporary marker file is IMHO not a good way to control the
resolution of tree conflicts.

A text or property conflict is marked by unversioned marker files
(with file extensions ".mine", ".copied", ".prej", etc.).  If the
marker files have been deleted manually, Subversion will silently
remove the conflict data in the corresponding entries file.  In other
word, marker files override Subversion 's internal data.  Note that
deleting a single marker file affects only one conflict.

A tree conflict is rather different.  Since a tree conflict may refer
to paths that no longer exist in the user's working copy, we store the
conflict data in the parent directory's entries file.  A temporary
marker file would naturally list all tree conflicts in the directory.
Deleting the file could affect many conflicts, which may not be
desired.

Manually removing one conflict description from the marker file would
have no effect. Because the descriptions are localized, we can't
reliably parse them to discern the user's intent.

2. The temporary marker file might be locked by the user when we want
to update it.

The safe solution is to create new, unique filenames each time.  It
rarely causes confusion for text and property conflicts, because
Subversion generally doesn't have to update the marker files for those
types of conflicts.

For tree conflicts, we expect that user may resolve them one at a
time.  This would require refreshing a tree conflict marker file
several times, leading to multiple marker files on disk.  It might
not be obvious which file is current.

-- 

Stephen Butler | Software Developer

elego Software Solutions GmbH
Gustav-Meyer-Allee 25 | 13355 Berlin | Germany

fon: +49 30 2345 8696 | mobile: +49 163 25 45 015
fax: +49 30 2345 8695 | http://www.elegosoft.com

Geschäftsführer: Olaf Wagner | Sitz der Gesellschaft: Berlin
Amtsgericht Charlottenburg HRB 77719 | USt-IdNr: DE163214194


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org


[tree conflicts] Dropping user-visible files from the design (was: Re: question about the update editor (essentially))

Posted by Stefan Sperling <st...@elego.de>.
On Wed, Dec 12, 2007 at 10:03:52PM +0100, Stefan Sperling wrote:
> Dear working copy gods and other svn-hacking fellows,
> 
> To create a user-visible tree conflicts report file,
> I call a function called "svn_wc__write_tree_conflict_report()".

I had a nice discussion with David Glasser on IRC about this yesterday.

Somewhere in the middle of trying to explain the issue to
David, I took a step back again and thought about why we are
actually trying to create this file.

The answer I found somewhere in the very back of my head was that
as far as I recall the idea of the user-visible file was proposed
at a time where API changes were to be avoided.

Given that we are now changing existing API *and* the working copy
format anyway, what about changing the design a little, more particularly
the way tree conflict information is presented to the user?

I propose the following:

When an update that caused tree conflicts has completed,
tree conflict information is stored in the entries file.
(This is no change of plan).

Now, instead of having a text file that mirrors that state of the data
in the entries file lying around in the working copy, we could have either
a separate svn command (unlikely) or an option to an existing svn command
such as "svn status" or "svn info" display the human readable tree conflict
description to the user. Any suggestions about what colour the exact command
should be?

We could also add an libsvn_wc API to query the working copy about
tree conflict data, so 3rd party tools like tortoiseSVN could easily
implement their own tree conflict information display, instead of
having to redirect the user to a text file.

"svn resolved <tree-conflict victim path>" would clear data about
the tree conflict victim from the entries file, instead of removing
the user visible file.

Oh, and if the temporary file really is desirable, we can still
re-add it to the design later. But keeping it in sync with the
entries file may turn out to be a bit of a burden in the long run...

Does this change sound reasonable?
-- 
Stefan Sperling <st...@elego.de>                 Software Developer
elego Software Solutions GmbH                            HRB 77719
Gustav-Meyer-Allee 25, Gebaeude 12        Tel:  +49 30 23 45 86 96 
13355 Berlin                              Fax:  +49 30 23 45 86 95
http://www.elego.de                 Geschaeftsfuehrer: Olaf Wagner