Newbie Guide for Windows People Working on Minor Bugs

From Dreamwidth Notes
Revision as of 14:36, 21 August 2011 by Ninetydegrees (Talk | contribs)

Jump to: navigation, search
Note: Feel free to correct, add, expand, anything that could make this better and clearer. ^_^


Install and Set Things Up

This may seem like a lot of things to do before you can really get started, things you're probably not familiar with but 1) you can do it 2) you'll only have to do this once.


Get a Dreamhack

What's a Dreamhack? To put it simply, it's an online mirror of the Dreamwidth site which is set up for any developer, beginner or experienced, who asks for it. This way, you don't have to go through the complicated process of installing the Dreamwidth code on your computer.

  • Apply for a Dreamhack by filling this form. The two important fields are 'Your Desired Username' and 'Your email address'. Note that your username is the name you'll use to log in to your Dreamhack; it's not the name of your account over there so no need to agonize over it. ;) Your e-mail address is used to send you a welcome e-mail which contains important information as well as maintenance/issue alerts and reinstall e-mails if you need to reinstall so it does matter. Also, some people like having an e-mail account specifically devoted to development. It's up to you.
  • Once you're done, you should get an e-mail with your login username and a password. Don't lose it. Once you've gotten this e-mail, you need to install two programs to be able to manage your Dreamhack: PuTTY and WinSCP.


Install PuTTY

What for? PuTTY will allow you to start and stop your Dreamhack, update it when changes are made (either by you or other developers) and generate patches.

  • Download PuTTY - choose the 'Windows installer for everything except PuTTYtel' .exe file - and install it.
  • Run PuTTY. In the configuration window, enter "hack.dreamwidth.net" for the host name. Go to Connection/Data and enter the username/login given to you in the welcome e-mail. It should be something like dh-username.
  • Click on Open. If you get a pop-up message about a key, click Yes.
  • Enter the password given to you in the welcome e-mail when asked. Note that no characters are displayed and the cursor won't move. It's normal.
  • Change your password by typing:
passwd
  • And that's it for now. :)


Install WinSCP

What for? WinSCP will allow you to browse and edit your Dreamhack files.

  • Install WinSCP. During the installation, you may be asked about the mode you prefer: Commander and Explorer. Commander works like an FTP client: a partitioned window with your computer files on one side and the Dreamhack files on the other. Explorer will only display your Dreamhack files and works like Windows's Explorer. I prefer this mode because I don't need to access any files on my computer but choose what's best for you.
  • Use "hack.dreamwidth.net" for the host name. Enter your username and password (the new one!). Click on Save then on Login.


Set Up Your Dreamhack

Protect Your Config Files

  • Follow the steps outlined at Back Up Your Configs. This will make sure you always have clean copies of your config files in /config-backup.
In PuTTY, copy paste the code given to you in the box.
In PuTTY, copy paste the code given to you.
In WinSCP, go to /dw/cvs/local/cvs/.
In the right-sided window, right-click and select New/File. Call it multicvs-private.conf. Type the code given to you in the second box then save.
Go back to PuTTY and copy/paste the code given to you in the third box.


Create Scripts for Routine Tasks

  • Create the dwu, dws and dwdb scripts as explained in Scripting. U is for Update, S is for Synchronize, DB is for Database.
Go to WinSCP and create the three files in /bin (again by right-clicking) with the code given to you in the boxes. For dwu, use the code from the second box.
Go to PuTTY and make them executable using the chmod ugo+x command as explained. The code you need to type is bolded and is above each box of code. For dws use this command instead:
chmod ugo+x ~/bin/dws
For more scripts, see this entry.

Manage Your System Account

  • Your default Dreamhack account is called system. Go to PuTTY and type this to set its password:
$LJHOME/bin/upgrading/make_system.pl


Get Rid of Invite Codes

  • Go to WinSCP, to /dw/cvs/local/etc/, and double-click on config.pl. Find $USE_ACCT_CODES = 1; and change 1 to 0. Save your file.
  • Go to PuTTY and type this to make the changes go live on your Dreamhack:
