Tuesday, November 27, 2012

Updating a local mercurial project

In the previous article, we cloned the pyptug repository from bitbucket. But what if the repository changes (and it did, this morning)?

Follow me


First, make sure you have signed up to bitbucket and follow the repository ( https://bitbucket.org/fdion/pyptug ). That way you will get an email notification when there is a change.

Solid Hg


Next, you need to go into the pyptug directory and issue:

 fdion@srv:~/bitbucket$ cd pyptug/  
 fdion@srv:~/bitbucket/pyptug$ hg incoming http://bitbucket.org/fdion/pyptug  
 warning: bitbucket.org certificate with fingerprint 24:9c:45:8b:9c:aa:ba:55:4e:01:6d:58:ff:e4:28:7d:2a:14:ae:3b not verified (check hostfingerprints or web.cacerts config setting)  
 real URL is https://bitbucket.org/fdion/pyptug  
 comparing with http://bitbucket.org/fdion/pyptug  
 searching for changes  
 changeset:  1:8e0c4e63bbb1  
 user:    fdion@bitbucket.org  
 date:    Mon Nov 26 09:52:46 2012 -0500  
 summary:   pep8 compliance  
 changeset:  2:638251f3f511  
 user:    fdion@bitbucket.org  
 date:    Mon Nov 26 10:39:57 2012 -0500  
 summary:   pep8 and fo3 fix  
 changeset:  3:b09297ef88b2  
 user:    fdion@bitbucket.org  
 date:    Mon Nov 26 10:43:09 2012 -0500  
 summary:   pep8 compliance  
 changeset:  4:9e0101cf03f8  
 user:    fdion@bitbucket.org  
 date:    Mon Nov 26 10:45:04 2012 -0500  
 summary:   pep8 compliance  
 changeset:  5:89aa2b01e1be  
 tag:     tip  
 user:    fdion@bitbucket.org  
 date:    Tue Nov 27 06:24:25 2012 -0500  
 summary:   Missing if __name__ ==  
 fdion@srv:~/bitbucket/pyptug$ hg pull http://bitbucket.org/fdion/pyptug  
 warning: bitbucket.org certificate with fingerprint 24:9c:45:8b:9c:aa:ba:55:4e:01:6d:58:ff:e4:28:7d:2a:14:ae:3b not verified (check hostfingerprints or web.cacerts config setting)  
 real URL is https://bitbucket.org/fdion/pyptug  
 pulling from http://bitbucket.org/fdion/pyptug  
 searching for changes  
 adding changesets  
 adding manifests  
 adding file changes  
 added 5 changesets with 9 changes to 9 files  
 (run 'hg update' to get a working copy)  
 fdion@srv:~/bitbucket/pyptug$ hg update  
 9 files updated, 0 files merged, 0 files removed, 0 files unresolved  

The hg incoming will basically tell us what the changes are, but will not download them. This is purely informational, you can skip that step if you want.

The hg pull command is what gets the changes to the pyptug repository pulled to your local machine.

Finally, hg update will apply those changes to a working copy. In the above example, 9 files have been changed over 5 changesets since I first published the repository.

Chchch...changes


If you are curious as to what was the change:

When running a web.py application through wsgi, and that means not only mod_wsgi or an external wsgi server, but also when running as python script.py [port] (since it will launch CherryPy), it is required to use:

if __name__ == "__main__":
to invoke app.run(). Else, it will lock itself by trying to open a socket on the same port twice.

hw2.py and hw3.py didn't have this. Although it did work in my automatic deployment test setup (uses cgi instead of wsgi so I can test every applications all at once), it didn't work in a standalone install.


No comments: