简体   繁体   中英

How do I merge changes in Mercurial

I have used hg clone to get a working copy of a project on a local folder

hg clone http://example.com/prj

I want to modify some files to meet my needs. For example an original file looks like:

int main() {
   cout << "hello";
   return 0;
}

So I change that like this:

int main() {
   int a = 0;
   cout << "hello";
   return 0;
}

Later the main repository changes and looks like this (compare to the first snippet):

int main() {
   for (int i=0; i<10; i++ )
      cout << "hello";
   return 0;
}

Now when I run

hg pull
hg update

my change int a=0; is lost.

For a crash course of how distributed SCM's work, and moreover HOW to use them please read either

Or:

Actually, this does not happen, if you remember to hg commit after you make the change. You will just have a repository with 2 heads, that you would need to hg merge eg:

$ hg pull
pulling from /tmp/remote
searching for changes
adding changesets
adding manifests
adding file changes
added 1 changesets with 1 changes to 1 files (+1 heads)
(run 'hg heads' to see heads, 'hg merge' to merge)
$ hg merge
  int main() {            |  int main() {            |  int main() {
      int a = 0;          |      for (int i=0; i<10 ;|      cout << "hello";    
      cout << "hello";    |          cout << "hello";|  ------------------------
      return 0;           |      return 0;           |      return 0;
  }                       |  }                       |  }

To learn how to use mercurial, please read the online book

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM