monotone-commits-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Monotone-commits-diffs] net.venge.monotone.issue-209: 329d1fe78cc665997


From: code
Subject: [Monotone-commits-diffs] net.venge.monotone.issue-209: 329d1fe78cc665997e872034520b09d0309f98eb
Date: Sun, 3 Jun 2012 17:47:14 +0200 (CEST)

revision:            329d1fe78cc665997e872034520b09d0309f98eb
date:                2012-06-03T15:17:09
author:              address@hidden
branch:              net.venge.monotone.issue-209
changelog:
finish dropped/modified; all tests pass, all documentation up to date.

* NEWS: mention dropped/modified conflicts

* doc/monotone.texi: clean up dropped/modified documentation

* src/cmd_merging.cc (show_conflicts_core): put ancestor properly

* src/merge_conflict.cc (resolve_dropped_modified_conflicts): record new
  file contents for 'user'.

* src/merge_content.hh (content_merge_adaptor):
* src/merge_content.cc (record_file): allow adding new file

* test/func/resolve_conflicts_read_all/__driver__.lua:
* test/func/resolve_conflicts_all_resolutions/__driver__.lua:
* test/func/conflict_messages/__driver__.lua:
* test/func/automate_show_conflicts/__driver__.lua: doc that dropped/modified 
is tested elsewhere

* test/func/resolve_conflicts_dropped_modified/__driver__.lua: test 
show_conflicts, automate show_conflicts, dropped/renamed

* test/func/resolve_conflicts_dropped_modified/show_conflicts: New file.


manifest:
format_version "1"

new_manifest [39ba6c8f364083c748f4e2a6169fef05b2b22e10]

old_revision [544ac7c8203751d61f6ccc016d6b0a28cb1e7596]

add_file "test/func/resolve_conflicts_dropped_modified/show_conflicts"
 content [e2c170d1c80ad32ac17d6a881c69a692847ae056]

patch "NEWS"
 from [8e1f0621a0612b9d910be8c3b0d87829269e72a7]
   to [14720ed190f83297dba3fe3fc434145a26215280]

patch "doc/monotone.texi"
 from [c4b06dbfa4640e9358dbbfadf36c78de7d9a2f64]
   to [3f52411f8776e632a9b6c1d7e5e588bb1cc8b1da]

patch "src/cmd_merging.cc"
 from [149b3d0a65bd2822f88e9838815aea01d827fc67]
   to [0a6aa03896408c4acdb7a1a9cd1682cb98c6f02a]

patch "src/merge_conflict.cc"
 from [6f0a13f140b97c5b8d2f4edfd327882d6006afe8]
   to [3289a8141136c7f57982a06bd6dfeac3f1251a47]

patch "src/merge_content.cc"
 from [3f38508142269cd629be6760713f636ed75bbbfd]
   to [7f032b0198b976f0c41399f104ae2bf4b974f845]

patch "src/merge_content.hh"
 from [c8fec9bc061a8a7ad9729ece909fde64e31b55ae]
   to [1ba84d139770571a9f23c85de72388acceb6570c]

patch "test/func/automate_show_conflicts/__driver__.lua"
 from [f835c5204474b98db1ef43aead8c9c0f97014575]
   to [41adbaaa488c5b3cda193cec8d037b66368f8b55]

patch "test/func/conflict_messages/__driver__.lua"
 from [a681cb85649f5e5ce53bad9b8ef8f2300c22d9d8]
   to [33836bd943bbe8c33abff9b8597db9d4c768b2d6]

patch "test/func/resolve_conflicts_all_resolutions/__driver__.lua"
 from [0a504a8ecd385dadb9a01b7fc2c836e58dbaf6ff]
   to [e491c1be8ceb2a90b1f80f6e29a4430e4ef8a439]

patch "test/func/resolve_conflicts_dropped_modified/__driver__.lua"
 from [a77c8e0b701e417014bf7958f8f2e8ed922586c6]
   to [7f16460e30c39738b2cf25239f1b9522b6c87fa1]

patch "test/func/resolve_conflicts_read_all/__driver__.lua"
 from [c8f14848057bb6eff36844cebd24aff6caed9d08]
   to [ccc41061b22420f5b08eea1271a3b5acf6c270d2]
============================================================
--- NEWS	8e1f0621a0612b9d910be8c3b0d87829269e72a7
+++ NEWS	14720ed190f83297dba3fe3fc434145a26215280
@@ -24,7 +24,14 @@ XXX XXX XX XX:XX:XX UTC 201X
         - All certs for a revision are now output by 'mtn log' with
           'suspend', 'testresult', and custom certs placed under a
           a new 'Other certs' heading.
