From a96cc23ff01b0370a8fbf6c06964ec393fe21c80 Mon Sep 17 00:00:00 2001 From: Doug Latornell Date: Thu, 14 May 2015 19:12:59 -0700 Subject: [PATCH] Update HTML. --- 02-collab.html | 77 ++++++++++++++++++++++++++++++++++---------------- 04-open.html | 2 +- 2 files changed, 53 insertions(+), 26 deletions(-) diff --git a/02-collab.html b/02-collab.html index 2e8d5ae..d522c0d 100644 --- a/02-collab.html +++ b/02-collab.html @@ -41,49 +41,76 @@

Learning Objectives

Version control really comes into its own when we begin to collaborate with other people. We already have most of the machinery we need to do this; the only thing missing is to copy changes from one person’s repository to another.

-

Systems like Mercurial allow us to move work between any two repositories. In practice, though, it’s easiest to use one copy as a central hub, and to keep it on the web rather than on someone’s laptop. Most programmers use hosting services like BitBucket and similar to hold those master copies; we’ll explore the pros and cons of this in the final section of this lesson.

-

Let’s start by sharing the changes we’ve made to our current project with the world. Log in to BitBucket, then click on the icon in the top right corner to create a new repository called planets:

+

Systems like Mercurial allow us to move work between any two repositories. In practice, though, it’s easiest to use one copy as a central hub, and to keep it on the web rather than on someone’s laptop. Most programmers use hosting services like Bitbucket and similar to hold those master copies; we’ll explore the pros and cons of this in the final section of this lesson.

+

Let’s start by sharing the changes we’ve made to our current project with the world. Log in to Bitbucket, then click on the icon in the top right corner to create a new repository called planets:

-Creating a Repository on BitBucket (Step 1)

Creating a Repository on BitBucket (Step 1)

+Creating a Repository on Bitbucket (Step 1)

Creating a Repository on Bitbucket (Step 1)

Name your repository “planets” and then click “Create Repository”:

-Creating a Repository on BitBucket (Step 2)

Creating a Repository on BitBucket (Step 2)

+Creating a Repository on Bitbucket (Step 2)

Creating a Repository on Bitbucket (Step 2)

-

As soon as the repository is created, BitBucket displays a page with a URL and some information on how to configure your local repository:

+

As soon as the repository is created, Bitbucket displays a page with a URL and some information on how to configure your local repository:

-Creating a Repository on BitBucket (Step 3)

Creating a Repository on BitBucket (Step 3)

+Creating a Repository on Bitbucket (Step 3)

Creating a Repository on Bitbucket (Step 3)

-

Select “I have an existing project” and follow its instructions. From within your planets directory, issue

-
hg push ssh://hg@bitbucket.org/vlad/planets
-

This brings the repository on BitBucket’s server up-to-date with the one on our own machine.

-

The next step is to connect the two repositories. We do this by making the BitBucket repository a remote for the local repository.

-

You’ll need the URL for the BitBucket repository, which is the same URL from the hg push statement above, but with the leading ssh://hg@ replaced with https://. Create a file .hg/hgrc in your local repository, and use your text editor to create a [paths] section in it, like so:

+

Select “I have an existing project”. We’re going to use a slight variation on those instructions. From within your planets directory, issue a command like:

+
$ hg push https://bitbucket.org/vlad/planets
+

It’s similar to the one shown under “I have an existing project” on the Bitbcucket page, but the URL should have your Bitbucket user name in it instead of vlad, and be prefixed with https://, not ssh://hg@.

+

The output from that command should look like:

+
pushing to https://bitbucket.org/vlad/planets
+searching for changes
+http authorization required for https://bitbucket.org/vlad/planets
+realm: Bitbucket.org HTTP
+user: vlad
+password:
+remote: adding changesets
+remote: adding manifests
+remote: adding file changes
+remote: added 3 changesets with 3 changes to 1 files
+

You will have to type your own Bitbucket user name and password.

+

This brings the repository on Bitbucket’s server up-to-date with the one on our own machine. Our local and remote repositories are now in this state:

+
+Bitbucket Repository After First Push

Bitbucket Repository After First Push

+
+

The next step is to connect the two repositories so that we don’t have to type the URL every time we do something with Bitbucket. We do this by making the Bitbucket repository a remote for the local repository. You’ll need the URL for the Bitbucket repository, which is the same URL from the hg push statement above.

+

Use the command:

+
$ hg config --local
+

to open your local repository’s configuration file in your editor. You should see a template file that looks like:

+
# example repository config (see "hg help config" for more info)
+[paths]
+# path aliases to other clones of this repo in URLs or filesystem paths
+# (see "hg help config.paths" for more info)
+#
+# default      = http://example.com/hg/example-repo
+# default-push = ssh://jdoe@example.net/hg/jdoes-fork
+# my-fork      = ssh://jdoe@example.net/hg/jdoes-fork
+# my-clone     = /home/jdoe/jdoes-clone
+
+[ui]
+# name and email (local to this repository, optional), e.g.
+# username = Jane Doe <jdoe@example.com>
+

Edit the file so that it has just 2 lines:

[paths]
 default = https://bitbucket.org/vlad/planets
-

