CloudServices/Sync/FxSync/WarOnSpinningEventLoop: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
 
(15 intermediate revisions by 2 users not shown)
Line 1: Line 1:
== Project branch ==
== Goals ==


=== Mercurial ===
Two main areas of work: we spin the event loop to wait for queries, and we spin to wait for HTTP requests. This allowed Sync to be programmed in a synchronous, procedural way, rather than as a giant web of callbacks.


We have the project branch Alder until 2011-07-30:
Spinning the event loop is bad, so we need to change this.


https://wiki.mozilla.org/ReleaseEngineering/DisposableProjectBranches#BOOKING_SCHEDULE
== Work Items ==


This will give us [http://tbpl.mozilla.org/?tree=Alder tbpl] and such. Hooray!
{{bug|652221}}: use AsyncResource everywhere. The implementation of this necessarily includes "make most of Sync use callbacks"; see [[Services/Sync/WEP/116]]. I'm about half done with this in branches in [https://github.com/rnewman/services-hacking services-hacking].


Cloning from your local s-c (much faster this way!):
(no bug yet): eliminate queryAsync/querySpinningly.


  hg clone services-central alder
== Project branch ==
  # You'll need >| if you're using zsh.
  echo "[paths]\ndefault = ssh://hg.mozilla.org/projects/alder" > alder/.hg/hgrc
  echo "sc = ssh://hg.mozilla.org/services/services-central" >> alder/.hg/hgrc
  cd alder
  hg pull -u
 
Now you have an hg repo from which you can
 
  hg pull -u
 
to update from alder, and


  hg pull -u sc
to update from mainline s-c.


=== Git ===
=== Git ===
Line 39: Line 25:
   # fork my repo and clone your fork.
   # fork my repo and clone your fork.
   cd ~/moz/git
   cd ~/moz/git
   git clone git@github.com:rnewman/alder.git
   git clone git@github.com:rnewman/services-hacking.git
   cd alder
   cd alder


Now you have a Git mirror of my alder repo, which I keep up to date from Mercurial as needed.
Now you have a Git mirror of my hacking repo, which I keep up to date from Mercurial as needed.


If you wish, you may link to your Mercurial alder repo. This is a two-step process:
If you wish, you may link to a Mercurial repo. This is a two-step process:


* Install [http://hg-git.github.com/ hg-git].
* Install [http://hg-git.github.com/ hg-git].
Line 58: Line 44:


   # In Mercurial version.
   # In Mercurial version.
   cd ~/moz/hg/alder
   cd ~/moz/hg/services-hacking
   hg bookmark -r default master        # Once.
   hg bookmark -r default master        # Once.
   hg pull ../../git/alder
   hg pull ../../git/services-hacking


(Note that you can't push to your git repo, because it's not bare. Try it and read the warning. You can push to GitHub and pull, though.)
(Note that you can't push to your git repo, because it's not bare. Try it and read the warning. You can push to GitHub and pull, though.)
Line 66: Line 52:
The first time you do this, <tt>hg-git</tt> needs to create a bunch of files in <tt>.hg</tt>. This takes a long time. You might want to leave this up to the Merge Viking (rnewman), and simply do all of your work in Git. Or leave this running for a week!
The first time you do this, <tt>hg-git</tt> needs to create a bunch of files in <tt>.hg</tt>. This takes a long time. You might want to leave this up to the Merge Viking (rnewman), and simply do all of your work in Git. Or leave this running for a week!


A much better solution is to grab <tt>.hg/git-mapfile</tt> from an existing repository (e.g., ask rnewman), and clone a bare git repo next to it. This gives you
A much better solution is to grab <tt>.hg/git-mapfile</tt> from an existing repository (e.g., [http://people.mozilla.com/~rnewman/alder/ rnewman's]), and clone a bare git repo next to it. This gives you


   alder              # Hg repo
   alder              # Hg repo
     .hg
     .hg
       git            # Git clone of alder git repo
       git            # Git clone of services-hacking git repo
       git-mappings  # Bookkeeping info
       git-mappings  # Bookkeeping info


Line 77: Line 63:
The quickest way to push to Git is to descend into <tt>.hg/git</tt> and use <tt>git push</tt>. Continue to use <tt>hg pull</tt> from either a Git repo or a Mercurial repo to bring changesets in.
The quickest way to push to Git is to descend into <tt>.hg/git</tt> and use <tt>git push</tt>. Continue to use <tt>hg pull</tt> from either a Git repo or a Mercurial repo to bring changesets in.


=== Merging ===
==== Remotes ====


So you have a Git feature branch, and you want to get it back into alder for TBPL. How?
Your Git clone starts off with <tt>origin</tt> pointing to GitHub. Once we have the Mercurial bridge set up, you can do this:


We assume that alder itself plays the role of <tt>develop</tt> in the git-flow model. That means we're merging feature branches.
  git remote add hg ~/moz/hg/services-hacking/.hg/git
 
to pull straight from your local copy.
 
=== Merging new work from Git back to Mercurial (stale after elimination of alder HG repo) ===
 
So you have a Git feature branch, and you want to get it back into services-central. How?
 
We assume that alder itself plays the role of <tt>develop</tt> in the [http://nvie.com/posts/a-successful-git-branching-model/ git-flow model]. That means we're merging feature branches.
 
See [https://github.com/mozilla/f1/wiki/Patch-and-Review-Workflow Philipp's fantastic writeup] for more.


   git checkout master
   git checkout master
   git merge --no-ff bug-123456-frobnicate         # Merge feature branch
   git merge --no-ff -m "Bug 123456: frobnicate." \
   git push origin master                         # Put master on GitHub
    bug-123456-frobnicate                                     # Merge feature branch.
   cd ../../hg/alder                               # Switch to hg
   git push origin master                                     # Put master on GitHub.
   hg pull git+ssh://git@github.com/rnewman/alder # Treat like a pull from hg.
   cd ../../hg/alder                                           # Switch to hg.
   hg pull git+ssh://git@github.com/rnewman/alder             # Treat like a pull from hg.
   # Merge etc. as necessary.
   # Merge etc. as necessary.
   hg push default                                 # Push to hg.m.o.
   hg push default                                             # Push to hg.m.o.
 
Note that you cannot specify the <tt>-b</tt> flag when you pull, which could lead to other branches traveling from Git to Mercurial. That's bad. Be careful! It might be necessary to pull into the private Git repo, strip branches, then use <tt>hg gimport</tt> to get Mercurial back in sync.
 
=== Merging upstream changes from Mercurial into Git  (stale after elimination of alder HG repo) ===
 
This is easier if you have a remote set up for GitHub:
 
  cd hg/alder
  git --git-dir .hg/git remote add github git+ssh://git@github.com/rnewman/alder
 
Now you can do this:
 
  hg pull -u default                                # Get our branch in order.
  hg pull -u sc                                    # Fetch new stuff from services-central.
  hg merge                                          # Execute a normal merge.
  hg commit -m "Merge services-central into alder."
  hg push default                                  # Push to alder hg repo.
  hg gexport                                        # Update the private git mirror.
  git --git-dir .hg/git push github                # Push to GitHub.
  cd ../../git/alder                                # Switch to git.
  git checkout master
 
  # Either, pull from GitHub:
  git pull origin master                            # Pull new changes from GitHub.
 
  # or pull from the local Mercurial private mirror:
  git pull hg master
 
  # Rebase or merge branches as necessary.

Latest revision as of 20:12, 19 November 2013

Goals

Two main areas of work: we spin the event loop to wait for queries, and we spin to wait for HTTP requests. This allowed Sync to be programmed in a synchronous, procedural way, rather than as a giant web of callbacks.

Spinning the event loop is bad, so we need to change this.

Work Items

bug 652221: use AsyncResource everywhere. The implementation of this necessarily includes "make most of Sync use callbacks"; see Services/Sync/WEP/116. I'm about half done with this in branches in services-hacking.

(no bug yet): eliminate queryAsync/querySpinningly.

Project branch

Git

We do our work in Git because it sucks less.

I assume you have parallel directories like ~/moz/hg and ~/moz/git.

Cloning:

 # Ask me (rnewman) to add you as a collaborator on GitHub, or 
 # fork my repo and clone your fork.
 cd ~/moz/git
 git clone git@github.com:rnewman/services-hacking.git
 cd alder

Now you have a Git mirror of my hacking repo, which I keep up to date from Mercurial as needed.

If you wish, you may link to a Mercurial repo. This is a two-step process:

  • Install hg-git.
  • Simply hg push and pull to the git repository directory.

You'll need these lines in your ~/.hgrc:

 [extensions]
 hgext.bookmarks =
 hggit =

Assuming that your Git version is ahead, because that's where you're working:

 # In Mercurial version.
 cd ~/moz/hg/services-hacking
 hg bookmark -r default master        # Once.
 hg pull ../../git/services-hacking

(Note that you can't push to your git repo, because it's not bare. Try it and read the warning. You can push to GitHub and pull, though.)

The first time you do this, hg-git needs to create a bunch of files in .hg. This takes a long time. You might want to leave this up to the Merge Viking (rnewman), and simply do all of your work in Git. Or leave this running for a week!

A much better solution is to grab .hg/git-mapfile from an existing repository (e.g., rnewman's), and clone a bare git repo next to it. This gives you

 alder              # Hg repo
   .hg
     git            # Git clone of services-hacking git repo
     git-mappings   # Bookkeeping info

You can use an older set of mappings; just run hg gexport -v in the top-level Mercurial repo to update.

The quickest way to push to Git is to descend into .hg/git and use git push. Continue to use hg pull from either a Git repo or a Mercurial repo to bring changesets in.

Remotes

Your Git clone starts off with origin pointing to GitHub. Once we have the Mercurial bridge set up, you can do this:

 git remote add hg ~/moz/hg/services-hacking/.hg/git

to pull straight from your local copy.

Merging new work from Git back to Mercurial (stale after elimination of alder HG repo)

So you have a Git feature branch, and you want to get it back into services-central. How?

We assume that alder itself plays the role of develop in the git-flow model. That means we're merging feature branches.

See Philipp's fantastic writeup for more.

 git checkout master
 git merge --no-ff -m "Bug 123456: frobnicate." \
   bug-123456-frobnicate                                     # Merge feature branch.
 git push origin master                                      # Put master on GitHub.
 cd ../../hg/alder                                           # Switch to hg.
 hg pull git+ssh://git@github.com/rnewman/alder              # Treat like a pull from hg.
 # Merge etc. as necessary.
 hg push default                                             # Push to hg.m.o.

Note that you cannot specify the -b flag when you pull, which could lead to other branches traveling from Git to Mercurial. That's bad. Be careful! It might be necessary to pull into the private Git repo, strip branches, then use hg gimport to get Mercurial back in sync.

Merging upstream changes from Mercurial into Git (stale after elimination of alder HG repo)

This is easier if you have a remote set up for GitHub:

 cd hg/alder
 git --git-dir .hg/git remote add github git+ssh://git@github.com/rnewman/alder

Now you can do this:

 hg pull -u default                                # Get our branch in order.
 hg pull -u sc                                     # Fetch new stuff from services-central.
 hg merge                                          # Execute a normal merge.
 hg commit -m "Merge services-central into alder."
 hg push default                                   # Push to alder hg repo.
 hg gexport                                        # Update the private git mirror.
 git --git-dir .hg/git push github                 # Push to GitHub.
 cd ../../git/alder                                # Switch to git.
 git checkout master
 
 # Either, pull from GitHub:
 git pull origin master                            # Pull new changes from GitHub.
 
 # or pull from the local Mercurial private mirror:
 git pull hg master
 
 # Rebase or merge branches as necessary.