-           
+
+        - New conflict 'dropped/modified' allows explicitly resolving
+          the case of a file that is dropped on one side of a merge,
+          and modified on the other. Previously, the modifications
+          were always lost; now you have the option of re-adding the
+          file with the modifications during merge conflict
+          resolution.
+        
         Bugs fixed
 
         - Monotone now compiles against Botan 1.10.x (as well as most of
============================================================
--- doc/monotone.texi	c4b06dbfa4640e9358dbbfadf36c78de7d9a2f64
+++ doc/monotone.texi	3f52411f8776e632a9b6c1d7e5e588bb1cc8b1da
@@ -3487,6 +3487,27 @@ @subheading Missing Root Conflict
 
 @command{conflicts} does not yet support resolving this conflict.
 
address@hidden Dropped/Modified file Conflict
+This conflict occurs when a file is dropped in one merge parent,
+and modified on the other.
+
address@hidden supports resolving this conflict; the possible
+resolutions are to drop the file in the result, keep the modified
+version, or keep a user supplied version.
+
+Because of the @emph{die-die-die} policy, monotone internally must
+first drop the modified file, and then add a new file with the same
+name and the desired contents. This means history is disconnected;
+when @command{mtn log} is later run for the file, it will stop at this
+merge, not showing the previous history for the file. That history is
+still there; the user can see it by starting @command{mtn log} again
+for the same file but in the parent of the merge.
+
+There is no such thing as a dropped/modified directory; if the
+directory is empty, the only possible change is rename, which is
+ignored. If the directory is not empty, that creates orphaned file
+conflicts.
+
 @subheading Invalid Name Conflict
 
 Monotone reserves the name @file{_MTN} in a workspace root directory
@@ -3560,15 +3581,6 @@ @subheading Multiple Name Conflict
 In earlier versions of monotone (those before version 0.39) this type
 of conflict was referred to as a @emph{name conflict}.
 
address@hidden Dropped/Modified Conflict
-
-A dropped/modified conflict occurs when a single file has
-been dropped in one merge parent, and modified in the other.
-
address@hidden supports resolving this conflict; the possible
-resolutions are to drop the file in the result, keep the modified
-version, or keep a user supplied version.
-
 @subheading Attribute Conflict
 
 An attribute conflict occurs when a versioned attribute on a file or
@@ -5151,11 +5163,11 @@ @subheading Commands
 convenient way to clean up.
 @end ftable
 
address@hidden Single file conflict resolutions
address@hidden Conflict resolutions
 
-For single file conflicts, there are several possible
-resolutions. Note that @command{resolved_user_left} is used even for
-single file conflicts.
+For single and two file conflicts, there are several possible
+resolutions. In the conflicts file, @command{resolved_user_left} is
+used for single file conflicts.
 
 @ftable @command
 @item interactive address@hidden
@@ -5166,47 +5178,24 @@ @subheading Single file conflict resolut
 specified, @var{file} defaults to @file{_MTN/resolutions/<path>},
 where @file{<path>} is the path to the file that has the conflict.
 
-This inserts a @command{resolved_user_left @var{file}} conflict resolution in the
+This inserts a @command{resolved_user_left @var{file}} or
address@hidden @var{file}} conflict resolution in the
 conflicts file.
 
 @item user @var{file}
 The file contents are replaced by the contents of the specified file.
 
-This inserts a @command{resolved_user_left @var{file}} conflict resolution in the
+This inserts a @command{resolved_user_left @var{file}} or
address@hidden @var{file}} conflict resolution in the
 conflicts file.
 
 @item drop
-The file is dropped in the merge. This is useful for an orphaned file
-conflict.
-
-This inserts a @command{resolved_drop_left} conflict resolution in the
-conflicts file.
-
address@hidden rename @var{filename}
-The file is renamed. This is useful for an orphaned file conflict.
-
-This inserts a @command{resolved_rename_left @var{filename}} conflict resolution
-in the conflicts file.
-
address@hidden ftable
-
address@hidden Two file conflict resolutions
-
-For two file conflicts, the possible resolutions are:
-
address@hidden @command
address@hidden drop
 The file is dropped in the merge.
 
-This inserts a @command{resolved_drop_left} or @command{resolved_drop_right}
-conflict resolution in the conflicts file.
+This inserts a @command{resolved_drop_left} or
address@hidden conflict resolution in the conflicts
+file.
 
address@hidden keep
-The file is kept in the merge.
-
-This inserts a @command{resolved_keep_left} or @command{resolved_keep_right}
-conflict resolution in the conflicts file.
-
 @item rename @var{filename}
 The file is renamed.
 
