1

Currently I have a code repository which is not well documented, called ''A'', in a remote server.
I have a local clone of it, called ''B''.

I want to accompany the following two things:

  1. add Doxygen-style comments to ''B'' to generate documents.
  2. push changesets to ''A'' without these comments in ''B''.

What is the best way to set up repo/branches to achieve this?

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
user103500
  • 77
  • 1
  • 8
  • I see that the git and svn tags were added in an edit. If you specifically are asking for how to achieve this in mercurial, I suggest you specify that in your question and remove the svn and git tags – Sigve Kolbeinson Jul 07 '16 at 12:05

1 Answers1

1

You could setup a second branch in B which:

  • can be used to merge the main branch of B where those Doxygen-style comment are added (so: merge from main branch to second branch)
  • but has a config activating a smudge content filter driver, with smudge being a script removing all Doxygen comments (that is, if those comments are easy to parse and detect)

smudge (image from "Customizing Git - Git Attributes", from "Pro Git book")

That involves a .gitattributes files (present only in the second branch)

*.cpp filter=removeDoxygen

(replace cpp by the right extension for your project sources)

And that involves a local config:

 git config filter.removeDoxygen.smudge 'removeDoxygen'

With removeDoxygen being a shell script anywhere in your $PATH.
(it can be a shell script even on Windows, as it will be executed by the msysgit shell)

That merge will result in files automatically modified (by the smudge script), and they will need to be added and committed in that second branch.

Then push said second branch to repo A.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • More specific to my user case: ''A'' is maintained by mercurial and some code in ''A'' already has doxygen style comment. What is the best action here? – user103500 Jul 07 '16 at 08:09
  • @user103500 I assume is managed by git. Nothing change for repo B: the comments will be removed in second branch. When pushing back to A (http://hg-git.github.io/), those comments should remain gone. – VonC Jul 07 '16 at 08:14
  • @user103500 if B is not directly cloned from A, I would suggest to push to a new branch in A, and then make a mercurial merge within the mercurial repo A. – VonC Jul 07 '16 at 08:14
  • I do not want to remove original comments in ''A'' when I push upstream. I do want to remove my comments in ''B'' when I push upstream. ''B'' is directly cloned from ''A'' in my case. – user103500 Jul 07 '16 at 08:43
  • @user103500 is B a git repo? – VonC Jul 07 '16 at 08:45
  • @user103500 if not, you need the equivalent of smudge for mercurial (for your repo B): http://stackoverflow.com/questions/32271504/mercurial-equivalent-of-gitattributes-smudge-clean-filters – VonC Jul 07 '16 at 09:07