# HG changeset patch # User Pulkit Goyal <7895pulkit@gmail.com> # Date 1612116511 -19800 # Node ID 835aafb2543f8354382e95b931d532595e96017f # Parent 83f037acf71a8773c88a597c7ea35cb572147d7e revlog: refactor logic to compute nodemap file in separate function I will like to use it one more place. Differential Revision: https://phab.mercurial-scm.org/D9933 diff -r 83f037acf71a -r 835aafb2543f mercurial/revlog.py --- a/mercurial/revlog.py Sun Jan 31 23:34:59 2021 +0530 +++ b/mercurial/revlog.py Sun Jan 31 23:38:31 2021 +0530 @@ -448,14 +448,9 @@ self.datafile = datafile or (indexfile[:-2] + b".d") self.nodemap_file = None if persistentnodemap: - if indexfile.endswith(b'.a'): - pending_path = indexfile[:-4] + b".n.a" - if opener.exists(pending_path): - self.nodemap_file = pending_path - else: - self.nodemap_file = indexfile[:-4] + b".n" - else: - self.nodemap_file = indexfile[:-2] + b".n" + self.nodemap_file = nodemaputil.get_nodemap_file( + opener, self.indexfile + ) self.opener = opener # When True, indexfile is opened with checkambig=True at writing, to diff -r 83f037acf71a -r 835aafb2543f mercurial/revlogutils/nodemap.py --- a/mercurial/revlogutils/nodemap.py Sun Jan 31 23:34:59 2021 +0530 +++ b/mercurial/revlogutils/nodemap.py Sun Jan 31 23:38:31 2021 +0530 @@ -634,3 +634,14 @@ if isinstance(entry, dict): return _find_node(entry, node[1:]) return entry + + +def get_nodemap_file(opener, indexfile): + if indexfile.endswith(b'.a'): + pending_path = indexfile[:-4] + b".n.a" + if opener.exists(pending_path): + return pending_path + else: + return indexfile[:-4] + b".n" + else: + return indexfile[:-2] + b".n"