Page MenuHomePhabricator

Add basic support for mirroring Mercurial repositories
ClosedPublic

Authored by richardvanvelzen on Jan 30 2014, 10:37 AM.
Tags
None
Referenced Files
F14053656: D8107.id18335.diff
Fri, Nov 15, 6:04 PM
F14002149: D8107.id.diff
Fri, Oct 25, 3:44 PM
F14000487: D8107.id18334.diff
Thu, Oct 24, 10:16 PM
F13963969: D8107.id18335.diff
Oct 15 2024, 7:00 PM
F13960322: D8107.diff
Oct 14 2024, 10:55 PM
Unknown Object (File)
Oct 11 2024, 4:03 PM
Unknown Object (File)
Oct 11 2024, 4:03 PM
Unknown Object (File)
Oct 7 2024, 12:51 PM

Details

Summary

Ref T4338. Mercurial exits with exit code 1 and "no changes found" in stdout
when there's no changes. I've split up the pushRepositoryToMirror to make
the code a tad more readable.

It isn't perfect, but it works for me.

Test Plan

pushed some changes to my hosted repo. Saw them appearing in the
mirrored repo

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

This looks good to me. Two thoughts:

  • Does tip exist in an empty repository? Specifically, will this command succeed if the repository is empty?
  • Do we need --force? Specifically, are there situations where we'll get a better outcome with it?
  • Do we need --new-branch? Specifically, will this choke when new branches are created?

For reference, I think the git version of this command is pretty aggressive about overwriting the remote, although I'm not completely sure how the --mirror flag behaves in all cases.

In any case, this looks like a huge step forward to me. If you hit any of those special cases, let me know and we can figure out what to do about them.

Closed by commit rP28fcb5711bc8 (authored by Richard van Velzen <rvanvelzen@expert-shops.com>, committed by @epriestley).

Good points. I had thought about the tip issue, which is probably true. This first version just pushes the tip to the remote instead of actually mirroring the entire repo.

--force *should* be enough in all cases:

Use --new-branch if you want to allow push to create a new named branch that is not present at the destination. This allows you to only create a new branch without forcing other changes.
Note: Extra care should be taken with the -f/--force option, which will push all new heads on all branches, an action which will almost always cause confusion for collaborators.

This basically means that --force implies --new-branch but it can be dangerous, in the same way that it's dangerous with git (it overwrites all changes on the remote).