cd $LJHOME
stop-apache
dws
dwdb
start-apache


Create a Bugzilla account

  • As [info]mark explained here, go to Name and Password and enter your name following this format: Name [:username]. 'Name' can be your real name, a nickname, your username again, etc. You don't have to give your real name if you don't want to.


Finish Setting Up Your Dreamhack

  • The final and last step is to create files and folders for patches.
  • In PuTTY, type this to create files and folders in ~/dw/cvs/dw-free/.hg/:
cd $LJHOME/cvs/dw-free
hg qinit -c
  • In WinSCP, open ~/dw/cvs/dw-free/.hg/hgrc and add this:
[ui]
username = username <username@gmail.com>
  • Change the second username to your Bugzilla name and the e-mail address to your Bugzilla address. Save the file.
  • In PuTTY again, type this to create files and folders in ~/dw/cvs/dw-nonfree/.hg/:
cd $LJHOME/cvs/dw-nonfree
hg qinit -c
  • In WinSCP, open ~/dw/cvs/dw-nonfree/.hg/hgrc and add this:
[ui]
username = username <username@gmail.com>
  • Change the second username to your Bugzilla name and the e-mail address to your Bugzilla address. Save the file.


How All of This Works

PuTTY, WinSCP or Bugzilla ?

  • You use PuTTY to update your Dreamhack code, make your changes go live on your Dreamhack, create patches and manage patches.
  • You use WinSCP to edit Dreamhack files.
  • You use Bugzilla to find bugs, file bugs, and upload patches.


