Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Phabricator Arcanist arc land vs arc amend

I am using Phabricator and Arcanist for code reviews in my team. The 'arc land' command is awesome, but there is one scenario where it doesn't work for us.

We have a single xml file, that contains a linked list (each element refers to a previous element). We don't make changes to this file very often, but once in a while we do. If two people make changes at the same time a "silent conflict" occurs, meaning that the linked list is broken because both new elements link to the same previous element. This is not very difficult to resolve. But no merge conflict is raised by git.

So when we run arc land, the incorrect xml file is automatically pushed. We don't want that.

Would the correct action be to use arc amend, and then resolve that conflict manually followed by a git push (like we do today without any hassle), or how would you suggest moving forward with this?

like image 229
Jay Pete Avatar asked Jan 12 '23 22:01

Jay Pete


1 Answers

Some possible ideas:

  • You can arc land --hold to stop before the git push is run and inspect the changes, then run git push manually.
  • You can add a local Git pre-commit hook to validate the XML file before Git allows the commit.
  • You can add a pre-receive hook on the server to validate the XML file before it is pushed to the remote.
  • You can override Git's merge behavior using a merge directive in gitattributes, and replace the default merge with one which gets it right (or fails to merge).
  • You could try to replace the XML file with data in some format which doesn't have these undesirable merge properties, since this problem is a general one.
  • You could force the merge to fail by including some string in the file which would always conflict. For example, add an attribute like lastNode="whatever" to the container element (i.e., always on line 1 or whatever), so that two edits would always conflict on that line by naming different last nodes (to make sure this was edited, you could check that the lastNode was correct at runtime). If the file is automatically generated, you could simply put a random number in a comment on a well-known line.
like image 168
Evan Priestley Avatar answered Jan 16 '23 18:01

Evan Priestley