Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Respect filemap rule order (rules that come first are overridden by rules that come later)
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Vitaliy Filippov  
View profile  
 More options Jan 27 2012, 5:25 pm
From: Vitaliy Filippov <vita...@yourcmc.ru>
Date: Sat, 28 Jan 2012 02:25:33 +0400
Local: Fri, Jan 27 2012 5:25 pm
Subject: [PATCH 2 of 2] Respect filemap rule order (rules that come first are overridden by rules that come later)
# HG changeset patch
# User Vitaliy Filippov <vita...@yourcmc.ru>
# Date 1327702705 -14400
# Node ID 480e204d11897bafd702834e5de15ddfe2f193f0
# Parent  49fc56d26ecee40a50619bbbb4498d4fd6010394
Respect filemap rule order (rules that come first are overridden by rules that come later)

diff -r 49fc56d26ece -r 480e204d1189 hgsubversion/maps.py
--- a/hgsubversion/maps.py      Fri Jan 20 19:06:32 2012 +0400
+++ b/hgsubversion/maps.py      Sat Jan 28 02:18:25 2012 +0400
@@ -272,32 +272,34 @@
             self._write()

     def _rpairs(self, name):
-        yield '.', name
         e = len(name)
         while e != -1:
             yield name[:e], name[e+1:]
             e = name.rfind('/', 0, e)
+        yield '.', name

     def check(self, m, path):
         m = getattr(self, m)
         for pre, _suf in self._rpairs(path):
-            if pre not in m:
-                continue
-            return m[pre]
-        return None
+            if pre in m:
+                return m[pre]
+        return -1

     def __contains__(self, path):
-        if len(self.include) and len(path):
+        if not len(path):
+            return True
+        if len(self.include):
             inc = self.check('include', path)
+        elif not len(self.exclude):
+            return True
         else:
-            inc = path
-        if len(self.exclude) and len(path):
+            inc = 0
+        if len(self.exclude):
             exc = self.check('exclude', path)
         else:
-            exc = None
-        if inc is None or exc is not None:
-            return False
-        return True
+            exc = -1
+        # respect rule order: newer rules override older
+        return inc > exc

     # Needed so empty filemaps are false
     def __len__(self):
@@ -311,7 +313,8 @@
             return
         bits = m.strip('e'), path
         self.ui.debug('%sing %s\n' % bits)
-        mapping[path] = path
+        # respect rule order
+        mapping[path] = len(self)
         if fn != self.path:
             f = open(self.path, 'a')
             f.write(m + ' ' + path + '\n')
diff -r 49fc56d26ece -r 480e204d1189 tests/test_fetch_mappings.py
--- a/tests/test_fetch_mappings.py      Fri Jan 20 19:06:32 2012 +0400
+++ b/tests/test_fetch_mappings.py      Sat Jan 28 02:18:25 2012 +0400
@@ -131,6 +131,19 @@
         # TODO: re-enable test if we ever reinstate this feature
         self.assertRaises(hgutil.Abort, self.test_file_map_exclude, True)

+    def test_file_map_rule_order(self):
+        test_util.load_svndump_fixture(self.repo_path, 'replace_trunk_with_branch.svndump')
+        filemap = open(self.filemap, 'w')
+        filemap.write("exclude alpha\n")
+        filemap.write("include .\n")
+        filemap.close()
+        ui = self.ui(False)
+        ui.setconfig('hgsubversion', 'filemap', self.filemap)
+        commands.clone(ui, test_util.fileurl(self.repo_path),
+                       self.wc_path, filemap=self.filemap)
+        self.assertEqual(node.hex(self.repo[0].node()), '2cd09772e0f6ddf2d13c60ef3c1be11ad5a7dfae')
+        self.assertEqual(node.hex(self.repo['default'].node()), '8a525ca0671f456e6b1417187bf86c6115d2cb78')
+
     def test_branchmap(self, stupid=False):
         test_util.load_svndump_fixture(self.repo_path, 'branchmap.svndump')
         branchmap = open(self.branchmap, 'w')


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Discussion subject changed to "Filemap patches (rule order patch fixed, test added)" by Vitaliy Filippov
Vitaliy Filippov  
View profile  
 More options Jan 27 2012, 5:25 pm
From: Vitaliy Filippov <vita...@yourcmc.ru>
Date: Sat, 28 Jan 2012 02:25:31 +0400
Local: Fri, Jan 27 2012 5:25 pm
Subject: [PATCH 0 of 2] Filemap patches (rule order patch fixed, test added)
This is a new version of my filemap patches; the first one is unchanged and the second one doesn't change the behaviour when only 'include' rules are present anymore. Additionally, I added a test for rule order patch.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Discussion subject changed to "Save filemap into .hg/svn/filemap just like other maps" by Vitaliy Filippov
Vitaliy Filippov  
View profile  
 More options Jan 27 2012, 5:25 pm
