Commits

David Schleimer  committed e95f4de

layouts: refactor buildmeta layout reading and writing

  • Participants
  • Parent commits 7a3b938

Comments (0)

Files changed (2)

File hgsubversion/layouts/detect.py

         if ui:
             ui.setconfig('hgsubversion', 'layout', layout)
     return layout
+
+def layout_from_commit(subdir, revpath):
+    """ Guess what the layout is based existing commit info
+
+    Specifically, this compares the subdir for the repository and the
+    revpath as extracted from the convinfo in the commit.
+
+    """
+
+    if (subdir or '/') == revpath:
+        layout = 'single'
+    else:
+        layout = 'standard'
+
+    return layout

File hgsubversion/svncommands.py

 from mercurial import util as hgutil
 from mercurial import error
 
+import layouts
 import maps
 import svnwrap
 import svnrepo
                                             'right location in the repo.')
 
         if layout is None:
-            if (subdir or '/') == revpath:
-                layout = 'single'
-            else:
-                layout = 'standard'
-            write_if_needed(os.path.join(svnmetadir, 'layout'), layout)
+            layout = layouts.detect.layout_from_commit(subdir, revpath)
+            existing_layout = layouts.detect.layout_from_file(svnmetadir)
+            if layout != existing_layout:
+                layouts.persist.layout_to_file(svnmetadir, layout)
         elif layout == 'single':
             assert (subdir or '/') == revpath, ('Possible layout detection'
                                                 ' defect in replay')