@@ -5214,13 +5203,11 @@ @subheading Two file conflict resolution
 @command{resolved_rename_right @var{filename}} conflict resolution in
 the conflicts file.
 
address@hidden user @var{file}
-The file contents are replaced by the contents of the specified file.
-The other file in the conflict must be dropped or renamed.
address@hidden keep
+The file is kept in the merge.
 
-This inserts a @command{resolved_user_left @var{file}} or
address@hidden @var{file}} conflict resolution in the
-conflicts file.
+This inserts a @command{resolved_keep_left} or @command{resolved_keep_right}
+conflict resolution in the conflicts file.
 
 @end ftable
 
@@ -10439,7 +10426,7 @@ @section Automation
 
 File dropped and modified (and possibly renamed):
 @verbatim
-        conflict drop_modified
+        conflict dropped_modified
    ancestor_name "foo"
 ancestor_file_id [e80910e54d0bdea1b6d295ada320b87aaf9fdc23]
        left_type "dropped file"
============================================================
--- src/cmd_merging.cc	149b3d0a65bd2822f88e9838815aea01d827fc67
+++ src/cmd_merging.cc	0a6aa03896408c4acdb7a1a9cd1682cb98c6f02a
@@ -985,8 +985,8 @@ show_conflicts_core (database & db,
     }
   else
     {
-      P(F("[left]  %s") % l_id);
-      P(F("[right] %s") % r_id);
+      P(F("[left]     %s") % l_id);
+      P(F("[right]    %s") % r_id);
     }
 
   if (is_ancestor(db, l_id, r_id))
@@ -1048,12 +1048,17 @@ show_conflicts_core (database & db,
       content_merge_database_adaptor adaptor(db, l_id, r_id,
                                              l_marking, r_marking);
 
-      {
-        basic_io::printer pr;
-        st.push_binary_pair(syms::ancestor, adaptor.lca.inner());
-        pr.print_stanza(st);
-        output.write(pr.buf.data(), pr.buf.size());
-      }
+      if (basic_io)
+        {
+          basic_io::printer pr;
+          st.push_binary_pair(syms::ancestor, adaptor.lca.inner());
+          pr.print_stanza(st);
+          output.write(pr.buf.data(), pr.buf.size());
+        }
+      else
+        {
+          P(F("[ancestor] %s") % adaptor.lca);
+        }
 
       // The basic_io routines in roster_merge.cc access these rosters via
       // the adaptor.
============================================================
--- src/merge_conflict.cc	6f0a13f140b97c5b8d2f4edfd327882d6006afe8
+++ src/merge_conflict.cc	3289a8141136c7f57982a06bd6dfeac3f1251a47
@@ -2644,9 +2644,13 @@ roster_merge_result::resolve_dropped_mod
             result_data = file_data(result_raw_data);
             calculate_ident(result_data, result_fid);
 
-            // FIXME: need to record file in db
             nid = roster.create_file_node(result_fid, nis);
 
+            // User could specify no changes
+            if (result_fid != modified_fid)
+              {
+                adaptor.record_file(result_fid, result_data);
+              }
             attach_node(lua, roster, nid, modified_name);
           }
           break;
============================================================
--- src/merge_content.cc	3f38508142269cd629be6760713f636ed75bbbfd
+++ src/merge_content.cc	7f032b0198b976f0c41399f104ae2bf4b974f845
@@ -82,6 +82,20 @@ void
 }
 
 void
+content_merge_database_adaptor::record_file(file_id const & ident,
+                                            file_data const & data)
+{
+  L(FL("recording new file %s")
+    % ident);
+
+  transaction_guard guard(db);
+
+  db.put_file(ident, data);
+
+  guard.commit();
+}
+
+void
 content_merge_database_adaptor::record_file(file_id const & parent_ident,
                                             file_id const & merged_ident,
                                             file_data const & parent_data,
@@ -203,6 +217,18 @@ void
 }
 
 void
+content_merge_workspace_adaptor::record_file(file_id const & id,
+                                             file_data const & data)
+{
+  L(FL("temporarily recording file %s")
+    % id);
+  // this is an insert instead of a safe_insert because it is perfectly
+  // legal (though rare) to have multiple merges resolve to the same file
+  // contents.
+  temporary_store.insert(make_pair(id, data));
+}
+
+void
 content_merge_workspace_adaptor::record_file(file_id const & parent_id,
                                              file_id const & merged_id,
                                              file_data const & parent_data,
@@ -307,6 +333,13 @@ void
 }
 
 void