Make sure to use the URL for your repository rather than Vlad’s and to prefix the URL with https://, not ssh://hg@.

+

Make sure to use the URL for your repository rather than Vlad’s (the one from the hg push command above), and that the prefix in the URL is https://, not ssh://hg@.

+

Save the file. It will automatically be stored in planets/.hg/hgrc.

We can check that the command has worked by running hg paths:

$ hg paths
default = https://bitbucket.org/vlad/planets
-

Now that the default path is set up, we won’t need to specify the target when we run hg push in the future; running hg push will automatically push the changes from our local repository to the repository on BitBucket:

+

Now that the default path is set up, we won’t need to specify the target URL when we run hg push in the future; running hg push will automatically push the changes from our local repository to the repository on Bitbucket:

$ hg push
pushing to https://bitbucket.org/vlad/planets
 searching for changes
-adding changesets
-adding manifests
-adding file changes
-added 1 changesets with 1 changes to 1 files
-

Our local and remote repositories are now in this state:

-
-BitBucket Repository After First Push

BitBucket Repository After First Push

-
+no changes found +

This push has no effect because the two repositories are already synchronized.

We can pull changes from the remote repository to the local one as well:

$ hg pull
pulling from https://bitbucket.org/vlad/planets
 searching for changes
 no changes found
-

Pulling has no effect in this case because the two repositories are already synchronized. If someone else had pushed some changes to the repository on BitBucket, though, this command would download them to our local repository.

-

We can simulate working with a collaborator using another copy of the repository on our local machine. To do this, cd to the directory /tmp. (Note the absolute path: don’t make tmp a subdirectory of the existing repository). Instead of creating a new repository here with hg init, we will clone the existing repository from BitBucket:

+

Pulling has no effect in this case because the two repositories are already synchronized. If someone else had pushed some changes to the repository on Bitbucket, though, this command would download them to our local repository.

+

We can simulate working with a collaborator using another copy of the repository on our local machine. To do this, cd to the directory /tmp. (Note the absolute path: don’t make tmp a subdirectory of the existing repository). Instead of creating a new repository here with hg init, we will clone the existing repository from Bitbucket:

$ cd /tmp
 $ hg clone https://bitbucket.org/vlad/planets

hg clone creates a fresh local copy of a remote repository. (We did it in /tmp or some other directory so that we don’t overwrite our existing planets directory.) Our computer now has two copies of the repository:

@@ -97,7 +124,7 @@

Learning Objectives

It is so a planet!
$ hg add pluto.txt
 $ hg commit -m "Some notes about Pluto"
-

then push the change to BitBucket:

+

then push the change to Bitbucket:

$ hg push
pushing to https://bitbucket.org/vlad/planets
 searching for changes
@@ -155,7 +182,7 @@ 

Learning Objectives

Bitbucket Timestamp
-

Create a repository on BitBucket, clone it, add a file, push those changes to BitBucket, and then look at the timestamp of the change on BitBucket. How does BitBucket record times, and why?

+

Create a repository on Bitbucket, clone it, add a file, push those changes to Bitbucket, and then look at the timestamp of the change on Bitbucket. How does Bitbucket record times, and why?

diff --git a/04-open.html b/04-open.html index b0a6fa0..e2e7199 100644 --- a/04-open.html +++ b/04-open.html @@ -106,7 +106,7 @@

Can I Use an Open License?Hosting

The second big question for groups that want to open up their work is where to host their code and data. One option is for the lab, the department, or the university to provide a server, manage accounts and backups, and so on. The main benefit of this is that it clarifies who owns what, which is particularly important if any of the material is sensitive (i.e., relates to experiments involving human subjects or may be used in a patent application). The main drawbacks are the cost of providing the service and its longevity: a scientist who has spent ten years collecting data would like to be sure that data will still be available ten years from now, but that’s well beyond the lifespan of most of the grants that fund academic infrastructure.

Another option is to purchase a domain and pay an Internet service provider (ISP) to host it. This gives the individual or group more control, and sidesteps problems that can arise when moving from one institution to another, but requires more time and effort to set up than either the option above or the option below.

-

The third option is to use a public hosting service like GitHub, BitBucket, Google Code, or SourceForge. All of these allow people to create repositories through a web interface, and also provide mailing lists, ways to keep track of who’s doing what, and so on. They all benefit from economies of scale and network effects: it’s easier to run one large service well than to run many smaller services to the same standard, and it’s also easier for people to collaborate if they’re using the same service, not least because it gives them fewer passwords to remember.

+

The third option is to use a public hosting service like GitHub, Bitbucket, Google Code, or SourceForge. All of these allow people to create repositories through a web interface, and also provide mailing lists, ways to keep track of who’s doing what, and so on. They all benefit from economies of scale and network effects: it’s easier to run one large service well than to run many smaller services to the same standard, and it’s also easier for people to collaborate if they’re using the same service, not least because it gives them fewer passwords to remember.

However, all of these services place some constraints on people’s work. In particular, most give users a choice: if they’re willing to share their work with others, it will be hosted for free, but if they want privacy, they may have to pay. Sharing might seem like the only valid choice for science, but many institutions may not allow researchers to do this, either because they want to protect future patent applications or simply because what’s new is frightening.