How do I find a package that provides a given file in OpenSuSE?

To search from all available packages to find a particular file, you can use the option wp or se --provides --match-exact as an example:

zypper se --provides --match-exact hg

You will see output similiar to the following:

Loading repository data...
Reading installed packages...

S | Name      | Summary                  | Type   
--+-----------+--------------------------+--------
  | mercurial | Scalable Distributed SCM | package

From that point you can install the package through a standard zypper install

zypper in mercurial

It should be noted that zypper wp is obsolete and may no longer be available.


To the googlers of the future: next to @SailorCire 's wonderful solution :-), there is also a tool named scout, which is able to search in practically everything, we can find rpm-s for a binary just as we can find the jars for a given java class.

For example, we can use scout's bin command to find out what package provides the hg executable:

scout bin hg

The result of this search is the mercurial package:

 repository      | package   | path     | binary
-----------------+-----------+----------+--------
 zypp (repo-oss) | mercurial | /usr/bin | hg