Folders and Files You Work With

  • Your Dreamhack has two parts:
    • the live part (~/dw/*)
    • the repository part (~/dw/cvs/dw-free/* and ~/dw/cvs/dw-nonfree/*).
  • But you work with in the repositories: you edit repository files and you create patches in repository folders.


Updating Your Repository Code

  • Code is committed by developers all the time. You must regularly update your repositories by running the 'Update' script:
cd $LJHOME
stop-apache
dwu
start-apache
  • Note that this won't update your Dreamhack. You need to make the changes go live with the next step:


Making Changes Go Live on Your Dreamhack

  • To do that, you use the 'Synchronize' and 'DataBase' scripts:
cd $LJHOME
stop-apache
dws
dwdb
start-apache


Before You Edit Anything

Find or File a Bug

Some of these bugs won't appear to require 'minor' effort to you. It's normal. Try to find small bugs among them: minor modifications to be done on one of the site pages (text to be modified; elements to be added, removed or moved; elements to be hidden from some categories of users, etc.).
  • To assign a bug to yourself, enter your Bugzilla e-mail address in Assign To and set the status to ASSIGNED.
To make this easier, you can also use of [info]fu's Greasemonkey scripts: Dreamwidth Bug Grabber. Click on (grab!) next to Assign To and this will edit it and Status for you. Click on Save Changes of course.


Create a Patch

  • Open PuTTY and update everything by running the three scripts. You need to work with the latest code.
  • Go to dw-free by typing this:
cd $LJHOME
tocvs f
  • If you need to go to dw-nonfree, type this instead:
cd $LJHOME
tocvs n
  • Create a new patch by typing this (change NUMBER and PATCHNAME of course):
hg qnew -g bugNUMBER_PATCHNAME.diff


Edit Files

  • Use WinSCP to open the file(s) you need to edit. WinSCP will open the files with your default editor, probably Windows's Notepad. While you can use Notepad to edit files, it may not be the best editor you could use. I recommend Notepad++ instead.
To tell WinSCP to use another editor as default, go to View/Preferences/Editors. Click on Add/External Editor and Browse. At the end don't forget to click on Up to make it the first editor in the list.
  • If you're working on site pages, you're working on .bml files. These are in ~dw/cvs/dw-free/htdocs/ or one of the subsequent folders. You'll see that their names correspond to the URLs of site pages. These files may use .pm modules/widgets which are in ~dw/cvs/dw-free/cgi-bin/DW/ or ~dw/cvs/dw-free/cgi-bin/LJ/.
  • For text strings which are not in ~dw/cvs/dw-free/htdocs/xxx.bml.text files, see ~dw/cvs/dw-free/bin/upgrading/en.dat.
  • For more specific searches, you can use the grep command: grep [option(s)] pattern [file(s)]

Interesting options:

-E: match using extended regular expressions -F: match using fixed strings -r: recursive -i: case insensitive -l: filename only -n: add relative line number

Examples:

grep -ri "find this text" * | more
This will search for "find this text" in all files.
grep -rl print_entry $LJHOME/bin/upgrading/s2layers
This will search for files containing "print_entry" in the /s2layers folder.


Test Your Changes on Your Dreamhack

  • In PuTTY, stop your Dreamhack:
cd $LJHOME
stop-apache
  • Synchronize your live code and update your database:
dws
dwdb
  • Start your Dreamhack again:
start-apache
  • Go to your Dreamhack and test. Edit the files again in WinSCP if more changes are needed. Go through these steps again to test your new changes.


Submit Your Patch

Update & Save Your Patch

  • In PuTTY, go to dw-free or dw-nonfree (tocvs f or tocvs n)
  • Type this to update your patch file:
hg qrefresh
  • Go to your patch directory in WinSCP (e.g. /dw/cvs/dw-free/.hg/patches) and save a copy of your patch on your computer.
Warning: Do not manually edit your patch. This may cause errors make your patch invalid. Edit your file again. Refresh your patch. Test again.


Upload Your Patch to Bugzilla

  • Click on 'Add an Attachment' to attach your patch. Add a description, check 'patch' and set Flags/Commit and Flags/Review to ?. Feel free to add a comment if you have questions or remarks. Click on Submit.
To help you with this, you can use one of [info]fu's Greasemonkey scripts: Dreamwidth Patch Upload Defaults. This will automatically check 'patch' and set the flags for you.
  • Wait for someone to review and commit your patch. You're done. :)


Getting Back to Default Code

  • Pop your patch out of the pile with:
hg qpop
  • Then delete it:
hg qdel BUGNAME
If you want to keep the patch file, use hg qdel -k BUGNAME instead.
If you don't remember the name of your bug you can use hg qseries -v. This will list all the patches you have in your patch queue.
You can also the use the bug number in the queue instead of its name: hg qdel 0
  • And finally use dws and dwdb to remove changes from your Dreamhack.


More: Navigating Your Patch Queue

If you have a long list of patches and you want to make changes to a patch that is buried in your queue, you can use the hg qgoto command. Simply add the name or the number of your patch after it and it will pop patches until it reaches this patch. You can also use it to go back further up in the queue. It will then push patches until it reaches the one you want.


More: Reordering Patches

Sometimes, while making a patch, you realize something else needs to be fixed first and you go ahead and do that and forget all about the other patch till you realize you need to do further work on it and it's at the bottom of the stack. Of course, you can pop the other patch to be able to edit it but a simpler solution might be to reorder your patches providing they don't deal with the same code:

  • Pop all your patches with hg qpop -a.
  • Open /.hg/patches/series and reorder the lines.
  • Push all your patches again with hg qpush -a.


More: Merging Patches

Sometimes it's a good idea to do things in stages by creating several patches which can be applied successively. It allows you to easily go back to a previous version if things go wrong at some point without losing all your work, or to experiment. However, once you're satisfied with your work, you may want to merge your series of patches to upload only one for review. You can do that using the hg qfold command:

  • First unapply the patches you want to merge using hg qpop.
  • Create a new patch using hg qnew.
  • List the patches you want to merge after hg qfold. Be careful! You need to list them in the order you've created them so start with your oldest one.
hg qfold PATCH1 PATCH2 PATCH3
PATCH1 will be merged into NEW. PATCH2 will be merged into PATCH1. PATCH3 will be merged into PATCH2.


More: Importing a Patch

  • Sometimes you want to unapply a patch, go back to default code and reapply it later; or you need to import someone else's patch because you want to add something to it or because it blocks your own bug as you're working on the same file.
  • In PuTTY, create a new folder to store patches using the mkdir command:
mkdir ~/patches
  • If you want to save one of your own patches, simply copy/paste the patch into this folder with WinSCP.
  • If you want to import a patch from Bugzilla use the wget command to download it:
wget -O ~/patches/bugNUMBER_PATCHNAME.diff BUGZILLA_URL
The Bugzilla URL is something like http://bugs.dwscoalition.org/attachment.cgi?id=NUMBER
  • When you want to apply any of your stored patches, go to dw-free/dw-nonfree in PuTTY.
  • Put the patch in your patch queue:
hg qimport ~/patches/bugNUMBER_PATCHNAME.diff
  • Apply the patch when you want to:
hg qpush

More: Troubleshooting Tips

Issues With Update and Synchronize

  • If your repositories won't update properly with dwu, you may need to go to dw-free/dw-nonfree and remove all your local changes with hg update -C then run dwu again.
  • If dwu gets interrupted and you get an error message about one of the folders, you can try removing the folder and running update again:
cd $LJHOME/cvs
rm -rf FOLDERNAME
$LJHOME/bin/cvsreport.pl -checkout
  • If your live code won't sync with your repository code, it may be because the files you've edited got saved using your computer time and not distant time. As the system relies on timestamps to see which files need to be updated, updates won't happen if live files seem to be more recent than repository files. Quickest trick is to change your computer time, open and save your files again so they get a later timestamp, refresh your patch and sync again. Also, make sure to check the DST options in WinSCP (Environment section).

Issues With Patches and the Patch Queue

  • If you've forgotten to create your patch before you edited your files, don't panic. Try hg qnew -fg bugNUMBER_PATCHNAME.diff. This will force patch creation.
  • If you get an error message saying that 'working directory is not qtip' when trying to refresh, create, or do anything else related to patches, try hg update -C tip. You may have lost some of your changes but your patch queue should be working again.
  • If there's something wrong with your patch queue (it says the patch is not in the series or you can't delete a patch) don't forget that you can start over: delete the patches folder with WinSCP and recreate it again in PuTTY using hg qinit -c.

Issues With Text Strings

  • As [info]denise explained here, you need to delete old text strings and create new ones when you edit .text files or en.dat instead of simply editing the text. If the change isn't critical - the string doesn't need to be renamed or the text change is minor - it's better to notify the site copy team so that text can be changed locally and the original file left alone.
  • If text you've modified doesn't appear on the site after a code push, append ?uselang=debug to the page URL to make sure it's using the right string. If it is and it still doesn't display after a while, comment on [info]dw_maintenance.

Starting Over


More: Notepad++ Tips

  • Notepad++ has integrated syntax highlighting, which is very useful. However, since S2 is not an official language it's treated as normal text by the software. Depending on the part of the file you're editing, you can force Notepad++ to treat it as JavaScript, Perl, CSS or HTML. Go to the Language menu and select what's best for you.
  • Notepad++ has several syntax highlight themes you can choose. Go to Settings/Style Configurator to select your favorite. However, you'll see that when you open the program again it's gone back to using its default theme. To change that, open Explorer and go to C:/programs/Notepad++/themes. Copy paste your favorite theme into C:/programs/Notepad++. Rename it to stylers.xml. You may need Administrator rights to do this.
  • To permanently change the default values of your theme, you can edit the .xml file, save it to another folder then cut/paste it again in the right folder; it won't let you save it otherwise. You may need Administrator rights to do this.
  • To make sure you're using spaces and not tabs for indents, go to Settings/Preferences/Language Menu&Tab Settings and check 'Replace by space'.
  • To make sure white spaces and tabs are always displayed, go to View/Special Characters and check 'Show White Space and Tab'.
  • To deactivate the auto-indentation, go to Settings/Preferences/Misc and uncheck 'Auto-indent'.


References