B. The attorney for the Commonwealth and assistant attorney for the Commonwealth shall be a part of the department of law enforcement of the county or city in which he is elected or appointed, and shall have the duties and powers imposed upon him by general law, including the duty of prosecuting all warrants, indictments or informations charging a felony, and he may in his discretion, prosecute Class 1, 2 and 3 misdemeanors, or any other violation, the conviction of which carries a penalty of confinement in jail, or a fine of $500 or more, or both such confinement and fine. He shall enforce all forfeitures, and carry out all duties imposed upon him by § 2.2-3126. He may enforce the provisions of § 18.2-268.3, 29.1-738.2, 46.2-341.20:7, or 46.2-341.26:3. He may, in his discretion, file a petition for appeal pursuant to Chapter 25 (§ 19.2-398 et seq.) of Title 19.2 and he shall continue to represent the Commonwealth in any such appeal before the Court of Appeals or the Supreme Court for which he was the prosecuting attorney, unless and until the Court of Appeals grants the petition, except that he shall remain counsel of record in an appeal regarding bail, bond, or recognizance pursuant to Article 1 (§ 19.2-119 et seq.) of Chapter 9 of Title 19.2 or subsection B of § 19.2-398. He shall also represent the Commonwealth in an appeal of a civil matter related to the enforcement of a criminal law or a criminal case for which he was the prosecuting attorney, including a petition for expungement of a defendant's criminal record, an action of forfeiture filed in accordance with the provisions of Chapter 22.1 (§ 19.2-386.1 et seq.) of Title 19.2, or any matter which he may enforce pursuant to this section.