diff --git a/hgext3rd/dirsync.py b/hgext3rd/dirsync.py --- a/hgext3rd/dirsync.py +++ b/hgext3rd/dirsync.py @@ -5,13 +5,14 @@ # This software may be used and distributed according to the terms of the # GNU General Public License version 2 or any later version. """ -dirsync is an extension for keeping directories in a repo synchronized. - -Configure it by adding the following config options to your .hg/hgrc. +keep directories in a repo synchronized (DEPRECATED) -[dirsync] -projectX.dir1 = path/to/dir1 -projectX.dir2 = path/dir2 +Configure it by adding the following config options to your .hg/hgrc or +.hgdirsync in the root of the repo:: + + [dirsync] + projectX.dir1 = path/to/dir1 + projectX.dir2 = path/dir2 The configs are of the form "group.name = path-to-dir". Every config entry with the same `group` will be mirrored amongst each other. The `name` is just used to @@ -20,19 +21,18 @@ the trailing '/' or not. Multiple mirror groups can be specified at once, and you can mirror between an -arbitrary number of directories. Ex: +arbitrary number of directories:: -[dirsync] -projectX.dir1 = path/to/dir1 -projectX.dir2 = path/dir2 -projectY.dir1 = otherpath/dir1 -projectY.dir2 = foo/bar -projectY.dir3 = foo/goo/hoo + [dirsync] + projectX.dir1 = path/to/dir1 + projectX.dir2 = path/dir2 + projectY.dir1 = otherpath/dir1 + projectY.dir2 = foo/bar + projectY.dir3 = foo/goo/hoo """ from __future__ import absolute_import -from collections import defaultdict import errno from mercurial import ( cmdutil, @@ -81,7 +81,7 @@ if content: ui._tcfg.parse(filename, '[dirsync]\n%s' % content, ['dirsync']) - maps = defaultdict(list) + maps = util.sortdict() for key, value in ui.configitems('dirsync'): if '.' not in key: continue @@ -89,6 +89,8 @@ # Normalize paths to have / at the end. For easy concatenation later. if value[-1] != '/': value = value + '/' + if name not in maps: + maps[name] = [] maps[name].append(value) return maps diff --git a/tests/test-dirsync.t b/tests/test-dirsync.t --- a/tests/test-dirsync.t +++ b/tests/test-dirsync.t @@ -675,3 +675,33 @@ mirrored changes in 'dir1/c' to 'dir7/c' $ cd ../.. + +Rule order matters. Only the first one gets executed. + + $ hg init $TESTTMP/repo-order1 + $ cd $TESTTMP/repo-order1 + $ cat >> .hgdirsync <<'EOF' + > a.dir1 = a/ + > a.dir2 = b/ + > c.dir1 = a/c/ + > c.dir2 = c/ + > EOF + $ mkdir -p a/c + $ echo 1 > a/c/1 + $ hg commit -m 'order test' -A a + adding a/c/1 + mirrored adding 'a/c/1' to 'b/c/1' + + $ hg init $TESTTMP/repo-order2 + $ cd $TESTTMP/repo-order2 + $ cat >> .hgdirsync <<'EOF' + > c.dir1 = a/c/ + > c.dir2 = c/ + > a.dir1 = a/ + > a.dir2 = b/ + > EOF + $ mkdir -p a/c + $ echo 1 > a/c/1 + $ hg commit -m 'order test' -A a + adding a/c/1 + mirrored adding 'a/c/1' to 'c/1'