After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 573049 - Factorize repository root finding code
Factorize repository root finding code
Status: RESOLVED FIXED
Product: meld
Classification: Other
Component: version
git master
Other Linux
: Normal enhancement
: ---
Assigned To: Vincent Legoll
Stephen Kennedy
Depends on:
Blocks:
 
 
Reported: 2009-02-25 00:46 UTC by Vincent Legoll
Modified: 2009-03-01 23:41 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
factorize it (5.87 KB, patch)
2009-02-25 00:54 UTC, Vincent Legoll
none Details | Review
factorize it (fixed) (5.83 KB, patch)
2009-02-26 20:20 UTC, Vincent Legoll
none Details | Review

Description Vincent Legoll 2009-02-25 00:46:31 UTC
There's code duplication in vc plugins.

The code that tries to find the repository root is duplicated in a lot of files and is almost always identical.

The attached patch tries to consolidate this into a single implementation in _vc.py

The patch should be a no-op
Please review

Tested with git+hg (dual repository) and svn

The diffstat is nice:

 _vc.py       |   13 +++++++++++++
 bzr.py       |    8 ++------
 darcs.py     |    8 ++------
 git.py       |   19 +++++++++----------
 mercurial.py |    9 +--------
 monotone.py  |   11 ++---------
 tla.py       |    8 ++------
 7 files changed, 31 insertions(+), 45 deletions(-)

CVS & svn not touched as they didn't have the same code cut'n'pasted
Comment 1 Vincent Legoll 2009-02-25 00:54:25 UTC
Created attachment 129447 [details] [review]
factorize it
Comment 2 Vincent Legoll 2009-02-26 20:20:54 UTC
Created attachment 129601 [details] [review]
factorize it (fixed)

This one fix a bug in vc/git.py constructor, _tree_cache was not initialized properly
Comment 3 Kai Willadsen 2009-02-28 13:06:03 UTC
Bug #556404 contains a large patch which, among other things, factorises out the repository root finding and also makes the root finding work on windows (see the find_vcs_root function). It would probably make sense to apply that part of the windows patch separately, but I'm not really familiar enough with the VC-related code to be sure that it's all correct. Maybe you could try and cherry-pick the useful parts of the windows patch (attachment #127707 [details]) into your patch here?
Comment 4 Vincent Legoll 2009-03-01 22:41:38 UTC
When reading your comment I told myself that I've seen code in anyvc that would be even better than mine. Then I read #127707, and saw something very similar to what's in anyvc (no hard coded '/' search)

So I think this is all good, I'll extract the relevant bits from #127707, and apply them after my factorization, as follow-ups, as some of those hunks would change behavior (something that I tried to avoid, when factorizing)
Comment 5 Vincent Legoll 2009-03-01 23:41:08 UTC
Committed as #1189 to #1192

- Factorization (noop)
- Make cvs & svn OS-independant
- detect cvs & svn repo by their directories, avoid files named .svn or CVS
- Make find_repo_root() OS-independant

Parts of this are taken from patch #127707 of bug #556404