git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[RFC/PATCHv1] git-p4: label import: first draft

From
Luke Diamand <luke@diamand.org>
Date
Mar 17, 2012, 10:44 UTC
Message-ID
<1331981081-25598-1-git-send-email-luke@diamand.org>
From: Luke Diamand <luked@diamand.org>

The existing label import code (--detect-labels) looks at each commit being imported, and then checks for labels at that commit.

This doesn't work in the real world though because labels applied in changelists that have already been imported are ignored. e.g.:

% p4 submit -d 'a change' % git-p4 rebase % p4 tag -l TAG ... % git-p4 sync --detect-labels

TAG will never be detected.
Additionally the existing label detection has some annoying shortcomings
* It gets the list of files at each label every time git-p4 is run,
  which on a large repo with many labels is a problem. The new
  scheme only pays this price the first time a label is seen.
* It only imports a label if the number of files in the label matches
  the number of files in the repo at the highest revision found. This
  is to cope with the way that git tags and p4 labels cannot be
  directly mapped to each other. In practice this is not a useful rule,
  for example if the p4 tag was applied across a wider area of the tree
  than just the part being imported by git-p4, then the tag is ignored.
  The new code just checks that there are no diffs between the label
  and the p4 changelist to be used.

The new code gets the lists of git tags and p4 labels, and then creates git tags for all the missing p4 labels. Any labels that could not be imported are added to an ignore-list so that they are not repeatedly queried. A regular expression can be specified to limit the p4 label patterns that will be imported.

Limitations:
* The code currently doesn't know anything about branch-based setups, and
  has 'p4/master' hardcoded as the branch to search for git revisions. I
  haven't yet thought about the best way to handle this, which is why this
  is only an RFC at this stage. I would welcome suggestions on the best way
  to deal with this.
* The code uses "git log --grep" to get from a p4 changelist to a git
  commit. This means it doesn't work on older versions of git, e.g.
  git 1.7.0. Arguably it should use gitCommitByP4Change().
* The unit tests could be expanded.

Thanks, Luke

Luke Diamand (1):
  git-p4: improved import of labels from p4
 Documentation/git-p4.txt       |   15 +++-
 contrib/fast-import/git-p4     |  152 +++++++++++++++++++++++++++++++---------
 t/t9811-git-p4-label-import.sh |  116 ++++++++++++++++++++++++++++++
 3 files changed, 248 insertions(+), 35 deletions(-)
 create mode 100755 t/t9811-git-p4-label-import.sh
-- 
1.7.10.rc0.158.gd9e55
Next: Luke Diamand
Message 1 of 2 in “[RFC/PATCHv1] git-p4: label import: first draft”
  1. Luke DiamandMar 17, 2012
  2. [RFC/PATCHv1] git-p4: improved import of labels from p4Luke Diamand, Mar 17, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.