borup mercurial published-fineprint
Post on 03-Jun-2018
238 Views
Preview:
TRANSCRIPT
8/12/2019 Borup Mercurial Published-fineprint
http://slidepdf.com/reader/full/borup-mercurial-published-fineprint 1/30
8/12/2019 Borup Mercurial Published-fineprint
http://slidepdf.com/reader/full/borup-mercurial-published-fineprint 2/30
8/12/2019 Borup Mercurial Published-fineprint
http://slidepdf.com/reader/full/borup-mercurial-published-fineprint 3/30
8/12/2019 Borup Mercurial Published-fineprint
http://slidepdf.com/reader/full/borup-mercurial-published-fineprint 4/30
8/12/2019 Borup Mercurial Published-fineprint
http://slidepdf.com/reader/full/borup-mercurial-published-fineprint 5/30
8/12/2019 Borup Mercurial Published-fineprint
http://slidepdf.com/reader/full/borup-mercurial-published-fineprint 6/30
8/12/2019 Borup Mercurial Published-fineprint
http://slidepdf.com/reader/full/borup-mercurial-published-fineprint 7/30
8 / 30
8/12/2019 Borup Mercurial Published-fineprint
http://slidepdf.com/reader/full/borup-mercurial-published-fineprint 8/30
VFP Version Control with Mercurial
© 2011 Rick Borup Page 15 of 5
To chec/ this out, he decides to update the wor/ing directory bac/ to his original ;ersion of
fox!prg, which is stored as re;ision 0 in the repository!
C:\ob\!#6ro=ect>hg update &r$
1 "iles updatedE $ "iles !ergedE $ "iles re!ovedE $ "iles unresolved
e then uses the -indows type co))and as a >uic/ way to ;iew the contents of fox!prg!
C:\ob\!#6ro=ect>t#pe "o.prg
8 G5o roc's;G
And ;oil 9ob sees that 'ercurial has updated fox!prg in the wor/ing directory bac/ to the
way it was in re;ision 0!
To co)plete the test, he issues the update co))and with no para)eter to tell 'ercurial to
update the wor/ing directory to the )ost current re;ision!
C:\ob\!#6ro=ect>hg update1 "iles updatedE $ "iles !ergedE $ "iles re!ovedE $ "iles unresolved
(isplaying the contents of fox!prg, he sees it once again includes the change he )ade and
co))itted in re;ision !
C:\ob\!#6ro=ect>t#pe "o.prg
"or i J 1 to
8 G5o roc's;G-nd"or
At this point, 9obCs con4idence in 'ercurial is running high and heCs feeling co)fortable
with the basic process of adding, co))itting, and updating! e decides itCs ti)e to
in;estigate Tortoiseg, the -indows shell for 'ercurial!
Introducing TortoiseHg
The best way to learn how 'ercurial wor/s is to in;o/e the indi;idual co))ands fro) the
co))and pro)pt, as the pre;ious exa)ples ha;e shown! -hile you can continue to do
e;erything you need to do fro) the co))and pro)pt, de;elopers who are accusto)ed to
wor/ing in a G7+ en;iron)ent will )ost li/ely prefer to use the Tortoiseg shell!
The Tortoiseg shell is tightly integrated with -indows explorer! 'ost of the features and
functions youCll use on a regular basis are a;ailable fro) a rightclic/ context )enu! The
pri)ary Tortoiseg interface, called the Tortoiseg -or/bench, can be launched either
fro) the context )enu or directly fro) the -indows Start )enu!
VFP Version Control with Mercurial
© 2011 Rick Borup Page 1$ of 5
Figure ." The Tortoiseg context )enu pro;ides access to the features and functions youCll )ost co))onlyuse when wor/ing with 'ercurial!
9ob decides to use Tortoiseg to ta/e a loo/ at the wor/ heCs already done! e launches the
Tortoiseg -or/bench by rightclic/ing on the C:\>Bob\myProject folder in -indows
6xplorer and choosing Hg Workbench fro) the context )enu! e then selects re;ision 0 in
the list and begins to explore the Tortoiseg interface as shown in Figure !
8 / 30
9 / 30
8/12/2019 Borup Mercurial Published-fineprint
http://slidepdf.com/reader/full/borup-mercurial-published-fineprint 9/30
VFP Version Control with Mercurial
© 2011 Rick Borup Page 17 of 5
Figure " The Tortoiseg interface pro;ides a ;isual, )ultipane interface to 'ercurial!
9ob can see that the top)ost pane of the Tortoiseg window shows the re;ision history in
re;erse chronological order! e realizes this is the sa)e infor)ation he got fro) the log
co))and when he was wor/ing fro) the co))and pro)pt, although in a so)ewhat
different for)at!
The lower panes display detailed infor)ation about the selected re;ision! -ith re;ision 0
selected, 9ob can see that the fox!prg 4ile was added, what its content was at that ti)e, thechangeset +( that was assigned, and what co))it )essage was associated with it!
&ontinuing to explore Tortoiseg, 9ob selects re;ision in the list! The lower panes now
display infor)ation about that re;ision, as shown in Figure :!
VFP Version Control with Mercurial
© 2011 Rick Borup Page 1! of 5
Figure :" (etails of the re;ision selected in the upper pane in the Tortoiseg -or/bench are displayed in thelower panes!
So far 9ob has used Tortoiseg only to re;iew changes he already co))itted fro) the
co))and line, but he /nows that later on heCll )ost li/ely stop using the co))and line and
begin using Tortoiseg exclusi;ely for his co))its and other interactions with 'ercurial!
Branching and merging within a repository One of the funda)ental re>uire)ents for any ;ersion control syste) is the ability to create
and )anage branches! (e;elopers create branches whene;er itCs necessary or desirable to
separate one line of de;elop)ent fro) another! 'ercurial enables branching, but in a way
that )ay be so)ewhat different fro) what youCre used to if youC;e used other ;ersion
control syste)s!
'ercurial pro;ides two closely related co))ands for wor/ing with branches! The branches
co))and pluralB displays the branches currently in the local repository, while the branch
co))and is used to create a new branch!
9 / 30
8/12/2019 Borup Mercurial Published-fineprint
http://slidepdf.com/reader/full/borup-mercurial-published-fineprint 10/30
8/12/2019 Borup Mercurial Published-fineprint
http://slidepdf.com/reader/full/borup-mercurial-published-fineprint 11/30
8/12/2019 Borup Mercurial Published-fineprint
http://slidepdf.com/reader/full/borup-mercurial-published-fineprint 12/30
8/12/2019 Borup Mercurial Published-fineprint
http://slidepdf.com/reader/full/borup-mercurial-published-fineprint 13/30
8/12/2019 Borup Mercurial Published-fineprint
http://slidepdf.com/reader/full/borup-mercurial-published-fineprint 14/30
15 / 30
8/12/2019 Borup Mercurial Published-fineprint
http://slidepdf.com/reader/full/borup-mercurial-published-fineprint 15/30
VFP Version Control with Mercurial
© 2011 Rick Borup Page 2 of 5
Figure " The graphical display in Tortoiseg shows that 9obCs local repository has two heads, one that hecreated Are; 8B and the other Are; .B created by &arol, which was added to 9obCs repository as a result of the pull !
+n addition to suggesting that he run the heads co))and, 'ercurial also suggested that
9ob needed to do a merge! So thatCs what he does!
C:\ob\!#6ro=ect>hg !erge
!erging "o.prg
-hat 'ercurial does at this point depends on which tool, if any, 9ob has set up to handle
)erge con4licts! 9ob has been a long ti)e fan of the excellent 9eyond &o)pare utility fro)
Scooter Software, and has con4igured 'ercurial to use it as his default )erge conflict
resolution progra)! 9ecause there is in fact a )erge con4lict in this exa)ple, 'ercurial
opens 9eyond &o)pareCs threeway )erge tool so 9ob can see and resol;e the con4lict!
VFP Version Control with Mercurial
© 2011 Rick Borup Page "0 of 5
Figure 2" 'ercurial can be con4igured to use 9eyond &o)pareCs threeway )erge tool to resol;e )erge
conflicts!
-hate;er )erge tool you use, the concept is the sa)e" there is a base ;ersion of the line or
lines in conflict Atop center, in Figure 2B, there are the two co)peting changed ;ersions
Atop left and top rightB, and there is so)e way Athe edit panel, botto)B for you to edit the
4ile and resol;e the con4lict!
+n this case, 9ob )a/es a co))and decision" he decides to co)pro)ise between the two
changes and display the )essage : ti)es! &arol wonCt care, since she did what she was told,
and after a few beers on the golf course the 'ar/eting $% wonCt re)e)ber what he told9ob anyway! 9ob )a/es the change to the )erged ;ersion in the botto) panel and sa;es
the edited 4ile, as shown in Figure 5!
16 / 30
8/12/2019 Borup Mercurial Published-fineprint
http://slidepdf.com/reader/full/borup-mercurial-published-fineprint 16/30
VFP Version Control with Mercurial
© 2011 Rick Borup Page "1 of 5
Figure 5" -hen a )erge con4lict occurs, the de;eloper needs to )a/e the changeAsB necessary to resol;e thecon4lict and then sa;e the )erged 4ile!
-hile 9ob has been wor/ing in 9eyond &o)pare, 'ercurial has been is a suspended state
waiting on a resolution to the )erge con4lict! -hen 9ob sa;es the )erged 4ile and closes
9eyond &o)pare, 'ercurial detects that the con4lict has been resol;ed and co)pletes its
)erge operation!0
C:\ob\!#6ro=ect>hg !erge!erging "o.prg
$ "iles updatedE 1 "iles !ergedE $ "iles re!ovedE $ "iles unresolved(branch !ergeE donOt "orget to co!!it)
The ;ersion of fox!prg that 9ob <ust sa;ed is now stored in his wor/ing directory, but his
local repository doesnCt ha;e a record of that change yet! ThatCs why 'ercurial pro)pted
9ob to do a co))it, which he does!
0 +n this exa)ple, 'ercurial /new the con4lict had been resol;ed because it was set up to be integrated with9eyond &o)pare! +f 9ob had not been using an integrated tool and had si)ply edited fox!prg )anually,'ercurial would ha;e had no way of /nowing the con4lict was resol;ed! 'ercurial pro;ides a resol!e
co))and to handle this situation! 9ob would ha;e run hg resol!e fox"prg to let 'ercurial /now the con4lict
had been resol;ed!
VFP Version Control with Mercurial
© 2011 Rick Borup Page "2 of 5
C:\ob\!#6ro=ect>hg co!!it &! Gresolved !erge con"lictE changed to ? ti!esG
9ob could now run the log co))and to see a record of the )ost recent changes! e can also
;iew the history in the Tortoiseg graphical interface, as shown in Figure *! 6ither way,
he sees that there is a new re;ision 0 representing the resolution of the )erge con4lict!
Figure *" The Tortoiseg graphical display i llustrates the )erge con4lict at re;isions 8 and ., and itsresolution at re;ision 0!
Net )e stress again that e;erything thatCs been done fro) the co))and pro)pt in theseexa)ples could also ha;e been done using Tortoiseg! (onCt get the i)pression that the Tortoiseg
-or/bench is only for ;iewing 3 itCs a co)pletely interacti;e tool for wor/ing with 'ercurial! + ha;e
chosen to introduce 'ercurialCs beha;ior using its co))ands fro) the co))and pro)pt because +belie;e thatCs a better way to learn the funda)entals! a;ing now learned about the indi;idualco))ands, youCll ha;e a better understanding of what Tortoiseg is doing behind the scenes!
8/12/2019 Borup Mercurial Published-fineprint
http://slidepdf.com/reader/full/borup-mercurial-published-fineprint 17/30
8/12/2019 Borup Mercurial Published-fineprint
http://slidepdf.com/reader/full/borup-mercurial-published-fineprint 18/30
19 / 30
8/12/2019 Borup Mercurial Published-fineprint
http://slidepdf.com/reader/full/borup-mercurial-published-fineprint 19/30
VFP Version Control with Mercurial
© 2011 Rick Borup Page "7 of 5
+n )y opinion, this is not a bad thing!
Although integrating your ;ersion control syste) with the $F% %ro<ect 'anager )ay
pro;ide so)e )easure of con;enience, there is also a downside! First of all, that interface is
designed around the centralized ;ersion control syste) idea of chec/ing 4iles in and out,
concepts which donCt apply to a distributed ;ersion control syste)! Second, there can be aperfor)ance penalty when wor/ing with large pro<ects! And 4inally, if youCre using a
re)ote repository and the connection to that repository is una;ailable, youCre pretty )uch
dead in the water because you canCt chec/ out any 4iles to wor/ on the)! Sure, there are
wor/arounds, but it gets )essy!
'y general rule of thu)b, based on )y own experience and fro) tal/ing to others, is not to
integrate your ;ersion control syste) with the $F% %ro<ect 'anager e;en if your $&S does
support it! Iaturally your opinion )ay ;ary, but if youCre using 'ercurial the decision has
already been )ade for you because you canCt do it e;en it you wanted to!
Integrating Mercurial into your daily development workflowDouC;e seen what 'ercurial can do for you, so you decide to install it and begin using it in
your daily $isual Fox%ro de;elop)ent wor/! ow do you get started?
#tep $ % Create a local repository
Assu)ing you ha;e an existing $isual Fox%ro pro<ect you want to place under 'ercurial
;ersion control, the 4irst step is to create the local repository! This is easily done fro) the-indows 6xplorer context )enu! The wor/ing directory will be the existing root folder of
your pro<ect, for exa)ple &"LS-Fox20LSessionsL'ercurialL)y$F%App! =ightclic/ on
that folder in -indows 6xplorer and choose Create 'epositor+ ,ere fro) the Tortoiseg
)enu pad!
VFP Version Control with Mercurial
© 2011 Rick Borup Page "! of 5
Figure 8" 'uch of what youCll want to do with 'ercurial, such as creating a new repository, is a;ailable fro)
the context )enu in -indows 6xplorer!
A s)all dialog window opens and presents a couple of options 3 you can si)ply accept the
defaults! -hen you clic/ the Create button Tortoiseg issues the init co))and to
'ercurial, which in turn creates the !hg local repository folder in your wor/ing directory!
Figure ." -hen you use Tortoiseg to create a new repository, it offers a couple of options and shows you
the hg init co))and it will run!
8/12/2019 Borup Mercurial Published-fineprint
http://slidepdf.com/reader/full/borup-mercurial-published-fineprint 20/30
VFP Version Control with Mercurial VFP Version Control with Mercurial
21 / 30
8/12/2019 Borup Mercurial Published-fineprint
http://slidepdf.com/reader/full/borup-mercurial-published-fineprint 21/30
VFP Version Control with Mercurial
© 2011 Rick Borup Page #1 of 5
Figure :" The lower left panel in the Tortoiseg -or/bench shows the status of the 4iles in the wor/ingdirectory!
Tortoiseg )a/es it easy to do both the add and the co))it in one step! First, )ar/ the
chec/ box for e;ery 4ile you want to add to the local repository! Dou can )ar/ the)
indi;idually, or you can si)ply )ar/ the Jchec/ all 4ilesK chec/ box abo;e the list see
Figure :B and Tortoiseg will )ar/ the) all for you!
Iote that the !hgignore 4ile itself is included in the list! +tCs a good idea to )ar/ the chec/
box for this 4ile so 'ercurial will trac/ the history of changes to it along with those to yourpro<ectCs other files!
After re;iewing the list of 4iles to be sure itCs the way you want it, enter a co))it )essage
in the 4ield to the right of the list and clic/ the &o))it button! A brief co))ent such as
J+nitial co))itK is generally considered to be appropriate for the 4irst co))it to a new
repository!
VFP Version Control with Mercurial
© 2011 Rick Borup Page #2 of 5
Figure " After )ar/ing all the 4iles whose changes you want to trac/, enter a co))it )essage and clic/ theCommit button to add these 4iles to your local repository!
Tortoiseg displays a dialog as/ing if you want to add the selected untrac/ed 4iles! This is
how it does the add and co))it in one step! &lic/ the Add button to proceed!
Figure 20" +f youC;e )ar/ed untrac/ed 4iles to be included in the co))it, Tortoiseg pro)pts you to addthe)!
And thatCs itG Dour pro<ect is now under 'ercurial ;ersion control, and the current ;ersions
of all trac/ed 4iles are now recorded in the local repository! Noo/ing at the upper)ost
panel in Tortoiseg, you can see that the local repository now contains changeset 0, whichis )ar/ed as the tip re;ision and which carries your co))it )essage of J+nitial &o))itK!
8/12/2019 Borup Mercurial Published-fineprint
http://slidepdf.com/reader/full/borup-mercurial-published-fineprint 22/30
8/12/2019 Borup Mercurial Published-fineprint
http://slidepdf.com/reader/full/borup-mercurial-published-fineprint 23/30
8/12/2019 Borup Mercurial Published-fineprint
http://slidepdf.com/reader/full/borup-mercurial-published-fineprint 24/30
8/12/2019 Borup Mercurial Published-fineprint
http://slidepdf.com/reader/full/borup-mercurial-published-fineprint 25/30
8/12/2019 Borup Mercurial Published-fineprint
http://slidepdf.com/reader/full/borup-mercurial-published-fineprint 26/30
VFP Version Control with Mercurial VFP Version Control with Mercurial
27 / 30
8/12/2019 Borup Mercurial Published-fineprint
http://slidepdf.com/reader/full/borup-mercurial-published-fineprint 27/30
© 2011 Rick Borup Page 5" of 5
Figure 28" The 'ercurial web ser;er enables you to ;iew details about a changeset along with the actual
content of the 4iles in the repository!
&lic/ing on the diff lin/, 9ob 4inds that this little -eb ser;er can e;en display the difference
between the selected re;ision and the pre;ious one, using the uni;ersal diff for)at!
© 2011 Rick Borup Page 5# of 5
Figure 2." The builtin -eb ser;er can e;en display the diff between the selected re;ision of a 4ile and the
pre;ious re;ision, using colors to help )a/e it )ore readable!
+f youCre interested, you can explore the other functions offered by the 'ercurial -ebser;er on your own!
+f 9ob wanted to, he could enable &arol Aor anybody elseB to push changes to his repository!
To do this, he 4irst has to )a/e a couple of entries in the pro<ectCs hgrc con4iguration 4ile!
The 4irst is to indicate that secure http AhttpsB is not re>uired, which it otherwise would be
by default! The second is allow anybody to push changes without re>uiring authorization!2
9ob creates a [web] section and )a/es the following two entries in the pro<ectCs hgrc 4ile! +f
he was using Tortoiseg, he could also do this ;ia the Settings dialog in Tortoiseg
-or/bench!
HebI
pushTssl J 5alsealloTpush J Q
+f the 'ercurial ser;er is running when these changes are )ade, it needs to be restarted for
the changes to ta/e effect! Once thatCs been done, itCs ready to go and &arol can push
2 This ob;iously opens a huge security hole, but under controlled conditions you can do so if only for testingand experi)entation! =e)e)ber to shut down the 'ercurial ser;er as soon as youCre done using it, thoughG
8/12/2019 Borup Mercurial Published-fineprint
http://slidepdf.com/reader/full/borup-mercurial-published-fineprint 28/30
8/12/2019 Borup Mercurial Published-fineprint
http://slidepdf.com/reader/full/borup-mercurial-published-fineprint 29/30
VFP Version Control with Mercurial
30 / 30
8/12/2019 Borup Mercurial Published-fineprint
http://slidepdf.com/reader/full/borup-mercurial-published-fineprint 30/30
© 2011 Rick Borup Page 5 of 5
Tortoiseg docu)entation"
http"##tortoisehg!bitbuc/et!org#)anual#2!
Tutorial by oel Spols/y"
http"##hginit!co)
6)ail listser;e"
https"##lists!sourceforge!net#lists#listinfo#tortoisehgissues
Summary'ercurial is an easytoinstall and easytouse distributed ;ersion control syste)! +tCs a
great choice for $isual Fox%ro de;elopers and others wor/ing on -indows )achines,
especially when used in concert with the Tortoiseg shell! 'ercurial offers signi4icant
bene4its not only to tea)s but also to independent de;elopers wor/ing solo!
+f youCre using a different ;ersion control syste) but are less than fully satis4ied with it,
'ercurial )ay be <ust what youCre loo/ing for! 'ercurial can i)port ;ersion history fro)
;arious other syste)s including Sub;ersion and git, so )igration )ay be easier than you
thin/! +f youCre not using a ;ersion control syste) at all, what are you waiting for?
'ercurial is a great way to get started!
Copyright 2011 Rick Borup. Windows® is a registered trademark of Microsoft Corporation in
the United tates and other countries. !"" other trademarks are the property of their
respecti#e owners.
top related