+content_merge_checkout_adaptor::record_file(file_id const & ident,
+                                            file_data const & data)
+{
+  I(false);
+}
+
+void
 content_merge_checkout_adaptor::get_ancestral_roster(node_id nid,
                                                      revision_id & rid,
                                                      shared_ptr<roster_t const> & anc)
@@ -337,6 +370,13 @@ void
 }
 
 void
+content_merge_empty_adaptor::record_file(file_id const & ident,
+                                         file_data const & data)
+{
+  I(false);
+}
+
+void
 content_merge_empty_adaptor::record_file(file_id const & parent_ident,
                                          file_id const & merged_ident,
                                          file_data const & parent_data,
============================================================
--- src/merge_content.hh	c8fec9bc061a8a7ad9729ece909fde64e31b55ae
+++ src/merge_content.hh	1ba84d139770571a9f23c85de72388acceb6570c
@@ -31,7 +31,10 @@ content_merge_adaptor
                             file_data const & right_data,
                             file_data const & merged_data) = 0;
 
-  // For use when one side of the merge is dropped
+  // dropped_modified conflict resolution of keep or user creates new node
+  virtual void record_file(file_id const & ident,
+                           file_data const & data) = 0;
+
   virtual void record_file(file_id const & parent_ident,
                            file_id const & merged_ident,
                            file_data const & parent_data,
@@ -70,6 +73,9 @@ content_merge_database_adaptor
                     file_data const & right_data,
                     file_data const & merged_data);
 
+  void record_file(file_id const & ident,
+                   file_data const & data);
+
   void record_file(file_id const & parent_ident,
                    file_id const & merged_ident,
                    file_data const & parent_data,
@@ -118,6 +124,9 @@ content_merge_workspace_adaptor
                     file_data const & right_data,
                     file_data const & merged_data);
 
+  void record_file(file_id const & ident,
+                   file_data const & data);
+
   void record_file(file_id const & parent_ident,
                    file_id const & merged_ident,
                    file_data const & parent_data,
@@ -147,6 +156,9 @@ content_merge_checkout_adaptor
                     file_data const & right_data,
                     file_data const & merged_data);
 
+  void record_file(file_id const & ident,
+                   file_data const & data);
+
   void record_file(file_id const & parent_ident,
                    file_id const & merged_ident,
                    file_data const & parent_data,
@@ -173,6 +185,9 @@ content_merge_empty_adaptor
                     file_data const & right_data,
                     file_data const & merged_data);
 
+  void record_file(file_id const & ident,
+                   file_data const & data);
+
   void record_file(file_id const & parent_ident,
                    file_id const & merged_ident,
                    file_data const & parent_data,
============================================================
--- test/func/automate_show_conflicts/__driver__.lua	f835c5204474b98db1ef43aead8c9c0f97014575
+++ test/func/automate_show_conflicts/__driver__.lua	41adbaaa488c5b3cda193cec8d037b66368f8b55
@@ -1,6 +1,9 @@
 -- Create the various non-content conflict cases, check that
 -- 'automate show_conflict' displays them properly.
 --
+-- Except for dropped/modified; see
+-- ../resolve_conflicts_dropped_modified/__driver__.lua
+--
 -- Cases are created in the same way as in conflict_messages/__driver__.lua
 
 mtn_setup()
============================================================
--- test/func/conflict_messages/__driver__.lua	a681cb85649f5e5ce53bad9b8ef8f2300c22d9d8
+++ test/func/conflict_messages/__driver__.lua	33836bd943bbe8c33abff9b8597db9d4c768b2d6
@@ -1,7 +1,10 @@ mtn_setup()
 mtn_setup()
 
--- this test creates the various non-content conflict cases
--- and attempts to merge them to check the various messages
+-- this test creates the various non-content conflict cases and
+-- attempts to merge them to check the various messages.
+--
+-- Except for dropped/modified; see
+-- ../resolve_conflicts_dropped_modified/__driver__.lua
 
 
 function setup(branch)
============================================================
--- test/func/resolve_conflicts_all_resolutions/__driver__.lua	0a504a8ecd385dadb9a01b7fc2c836e58dbaf6ff
+++ test/func/resolve_conflicts_all_resolutions/__driver__.lua	e491c1be8ceb2a90b1f80f6e29a4430e4ef8a439
@@ -1,5 +1,8 @@
 -- Test showing and setting all possible conflict resolutions in a
 -- conflict file. Also test 'conflict show_remaining'.
+--
+-- Except for dropped/modified; see
+-- ../resolve_conflicts_dropped_modified/__driver__.lua
 
 mtn_setup()
 get("merge3_hook.lua")
============================================================
--- test/func/resolve_conflicts_dropped_modified/__driver__.lua	a77c8e0b701e417014bf7958f8f2e8ed922586c6
+++ test/func/resolve_conflicts_dropped_modified/__driver__.lua	7f16460e30c39738b2cf25239f1b9522b6c87fa1
@@ -54,6 +54,16 @@ right_1 = base_revision()
 commit("testbranch", "right 1")
 right_1 = base_revision()
 
+-- Now start the conflict resolution process. First show the conflicts.
+check(mtn("show_conflicts", left_1, right_1), 0, nil, true)
+canonicalize("stderr")
+check(samefilestd("show_conflicts", "stderr"))
+
+check(mtn("automate", "show_conflicts", left_1, right_1), 0, true, nil)
+canonicalize("stdout")
+check(samefilestd("conflicts", "stdout"))
+
+-- Now store and resolve them one by one.
 check(mtn("conflicts", "store", left_1, right_1), 0, nil, true)
 check(samelines("stderr",
 {"mtn: 6 conflicts with supported resolutions.",
@@ -156,7 +166,29 @@ check(not qgrep("warning", "stderr"))
 check(qgrep("replacing content of 'file_7_renamed' with '_MTN/resolutions/file_7_resolved", "stderr"))
 check(not qgrep("warning", "stderr"))
 
--- FIXME: add dropped_modified to 'show_conflicts' test (etc?)
--- better to put those tests here
-                           
+-- There is no such thing as a dropped/modified directory; if the
+-- directory is empty, the only possible change is rename, which is
+-- ignored. If the directory is not empty, that creates orphaned file
+-- conflicts.
+--
+-- Similarly, if a file is renamed (without other change) and dropped,
+-- the change is ignored:
+
+addfile("file_8", "file_8 base") -- rename left, drop right
+commit("testbranch", "base 2")
+base_2 = base_revision()
+
+check(mtn("mv", "file_8", "file_8_renamed"), 0, false, false)
+commit("testbranch", "left 2")
+left_2 = base_revision()
+
+revert_to(base_2)
+
+check(mtn("drop", "file_8"), 0, false, false)
+commit("testbranch", "right 2")
+right_2 = base_revision()
+
+check(mtn("show_conflicts", left_2, right_2), 0, nil, true)
+check(qgrep("0 conflicts", "stderr"))
+
 -- end of file
============================================================
--- /dev/null	
+++ test/func/resolve_conflicts_dropped_modified/show_conflicts	e2c170d1c80ad32ac17d6a881c69a692847ae056
@@ -0,0 +1,22 @@
+mtn: [left]     f675f3440ebd978fffba5d990e8c876ae9470aa3
+mtn: [right]    3b44e67a00d6f2ef92279d5fd07b46cc175b3291
+mtn: [ancestor] c2fe3623ce72d248154425dc7db2ddcc397c9aca
+mtn: conflict: file 'file_2' from revision c2fe3623ce72d248154425dc7db2ddcc397c9aca
+mtn: modified on the left, named file_2_renamed
+mtn: dropped on the right
+mtn: conflict: file 'file_3' from revision c2fe3623ce72d248154425dc7db2ddcc397c9aca
+mtn: dropped on the left
+mtn: modified on the right, named file_3_renamed
+mtn: conflict: file 'file_4' from revision c2fe3623ce72d248154425dc7db2ddcc397c9aca
+mtn: modified on the left, named file_4
+mtn: dropped on the right
+mtn: conflict: file 'file_5' from revision c2fe3623ce72d248154425dc7db2ddcc397c9aca
+mtn: dropped on the left
+mtn: modified on the right, named file_5
+mtn: conflict: file 'file_6' from revision c2fe3623ce72d248154425dc7db2ddcc397c9aca
+mtn: modified on the left, named file_6_renamed
+mtn: dropped on the right
+mtn: conflict: file 'file_7' from revision c2fe3623ce72d248154425dc7db2ddcc397c9aca
+mtn: dropped on the left
+mtn: modified on the right, named file_7_renamed
+mtn: 6 conflicts with supported resolutions.
============================================================
--- test/func/resolve_conflicts_read_all/__driver__.lua	c8f14848057bb6eff36844cebd24aff6caed9d08
+++ test/func/resolve_conflicts_read_all/__driver__.lua	ccc41061b22420f5b08eea1271a3b5acf6c270d2
@@ -4,6 +4,9 @@ mtn_setup()
 -- that "conflicts show_remaining" can properly process the output of
 -- "conflicts store".
 --
+-- Except for dropped/modified; see
+-- ../resolve_conflicts_dropped_modified/__driver__.lua
+--
 -- test case generation borrowed from conflict_messages test.
 
 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]