Page MenuHomePhabricator

Add basic support for mirroring Mercurial repositories
ClosedPublic

Authored by richardvanvelzen on Jan 30 2014, 10:37 AM.
Tags
None
Referenced Files
F13266032: D8107.id.diff
Tue, May 28, 8:22 AM
F13259271: D8107.id18334.diff
Sun, May 26, 6:51 PM
F13216232: D8107.diff
Fri, May 17, 11:18 PM
F13215755: D8107.id18335.diff
Fri, May 17, 7:41 PM
F13201482: D8107.id18335.diff
May 14 2024, 12:41 PM
F13201481: D8107.id18334.diff
May 14 2024, 12:41 PM
F13201431: D8107.id.diff
May 14 2024, 12:08 PM
F13201406: D8107.diff
May 14 2024, 11:43 AM

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).