Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

using hg revert to revert a group of files in Mercurial

I'm using Mercurial to read and debug a complex project, and my modify of the project can be divided into different group of files clearly. For example, if I modified four files

src1.cc src1.hh src2.cc src2.hh

It's apparent that I can divide them into two file groups such as group src1 includes src1.cc src1.hh and group src2 includes src2.cc src2.hh.

I'm wondering if I can revert a group of files by a simple command like 'hg revert group-name-alias' instead of listing all the filename of the group, which is a awful idea if I have modified many files?

Any help really appreciated!

like image 685
zhengchl Avatar asked Mar 27 '12 03:03

zhengchl


1 Answers

From what I can understand of your use-case, you can:

  1. Use patterns in the hg revert command. This means that you can run hg revert src1* to revert all the first group.

    Most probably, though, your stuff is in sub-folders and thankfully you can specify a parent folder to the revert command.

    So say your files are really like: foo/src1.cc, foo/src1.hh, bar/src2.cc, bar/src2.hh. In that case, you can revert all the second group with hg revert bar, assuming you're in the top folder. If you're already in the bar folder, you can run hg revert ..

    You can specify several patterns.

  2. Use Mercurial queues if each one of your "file groups" is also a different unit of work (a different bug fix or feature). This is not so desirable if all files belong to the same unit of work, though.

like image 199
Ludovic Chabant Avatar answered Sep 22 '22 11:09

Ludovic Chabant