This is an archive of the discontinued Mercurial Phabricator instance.

graft: add test for reading old graftstate files with new mechanism
ClosedPublic

Authored by pulkit on Mar 3 2018, 2:19 PM.

Details

Summary

This tests the reading of old graftstate file using the new logic. The tests
shows that if user is in middle of a graft and then updates their mercurial to
the version where we have new graftstate format, we can still read the old graft
state format files correctly.

Diff Detail

Repository
rHG Mercurial
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

pulkit created this revision.Mar 3 2018, 2:19 PM

Overall I think I like where this is headed.

pulkit updated this revision to Diff 7303.Mar 26 2018, 1:10 PM
pulkit edited the summary of this revision. (Show Details)May 24 2018, 5:01 PM
pulkit retitled this revision from graft: add test for reading old format state files with new mechanism to graft: add test for reading old graftstate files with new mechanism.
pulkit updated this revision to Diff 8886.
martinvonz added inline comments.
tests/test-graft.t
1417

Can this line be replaced by hg log -r 1 -r 2 -T '{node}\n' > .hg/graftstate and remove the need for the extension above (and the need to create conflicting changes)?

pulkit added inline comments.May 25 2018, 6:14 AM
tests/test-graft.t
1417

That's a nice idea. I think we can, but the behavior will be bit different since graft will think the working directory now contains changes from rev 1 and will straight away try to create a commit and later reporting that graft of 1 created no changes to commit. Here is the diff:

~/repo/hg-committed/tests$ hg diff
diff --git a/tests/test-graft.t b/tests/test-graft.t
--- a/tests/test-graft.t
+++ b/tests/test-graft.t
@@ -1414,16 +1414,9 @@ Testing the reading of old format grafts
   $ hg add b
   $ hg ci -m "bar to b"
   created new head
-  $ hg oldgraft -r 1 -r 2 --config extensions.oldgraft=$TESTTMP/oldgraft.py
-  merging b
-  warning: conflicts while merging b! (edit, then use 'hg resolve --mark')
-  abort: unresolved conflicts
-  [255]
+  $ hg log -r 1 -r 2 -T '{node}\n' > .hg/graftstate
 
-  $ echo foo > b
-  $ hg resolve -m
-  (no more unresolved files)
-  continue: hg graft --continue
   $ hg graft --continue
   grafting 1:80e6d2c47cfe "added b"
+  note: graft of 1:80e6d2c47cfe created no changes to commit
   grafting 2:8be98ac1a569 "added c"

Since we are just testing reading old state format files, we should be fine with this. What do you think?

martinvonz added inline comments.May 25 2018, 9:10 AM
tests/test-graft.t
1417

An alternative is to use the regular great command to start the process and then replace the .hg/graftstate once it's run into conflicts. That might be better so we have a repo state (include the merge state) that we know is valid to continue from.

pulkit added inline comments.May 25 2018, 2:54 PM
tests/test-graft.t
1417

That's a very good suggestion. Thanks for that!

martinvonz accepted this revision.May 25 2018, 3:13 PM
This revision is now accepted and ready to land.May 25 2018, 3:13 PM
This revision was automatically updated to reflect the committed changes.