vcssync: eliminate shamap_path variable (bug 1357597); r?glob draft
authorGregory Szorc <gps@mozilla.com>
Tue, 18 Apr 2017 17:03:33 -0700
changeset 10852 a40ca8daccdb7b2433148fc587f31e1d0bdf899c
parent 10851 2b7cff910a8220c78a3a7e174470828809315d18
child 10853 40aaed94c3c84b701fdc8c9a16540e5163324f2b
push id1638
push userbmo:gps@mozilla.com
push dateSat, 22 Apr 2017 00:35:48 +0000
reviewersglob
bugs1357597
vcssync: eliminate shamap_path variable (bug 1357597); r?glob The value is redundant with rev_map and not necessary. Given the state of mind I was in when I wrote this code (I was rushing to get this feature deployed), I'm not surprised this slipped through. MozReview-Commit-ID: 98Sbs4aDU1o
vcssync/mozvcssync/git2hg.py
--- a/vcssync/mozvcssync/git2hg.py
+++ b/vcssync/mozvcssync/git2hg.py
@@ -248,22 +248,21 @@ def linearize_git_repo_to_hg(git_source_
     if not os.path.exists(hg_repo_path):
         hglib.init(hg_repo_path)
 
     with hglib.open(hg_repo_path) as hrepo:
         tip = hrepo[b'tip']
         before_hg_tip_rev = tip.rev()
         before_hg_tip_node = tip.node()
 
-    shamap_path = os.path.join(hg_repo_path, b'.hg', b'shamap')
     def get_shamap_hash():
-        if not os.path.exists(shamap_path):
+        if not os.path.exists(rev_map):
             return None
 
-        with open(shamap_path, 'rb') as fh:
+        with open(rev_map, 'rb') as fh:
             return hashlib.sha256(fh.read()).digest()
 
     old_shamap_hash = get_shamap_hash()
 
     run_hg_convert(git_repo_path, hg_repo_path, rev_map,
                    rev=b'refs/convert/dest/heads/%s' % ref,
                    similarity=similarity,
                    find_copies_harder=find_copies_harder,
@@ -291,12 +290,12 @@ def linearize_git_repo_to_hg(git_source_
         convert_count, before_hg_tip_rev, before_hg_tip_node,
         after_hg_tip_rev, after_hg_tip_node))
 
     maybe_push_hg()
 
     # TODO so hacky. Relies on credentials in the environment.
     if shamap_s3_upload_url and old_shamap_hash != get_shamap_hash():
         subprocess.check_call([
-            b'aws', b's3', b'cp', shamap_path, shamap_s3_upload_url
+            b'aws', b's3', b'cp', rev_map, shamap_s3_upload_url
         ])
 
     return result