Patchwork [STABLE] convert: restore the ability to use bzr < 2.6.0 (issue5733)

login
register
mail settings
Submitter Matt Harbison
Date Dec. 2, 2017, 6:59 a.m.
Message ID <dedc5dbc155dcd1c1420.1512197996@Envy>
Download mbox | patch
Permalink /patch/25890/
State Accepted
Headers show

Comments

Matt Harbison - Dec. 2, 2017, 6:59 a.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@yahoo.com>
# Date 1512188828 18000
#      Fri Dec 01 23:27:08 2017 -0500
# Branch stable
# Node ID dedc5dbc155dcd1c142059c4896a9a5cf3e1e350
# Parent  fff9ffa2ea05c3b661aa769644454b27266ab940
convert: restore the ability to use bzr < 2.6.0 (issue5733)

This effectively conditionalizes a234b32b744a.  Some Linux distributions (like
CentOS 7) use really old versions, and the change referenced was causing
exceptions to be thrown.

Even though the deprecation warning says 'since 2.5.0', it wasn't marked as such
in 2.5.1, but is by 2.6.0.  This was tested with 2.4.2 and 2.6.0 with
PYTHONWARNINGS=::DeprecationWarning, and both paths were exercized.
Yuya Nishihara - Dec. 3, 2017, 6:31 a.m.
On Sat, 02 Dec 2017 01:59:56 -0500, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_harbison@yahoo.com>
> # Date 1512188828 18000
> #      Fri Dec 01 23:27:08 2017 -0500
> # Branch stable
> # Node ID dedc5dbc155dcd1c142059c4896a9a5cf3e1e350
> # Parent  fff9ffa2ea05c3b661aa769644454b27266ab940
> convert: restore the ability to use bzr < 2.6.0 (issue5733)

Queued for stable, thanks.

Patch

diff --git a/hgext/convert/bzr.py b/hgext/convert/bzr.py
--- a/hgext/convert/bzr.py
+++ b/hgext/convert/bzr.py
@@ -205,6 +205,13 @@ 
         changes = []
         renames = {}
         seen = set()
+
+        # Fall back to the deprecated attribute for legacy installations.
+        try:
+            inventory = origin.root_inventory
+        except AttributeError:
+            inventory = origin.inventory
+
         # Process the entries by reverse lexicographic name order to
         # handle nested renames correctly, most specific first.
         curchanges = sorted(current.iter_changes(origin),
@@ -229,10 +236,9 @@ 
                     renaming = paths[0] != paths[1]
                     # neither an add nor an delete - a move
                     # rename all directory contents manually
-                    subdir = origin.root_inventory.path2id(paths[0])
+                    subdir = inventory.path2id(paths[0])
                     # get all child-entries of the directory
-                    for name, entry in origin.root_inventory.iter_entries(
-                            subdir):
+                    for name, entry in inventory.iter_entries(subdir):
                         # hg does not track directory renames
                         if entry.kind == 'directory':
                             continue