You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Mercurial.md 5.0 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. Mercurial is a version control system, like
  2. [subversion](/svn "wikilink") in that it manages changes in your code,
  3. but different in that it\'s designed to be distributed. Git and bazaar
  4. are also distributed version control systems. Mercurial is also written
  5. in python, which is [cool](http://xkcd.com/353/). It\'s built in web
  6. interface is also excellent.
  7. ## Setting Up On RedBrick
  8. All the setup needs to be done on murphy, since that\'s the webserver.
  9. After that, you can access your code from anywhere.
  10. First, we need to setup the repo that will contain the code
  11. `receive@murphy (~) % hg init hgrepo`
  12. Next, we setup the web access\...
  13. ### Step 1 - Create the directory, and copy in the python cgi
  14. `receive@murphy (~) % cd ~/public_html`\
  15. `receive@murphy (~/public_html) % mkdir hg`\
  16. `receive@murphy (~/public_html) % chmod 711 hg`\
  17. `receive@murphy (~/public_html) % cd hg`\
  18. `receive@murphy (~/public_html/hg) % cp /usr/share/doc/mercurial-common/examples/hgweb.cgi ./index.cgi`\
  19. `receive@murphy (~/public_html/hg) % chmod 755 index.cgi`
  20. ### Step 2 - Set the repo location
  21. Open the index.cgi in nano (or any other text editor) and on the second
  22. to last line replace /YOUR/HOME/DIR/YOUR/REPO with the location of the
  23. repo you created. For me, this is /home/member/r/receive/hgrepo - the
  24. location will depend on where your home directory is. Optionally,
  25. replace \"repository name\" with something cooler.
  26. ### Step 3 - Set Up htaccess
  27. `receive@murphy (~/public_html/hg) % touch .htaccess`\
  28. `receive@murphy (~/public_html/hg) % chmod 644 .htaccess`
  29. Open the htaccess file in a text editor.
  30. RewriteEngine On
  31. ##################################
  32. # Force all access to over https #
  33. ##################################
  34. RewriteCond %{SERVER_PORT} 80
  35. RewriteRule (.*) https://www.redbrick.dcu.ie/~receive/hg/
  36. ###################################
  37. # Options for rewriting hg access #
  38. ###################################
  39. RewriteCond %{SERVER_PORT} 443
  40. #write base depending on where the base url lives
  41. RewriteBase /~receive/hg
  42. # Send requests for files that exist to those files.
  43. RewriteCond %{REQUEST_FILENAME} !-f
  44. # Send requests for directories that exist to those directories.
  45. RewriteCond %{REQUEST_FILENAME} !-d
  46. # Send requests to hgwebdir.cgi, appending the rest of url.
  47. RewriteRule (.*) index.cgi/$1 [QSA,L]
  48. ################################
  49. # Options for password control #
  50. ################################
  51. AuthType Basic
  52. AuthName "My Mercurial Repo"
  53. AuthUserFile /home/member/r/receive/.hgpasswd
  54. Require valid-user
  55. You can use this htaccess file as a sample, but you\'ll need to make a
  56. few changes. The rewrite base should be set to the location on the
  57. webserver you created the hg directory. If you\'ve been following the
  58. same example names I used it will be \~username/hg
  59. Also, you\'ll need to set the location you\'re going to use for your
  60. htpasswd file.
  61. ### Step 4: Create the password file
  62. `receive@murphy (~/public_html/hg) % htpasswd -c /home/member/r/receive/.hgpasswd receive`
  63. This will prompt you to enter your new password twice.
  64. `receive@murphy (~/public_html/hg) % chmod 644 /home/member/r/receive/.hgpasswd`
  65. ## Using LDAP instead of the password file
  66. In the .htaccess you created earlier replace the Options for password
  67. control with the following:
  68. ################################
  69. # Options for password control #
  70. ################################
  71. AuthType Basic
  72. AuthBasicProvider ldap
  73. AuthName "Some sort of name"
  74. AuthLDAPURL ldap://192.168.0.3:389/o=redbrick?uid?sub?objectClass=posixAccount
  75. AuthzLDAPAuthoritative Off
  76. Require valid-user
  77. And hey presto, no need for a password file and you can log in with your
  78. redbrick details, of course so can anyone else so if you want to
  79. restrict access replace
  80. `Require valid-user`
  81. with
  82. `Require user username1 username2 (Obviously replace username1 username2 with actual usernames etc)`
  83. ## Cloning the Repo
  84. Once all this is done you should be able to login at
  85. <https://www.redbrick.dcu.ie/~username/hg> - of course you won\'t see
  86. any code there yet.
  87. Go to whatever computer you want to start writing code on and clone a
  88. copy of the repo
  89. `andrew@laptop:~ $ hg clone`[`https://www.redbrick.dcu.ie/~receive/hg/`](https://www.redbrick.dcu.ie/~receive/hg/)
  90. Now I have a copy of the repo on my laptop I can work on. You should
  91. [read the guide](http://mercurial.selenic.com/guide/) to see all the
  92. commands that are available, but the basics you\'ll need are hg add and
  93. hg commit.
  94. ## Pushing
  95. Before you are able to push changes to your repo you will need to
  96. specify which users have permission to do so. You will need to add the
  97. following lines to the configuration for your repo (\~/hgrepo/.hg/hgrc).
  98. `[web]`\
  99. `allow_push = *`
  100. If you wish to only give certain users permission to push changes to
  101. your repo replace \* with their usernames.
  102. Now once you make changes you can push them back to your repo on
  103. RedBrick.
  104. `andrew@laptop:~/hg $ hg push`
  105. You can now look at the changes on the web interface :)