nikhilm / cq

Cq ( Commit Queue ) is a tool to work offline on a Mercurial clone of a Subversion working copy. All changes done in the local Mercurial repository can be pushed to the Subversion repository when the network is available. Cq is in a very early stage, see DESIGN ( incomplete ) for details

Clone this repository (size: 70.1 KB): HTTPS / SSH
$ hg clone http://bitbucket.org/nikhilm/cq/
commit 95: 193eda2760d5
parent 94: a50b3a37336a
branch: default
tags: tip
Added custom ignore function to sync.hg_with_svn to reject files not checked into Subversion
Nikhil Marathe / nikhilm
8 months ago

Changed (Δ756 bytes):

raw changeset »

src/cq/sync.py (23 lines added, 2 lines removed)

Up to file-list src/cq/sync.py:

1
1
# handle file copying, patching diffs, renames
2
2
# anything involving keeping the swc in sync with hgr
3
3
4
import shutil, os
4
import shutil, os, subprocess
5
5
6
6
from cq import repo, util
7
7
@@ -28,4 +28,25 @@ def add( files ):
28
28
        shutil.copy(src, dst)
29
29
30
30
def hg_with_svn(svn, hgr):
31
    shutil.copytree(svn, hgr, ignore=shutil.ignore_patterns('.cq', '.svn'))
31
32
    def my_ignore(dir, fns):
33
        sysignore = shutil.ignore_patterns('.cq', '.svn')
34
        ignore = sysignore(dir, fns)
35
36
        # this ignore function is a kind of dirty hack.
37
        # The problem is that svn list requires access
38
        # to the repository
39
        # instead we check if subversion has info
40
        # about the file. If it does, it is in version control
41
        # svn returns exit code 0
42
        # otherwise it returns 1
43
        # ignore all files with return 1
44
        for fn in fns:
45
            # pipe the file descriptors to silence output
46
            if subprocess.call(['svn', 'info', os.path.join( dir, fn )],
47
                    stderr=subprocess.PIPE, stdout=subprocess.PIPE ) == 1:
48
                ignore.add( fn )
49
50
        return ignore
51
52
    shutil.copytree(svn, hgr, ignore=my_ignore)