-Now that we have a grasp of viewing history in Mercurial, let’s take a look at making some changes and examining them.
-
-The first thing we’ll do is isolate our experiment in a repository of its own. We use the “hg clone” command, but we don’t need to clone a copy of the remote repository. Since we already have a copy of it locally, we can just clone that instead. This is much faster than cloning over the network, and cloning a local repository uses less disk space in most cases, too.
-
-1 $ cd ..
-2 $ hg clone hello my-hello
-3 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
-4 $ cd my-hello
-
-As an aside, it’s often good practice to keep a “pristine” copy of a remote repository around, which you can then make temporary clones of to create sandboxes for each task you want to work on. This lets you work on multiple tasks in parallel, each isolated from the others until it’s complete and you’re ready to integrate it back. Because local clones are so cheap, there’s almost no overhead to cloning and destroying repositories whenever you want.
-
-In our my-hello repository, we have a file hello.c that contains the classic “hello, world” program. Let’s use the ancient and venerable sed command to edit this file so that it prints a second line of output. (I’m only using sed to do this because it’s easy to write a scripted example this way. Since you’re not under the same constraint, you probably won’t want to use sed; simply use your preferred text editor to do the same thing.)
-
-1 $ sed -i '/printf/a∖∖tprintf("hello again!∖∖n");' hello.c
-
-Mercurial’s “hg status” command will tell us what Mercurial knows about the files in the repository.
-
-1 $ ls
-2 Makefile hello.c
-3 $ hg status
-4 M hello.c
-
-The “hg status” command prints no output for some files, but a line starting with “M” for hello.c. Unless you tell it to, “hg status” will not print any output for files that have not been modified.
-
-The “M” indicates that Mercurial has noticed that we modified hello.c. We didn’t need to inform Mercurial that we were going to modify the file before we started, or that we had modified the file after we were done; it was able to figure this out itself.
-
-It’s a little bit helpful to know that we’ve modified hello.c, but we might prefer to know exactly what changes we’ve made to it. To do this, we use the “hg diff” command.
-
-1 $ hg diff
-2 diff -r b57f9a090b62 hello.c
-3 --- a/hello.c Tue Sep 06 15:43:07 2005 -0700
-4 +++ b/hello.c Sun Jun 17 18:05:50 2007 +0000
-5 @@ -8,5 +8,6 @@ int main(int argc, char ⋆⋆argv)
-6 int main(int argc, char ⋆⋆argv)
-7 {
-8 printf("hello, world!∖");
-9 + printf("hello again!∖n");
-10 return 0;
-11 }
+Now that we have a grasp of viewing history in Mercurial, let’s take a
+look at making some changes and examining them.
+
+The first thing we’ll do is isolate our experiment in a repository of
+its own. We use the “hg clone” command, but we don’t need to clone a
+copy of the remote repository. Since we already have a copy of it
+locally, we can just clone that instead. This is much faster than
+cloning over the network, and cloning a local repository uses less
+disk space in most cases, too.
+
+ $ cd ..
+ $ hg clone hello my-hello
+ 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
+ $ cd my-hello
+
+As an aside, it’s often good practice to keep a “pristine” copy of a
+remote repository around, which you can then make temporary clones of
+to create sandboxes for each task you want to work on. This lets you
+work on multiple tasks in parallel, each isolated from the others
+until it’s complete and you’re ready to integrate it back. Because
+local clones are so cheap, there’s almost no overhead to cloning and
+destroying repositories whenever you want.
+
+In our my-hello repository, we have a file hello.c that contains the
+classic “hello, world” program. Let’s use the ancient and venerable
+sed command to edit this file so that it prints a second line of
+output. (I’m only using sed to do this because it’s easy to write a
+scripted example this way. Since you’re not under the same constraint,
+you probably won’t want to use sed; simply use your preferred text
+editor to do the same thing.)
+
+ $ sed -i '/printf/a∖∖tprintf("hello again!∖∖n");' hello.c
+
+Mercurial’s “hg status” command will tell us what Mercurial knows
+about the files in the repository.
+
+ $ ls
+ Makefile hello.c
+ $ hg status
+ M hello.c
+
+The “hg status” command prints no output for some files, but a line
+starting with “M” for hello.c. Unless you tell it to, “hg status” will
+not print any output for files that have not been modified.
+
+The “M” indicates that Mercurial has noticed that we modified
+hello.c. We didn’t need to inform Mercurial that we were going to
+modify the file before we started, or that we had modified the file
+after we were done; it was able to figure this out itself.
+
+It’s a little bit helpful to know that we’ve modified hello.c, but we
+might prefer to know exactly what changes we’ve made to it. To do
+this, we use the “hg diff” command.
+
+ $ hg diff
+ diff -r b57f9a090b62 hello.c
+ --- a/hello.c Tue Sep 06 15:43:07 2005 -0700
+ +++ b/hello.c Sun Jun 17 18:05:50 2007 +0000
+ @@ -8,5 +8,6 @@ int main(int argc, char ⋆⋆argv)
+ int main(int argc, char ⋆⋆argv)
+ {
+ printf("hello, world!∖");
+ + printf("hello again!∖n");
+ return 0;
+ }