rhg: refactor relative path resolution in utility fn

The same code is being used in `rhg files` and `rhg status` and I expect it to
be used at more places in upcoming future. So let's have a utility function for
that.

`rhg files` still doesn't use this codepath but will start using in upcoming
patches.
15 jobs for topic/default/rhg-review-ready in 28 minutes and 20 seconds (queued for 5 seconds)
Status Job ID Name Coverage
  Tests
manual check-pytype-py3 #210594
allowed to fail manual
passed checks-py2 #210581

00:02:33

passed checks-py3 #210582

00:03:34

passed rust-cargo-test-py2 #210583

00:02:02

passed rust-cargo-test-py3 #210584

00:02:00

passed test-py2 #210585

00:23:11

passed test-py2-chg #210592

00:26:00

passed test-py2-pure #210587

00:22:54

passed test-py2-rust #210589

00:27:58

passed test-py3 #210586

00:13:43

passed test-py3-chg #210593

00:08:09

passed test-py3-pure #210588

00:14:59

passed test-py3-rhg #210591

00:16:43

passed test-py3-rust #210590

00:16:04

 
  Phabricator
failed phabricator-refresh #210595

00:00:21

 
Name Stage Failure
failed
phabricator-refresh Phabricator

Changeset 5e6e4e9ead61e8fe3a298f68362dc8f790f43a46 is present
Updating to 5e6e4e9ead61e
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
Executing "step_script" stage of the job script
$ if [ `hg branch` == "stable" ]; then # collapsed multi-line command
not all stack changesets (5) have matching Phabricator Diff (4)
Cleaning up file based variables
ERROR: Job failed: exit code 1