From: Vitaliy Filippov <vita...@yourcmc.ru>
Date: Sat, 28 Jan 2012 02:25:32 +0400
Local: Fri, Jan 27 2012 5:25 pm
Subject: [PATCH 1 of 2] Save filemap into .hg/svn/filemap just like other maps
# HG changeset patch
# User Vitaliy Filippov <vita...@yourcmc.ru>
# Date 1327071992 -14400
# Node ID 49fc56d26ecee40a50619bbbb4498d4fd6010394
# Parent  6c4d15d8cfbda880bf5e41cd408d49f8529f97d2
Save filemap into .hg/svn/filemap just like other maps

diff -r 6c4d15d8cfbd -r 49fc56d26ece hgsubversion/maps.py
--- a/hgsubversion/maps.py      Fri Oct 21 16:42:10 2011 -0500
+++ b/hgsubversion/maps.py      Fri Jan 20 19:06:32 2012 +0400
@@ -21,7 +21,7 @@
         The ui argument is used to print diagnostic messages.

         The path argument is the location of the backing store,
-        typically .hg/authormap.
+        typically .hg/svn/authors.
         '''
         self.ui = ui
         self.path = path
@@ -252,13 +252,24 @@

 class FileMap(object):

-    def __init__(self, repo):
-        self.ui = repo.ui
+    VERSION = 1
+
+    def __init__(self, ui, path):
+        '''Initialise a new FileMap.
+
+        The ui argument is used to print diagnostic messages.
+
+        The path argument is the location of the backing store,
+        typically .hg/svn/filemap.
+        '''
+        self.ui = ui
+        self.path = path
         self.include = {}
         self.exclude = {}
-        filemap = repo.ui.config('hgsubversion', 'filemap')
-        if filemap and os.path.exists(filemap):
-            self.load(filemap)
+        if os.path.isfile(self.path):
+            self._load()
+        else:
+            self._write()

     def _rpairs(self, name):
         yield '.', name
@@ -301,10 +312,18 @@
         bits = m.strip('e'), path
         self.ui.debug('%sing %s\n' % bits)
         mapping[path] = path
+        if fn != self.path:
+            f = open(self.path, 'a')
+            f.write(m + ' ' + path + '\n')
+            f.close()

     def load(self, fn):
         self.ui.note('reading file map from %s\n' % fn)
         f = open(fn, 'r')
+        self.load_fd(f, fn)
+        f.close()
+
+    def load_fd(self, f, fn):
         for line in f:
             if line.strip() == '' or line.strip()[0] == '#':
                 continue
@@ -319,6 +338,20 @@
             except IndexError:
                 msg = 'ignoring bad line in filemap %s: %s\n'
                 self.ui.warn(msg % (fn, line.rstrip()))
+
+    def _load(self):
+        self.ui.note('reading in-repo file map from %s\n' % self.path)
+        f = open(self.path)
+        ver = int(f.readline())
+        if ver != self.VERSION:
+            print 'filemap too new -- please upgrade'
+            raise NotImplementedError
+        self.load_fd(f, self.path)
+        f.close()
+
+    def _write(self):
+        f = open(self.path, 'w')
+        f.write('%s\n' % self.VERSION)
         f.close()

 class BranchMap(dict):
diff -r 6c4d15d8cfbd -r 49fc56d26ece hgsubversion/svnmeta.py
--- a/hgsubversion/svnmeta.py   Fri Oct 21 16:42:10 2011 -0500
+++ b/hgsubversion/svnmeta.py   Fri Jan 20 19:06:32 2012 +0400
@@ -55,6 +55,7 @@
                                                  'usebranchnames', True)
         branchmap = self.ui.config('hgsubversion', 'branchmap')
         tagmap = self.ui.config('hgsubversion', 'tagmap')
+        filemap = self.ui.config('hgsubversion', 'filemap')

         self.branches = {}
         if os.path.exists(self.branch_info_file):
@@ -94,8 +95,11 @@
         if tagmap:
             self.tagmap.load(tagmap)

+        self.filemap = maps.FileMap(self.ui, self.filemap_file)
+        if filemap:
+            self.filemap.load(filemap)
+
         self.lastdate = '1970-01-01 00:00:00 -0000'
-        self.filemap = maps.FileMap(repo)
         self.addedtags = {}
         self.deletedtags = {}

@@ -192,6 +196,10 @@
         return os.path.join(self.meta_data_dir, 'authors')

     @property
+    def filemap_file(self):
+        return os.path.join(self.meta_data_dir, 'filemap')
+
+    @property
     def branchmapfile(self):
         return os.path.join(self.meta_data_dir, 'branchmap')


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Discussion subject changed to "Respect filemap rule order (rules that come first are overridden by rules that come later)" by Augie Fackler
Augie Fackler  
View profile  
 More options Jan 31 2012, 9:10 am
From: Augie Fackler <duri...@gmail.com>
Date: Tue, 31 Jan 2012 08:10:41 -0600
Local: Tues, Jan 31 2012 9:10 am
Subject: Re: [PATCH 2 of 2] Respect filemap rule order (rules that come first are overridden by rules that come later)

On Jan 27, 2012, at 4:25 PM, Vitaliy Filippov wrote:

Queued both of these, though for future reference we're trying to make new tests examine particular attributes of commits rather than just asserting the hash is a particular value, as changes to the metadata stored by Mercurial can cause these to change over time without the content being meaningfully different.

Thanks!


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »